3๊ฐ ์ปฌ๋ ์
ํธ์ถํ๋ ๋ฒ (ํ
์คํธ ์ปฌ๋ ์
: page, ์ด๋ฏธ์ง - colqwen, ์ด๋ฏธ์ง - tomoro)
โ
1. ํ
์คํธ ์ฟผ๋ฆฌ - page ์ปฌ๋ ์
๊ฒ์
๐ข 1-1. ํํฐ ์์ด ๊ฒ์
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. ๋จ์ผ ํํฐ ์ ์ฉ
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 ์กฐ๊ฑด)
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. ํํฐ ์์ด ๊ฒ์
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. ๋ค์ค ํํฐ ์ ์ฉ
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. ํํฐ ์์ด ๊ฒ์
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. ๋ค์ค ํํฐ ์ ์ฉ
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. ๋จ์ด ์ฌ์
๋จ์ด์ฌ์ ํธ์ถํ๋ ๋ฒ
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
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'])
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}
}
)
print(response.json()['choices'][0]['message']['content'])