# 3개 컬렉션 호출하는 법 (텍스트 컬렉션 : page, 이미지 - colqwen, 이미지 - tomoro) # ✅ 1. 텍스트 쿼리 - `page` 컬렉션 검색 ### 🟢 1-1. 필터 없이 검색 ```bash curl -X 'POST' \   'http://10.150.6.47:4275/search/text' \   -H 'accept: application/json' \   -H 'Content-Type: application/json' \   -d '{     "query": "물류업체 선정 기준",     "top_k": 3   }' ``` ### 🟢 1-2. 단일 필터 적용 ```bash curl -X 'POST' \   'http://10.150.6.47:4275/search/text' \   -H 'accept: application/json' \   -H 'Content-Type: application/json' \   -d '{     "query": "DSG",     "top_k": 3,     "filters": {       "apply_region": "2공장"     }   }' ``` ### 🟢 1-3. 다중 필터 적용 (AND 조건) ```bash curl -X 'POST' \   'http://10.150.6.47:4275/search/text' \   -H 'accept: application/json' \   -H 'Content-Type: application/json' \   -d '{     "query": "DSG 상정반 교체 절차",     "top_k": 3,     "filters": {       "apply_region": "3공장",       "apply_product": "300mm"     }   }' ``` --- # ✅ 2. 텍스트 쿼리 - 이미지 컬렉션 검색 (`Tomoro`) ### 🟡 2-1. 필터 없이 검색 ```bash curl -X 'POST' \   'http://10.150.6.47:4275/search/text/tomoro' \   -H 'accept: application/json' \   -H 'Content-Type: application/json' \   -d '{     "query": "물류업체 선정 기준",     "top_k": 3   }' ``` ### 🟡 2-2. 다중 필터 적용 ```bash curl -X 'POST' \   'http://10.150.6.47:4275/search/text/tomoro' \   -H 'accept: application/json' \   -H 'Content-Type: application/json' \   -d '{     "query": "출하검사 기준",     "top_k": 3,     "filters": {       "document_type": "지침서",       "apply_product": "지원부문"     }   }' ``` --- ## ✅ 3. 텍스트 쿼리 - 이미지 컬렉션 검색 (`ColQwen3.5`) ### 🟢 3-1. 필터 없이 검색 ```bash curl -X 'POST' \   'http://10.150.6.47:4275/search/text/colqwen35' \   -H 'accept: application/json' \   -H 'Content-Type: application/json' \   -d '{     "query": "안전운전 절차",     "top_k": 3   }' ``` ### 🟢 3-2. 다중 필터 적용 ```bash curl -X 'POST' \   'http://10.150.6.47:4275/search/text/colqwen35' \   -H 'accept: application/json' \   -H 'Content-Type: application/json' \   -d '{     "query": "물류업체 선정 기준",     "top_k": 3,     "filters": {       "apply_region": "전사공통",       "dept_name": "Infra구매팀"     }   }' ``` # 3. 단어 사전 # 단어사전 호출하는 법 ```bash curl -X POST 'http://10.150.6.47:4276/search/term' \ -H 'Content-Type: application/json' \ -d '{   "query": "안전골든룰",   "top_k": 3,   "filters": {     "apply_region": "전사공통",     "document_type": "지침서"   } }' ``` # 4. 최종 api call ``` import requests import json # 🔧 설정 BASE_URL = "http://10.150.6.46:18504" # FastAPI 서버 주소 SEARCH_ENDPOINT = f"{BASE_URL}/search" # 📝 쿼리 요청 데이터 payload = { "query": "TTV 규격 기준", "top_k": 10, "image_backend": "colqwen35", # 또는 "tomoro" "alpha_override": None, # 자동으로 query_type 기반 alpha 적용 "filters": { # 필요 시 필터 추가 (예: 부서, 지역, 제품 등) # "dept_name": "품질관리팀", # "apply_region": "Korea" }, "return_debug": True, # 디버그 정보 포함 (개발용) "rerank": True # 리랭커 사용 여부 (환경 기본값 따름) } # 🌐 요청 보내기 try: print("🔍 'TTV 규격 기준' 쿼리 전송 중...") response = requests.post( SEARCH_ENDPOINT, json=payload, timeout=60 # 서버 응답 대기 시간 ) # 🔍 응답 확인 if response.status_code == 200: result = response.json() print("\n✅ 성공! 검색 결과:") print(json.dumps(result, indent=2, ensure_ascii=False)) # 간단히 상위 3개 결과 출력 print("\n📌 상위 3개 결과 요약:") for i, item in enumerate(result["results"][:3], 1): rank = item["rank"] score = item["score"] rerank_score = item.get("rerank_score") content = item["content"] or "(내용 없음)" print(f" {i}. [Rank:{rank}] (Score: {score:.4f}, Rerank: {rerank_score})") print(f" {content[:150]}...") else: print(f"❌ 요청 실패: {response.status_code} - {response.text}") except requests.exceptions.ConnectionError: print("🚨 연결 오류: FastAPI 서버가 실행 중인지 확인하세요 (uvicorn 실행 여부)") except requests.exceptions.Timeout: print("⏰ 타임아웃: 서버 응답이 지연되고 있습니다.") except Exception as e: print(f"💥 예상치 못한 오류: {e}") ``` # VLM API CALL ```python ### H200-2 서버 : Qwen3.5-397B-A17B-FP8 ### 이미지 Input import requests import base64 import mimetypes ''' Thinking mode: temperature=0.6, top_p=0.95, top_k=20, min_p=0.0, presence_penalty=0.0, repetition_penalty=1.0 Instruct (or non-thinking) mode: temperature=0.7, top_p=0.8, top_k=20, min_p=0.0, presence_penalty=1.5, repetition_penalty=1.0 ''' def encode_image_to_base64(image_path): mime_type,_ = mimetypes.guess_type(image_path) with open(image_path, "rb") as image_file: base64_encoded = base64.b64encode(image_file.read()).decode("utf-8") return f"data:{mime_type};base64,{base64_encoded}" image_path = "./test.png" image_input = { "type": "image_url", "image_url": { "url": f"{encode_image_to_base64(image_path)}" } } response = requests.post( "http://10.150.6.160:8000/v1/chat/completions", json={ "model": "Qwen3.5-397B-A17B-FP8", 'messages':[ {"role":"system", "content":"너는 SK실트론의 AI Assistant입니다."}, {"role":"user", "content":[ image_input, {"type":"text","text":"이미지 OCR해줘"} ] } ], "temperature":0.6, "top_p":0.95, "top_k":20, "min_p":0.0, "presence_penalty":0.0, "repetition_penalty":1.0, } ) print(response.json()['choices'][0]['message']['content']) ### Non-thinking response = requests.post( "http://10.150.6.160:8000/v1/chat/completions", json={ "model": "Qwen3.5-397B-A17B-FP8", 'messages':[ {"role":"system", "content":"너는 SK실트론의 AI Assistant입니다."}, {"role":"user", "content":[ {"type":"text","text":"안녕하세요."} ] } ], "temperature":0.7, "top_p":0.8, "top_k":20, "min_p":0.0, "presence_penalty":1.5, "repetition_penalty":1.0, "chat_template_kwargs": {"enable_thinking": False} ## Thinking(Reasoning) off } ) print(response.json()['choices'][0]['message']['content']) ```