fix(bot): better buttons

This commit is contained in:
h
2026-01-21 02:51:59 +01:00
parent 646254cd24
commit bd361c6e7d
3 changed files with 15 additions and 16 deletions

View File

@@ -202,7 +202,7 @@ async def process_message_from_web( # noqa: C901, PLR0912, PLR0915
follow_up_agent = create_follow_up_agent( follow_up_agent = create_follow_up_agent(
api_key=api_key, model_name=follow_up_model, system_prompt=follow_up_prompt api_key=api_key, model_name=follow_up_model, system_prompt=follow_up_prompt
) )
follow_ups = await get_follow_ups(follow_up_agent, full_history) follow_ups = await get_follow_ups(follow_up_agent, full_history, chat_images)
if state: if state:
await state.stop_typing() await state.stop_typing()
@@ -336,7 +336,7 @@ async def process_message(
follow_up_agent = create_follow_up_agent( follow_up_agent = create_follow_up_agent(
api_key=api_key, model_name=follow_up_model, system_prompt=follow_up_prompt api_key=api_key, model_name=follow_up_model, system_prompt=follow_up_prompt
) )
follow_ups = await get_follow_ups(follow_up_agent, full_history) follow_ups = await get_follow_ups(follow_up_agent, full_history, chat_images)
await state.stop_typing() await state.stop_typing()

View File

@@ -41,7 +41,7 @@ def create_text_agent(
model = GoogleModel(model_name, provider=provider) model = GoogleModel(model_name, provider=provider)
base_prompt = system_prompt or DEFAULT_SYSTEM_PROMPT base_prompt = system_prompt or DEFAULT_SYSTEM_PROMPT
full_prompt = f"{base_prompt} {LATEX_INSTRUCTION}" full_prompt = f"{base_prompt} {LATEX_INSTRUCTION}"
return Agent(model, system_prompt=full_prompt) return Agent(model, instructions=full_prompt)
def create_follow_up_agent( def create_follow_up_agent(
@@ -52,7 +52,7 @@ def create_follow_up_agent(
provider = GoogleProvider(api_key=api_key) provider = GoogleProvider(api_key=api_key)
model = GoogleModel(model_name, provider=provider) model = GoogleModel(model_name, provider=provider)
prompt = system_prompt or DEFAULT_FOLLOW_UP prompt = system_prompt or DEFAULT_FOLLOW_UP
return Agent(model, output_type=FollowUpOptions, system_prompt=prompt) return Agent(model, output_type=FollowUpOptions, instructions=prompt)
def build_message_history(history: list[dict[str, str]]) -> list[ModelMessage]: def build_message_history(history: list[dict[str, str]]) -> list[ModelMessage]:
@@ -99,17 +99,17 @@ async def stream_response( # noqa: PLR0913
async def get_follow_ups( async def get_follow_ups(
follow_up_agent: Agent[None, FollowUpOptions], follow_up_agent: Agent[None, FollowUpOptions],
history: list[dict[str, str]], history: list[dict[str, str]],
image: ImageData | None = None, images: list[ImageData] | None = None,
) -> list[str]: ) -> list[str]:
message_history = build_message_history(history) if history else None message_history = build_message_history(history) if history else None
if image: if images:
prompt: list[str | BinaryContent] = [ prompt: list[str | BinaryContent] = ["Process this:"]
"Suggest follow-up options based on this conversation and image.", prompt.extend(
BinaryContent(data=image.data, media_type=image.media_type), BinaryContent(data=img.data, media_type=img.media_type) for img in images
] )
else: else:
prompt = "Suggest follow-up questions based on this conversation." # type: ignore[assignment] prompt = "Process this conversation." # type: ignore[assignment]
result = await follow_up_agent.run(prompt, message_history=message_history) result = await follow_up_agent.run(prompt, message_history=message_history)
return result.output["options"] return result.output["options"]

View File

@@ -12,14 +12,13 @@ When asked for DETAILS on a specific problem (or a problem number):
- Academic style, as it would be written in a notebook - Academic style, as it would be written in a notebook
- Step by step, clean, no fluff""" - Step by step, clean, no fluff"""
EXAM_FOLLOW_UP = """You see a problem set image. List available problem numbers. EXAM_FOLLOW_UP = """Look at the problem set image and list problem numbers as options.
Output only the numbers that exist in the image, like: 1, 2, 3, 4, 5 If problems have sub-parts (a, b, c), list as: 1a, 1b, 2a, etc.
If problems have letters (a, b, c), list them as: 1a, 1b, 2a, etc. Only output identifiers that exist in the image."""
Keep it minimal - just the identifiers."""
DEFAULT_FOLLOW_UP = ( DEFAULT_FOLLOW_UP = (
"Based on the conversation, suggest 3 short follow-up questions " "Based on the conversation, suggest 3 short follow-up questions "
"the user might want to ask. Be concise, each under 50 chars." "the user might want to ask. Each option should be under 50 characters."
) )
SUMMARIZE_PROMPT = """You are summarize agent. You may receive: SUMMARIZE_PROMPT = """You are summarize agent. You may receive: