fix(bot): bei Bild+Preisfrage erzwinge web_search statt Bild-Extraktion, max_tokens 4000
This commit is contained in:
parent
72b90e6982
commit
59de3e3a49
1 changed files with 15 additions and 2 deletions
|
|
@ -355,6 +355,19 @@ def ask_with_image(image_base64: str, caption: str, tool_handlers: dict, session
|
||||||
"Wenn es ein normales Bild ist: Beschreibe strukturiert was du siehst."
|
"Wenn es ein normales Bild ist: Beschreibe strukturiert was du siehst."
|
||||||
)
|
)
|
||||||
prompt_text = caption if caption else default_prompt
|
prompt_text = caption if caption else default_prompt
|
||||||
|
|
||||||
|
_price_kw = ["preis", "kostet", "kosten", "price", "teuer", "guenstig", "billig",
|
||||||
|
"bestpreis", "angebot", "euro", "eur", "kaufen"]
|
||||||
|
_is_price_q = any(kw in (caption or "").lower() for kw in _price_kw)
|
||||||
|
if _is_price_q:
|
||||||
|
prompt_text = (
|
||||||
|
"WICHTIG: Der User fragt nach einem aktuellen Preis. "
|
||||||
|
"Du MUSST zuerst web_search aufrufen um den aktuellen Marktpreis zu ermitteln. "
|
||||||
|
"Nutze das Bild nur als Kontext, NICHT als Preisquelle — Bilder koennen veraltet sein. "
|
||||||
|
"Erst NACH der web_search darfst du antworten.\n\n"
|
||||||
|
+ prompt_text
|
||||||
|
)
|
||||||
|
|
||||||
user_content = [
|
user_content = [
|
||||||
{"type": "text", "text": prompt_text},
|
{"type": "text", "text": prompt_text},
|
||||||
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_base64}", "detail": "high"}},
|
{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image_base64}", "detail": "high"}},
|
||||||
|
|
@ -384,7 +397,7 @@ def ask_with_image(image_base64: str, caption: str, tool_handlers: dict, session
|
||||||
try:
|
try:
|
||||||
for _round in range(MAX_TOOL_ROUNDS):
|
for _round in range(MAX_TOOL_ROUNDS):
|
||||||
data = _call_openrouter(messages, api_key, use_tools=True,
|
data = _call_openrouter(messages, api_key, use_tools=True,
|
||||||
model=VISION_MODEL, max_tokens=1200)
|
model=VISION_MODEL, max_tokens=4000)
|
||||||
choice = data["choices"][0]
|
choice = data["choices"][0]
|
||||||
msg = choice["message"]
|
msg = choice["message"]
|
||||||
|
|
||||||
|
|
@ -418,7 +431,7 @@ def ask_with_image(image_base64: str, caption: str, tool_handlers: dict, session
|
||||||
})
|
})
|
||||||
|
|
||||||
data = _call_openrouter(messages, api_key, use_tools=False,
|
data = _call_openrouter(messages, api_key, use_tools=False,
|
||||||
model=VISION_MODEL, max_tokens=1200)
|
model=VISION_MODEL, max_tokens=4000)
|
||||||
return data["choices"][0]["message"]["content"]
|
return data["choices"][0]["message"]["content"]
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue