fix(bot): better buttons
This commit is contained in:
@@ -202,7 +202,7 @@ async def process_message_from_web( # noqa: C901, PLR0912, PLR0915
|
||||
follow_up_agent = create_follow_up_agent(
|
||||
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:
|
||||
await state.stop_typing()
|
||||
@@ -336,7 +336,7 @@ async def process_message(
|
||||
follow_up_agent = create_follow_up_agent(
|
||||
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()
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ def create_text_agent(
|
||||
model = GoogleModel(model_name, provider=provider)
|
||||
base_prompt = system_prompt or DEFAULT_SYSTEM_PROMPT
|
||||
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(
|
||||
@@ -52,7 +52,7 @@ def create_follow_up_agent(
|
||||
provider = GoogleProvider(api_key=api_key)
|
||||
model = GoogleModel(model_name, provider=provider)
|
||||
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]:
|
||||
@@ -99,17 +99,17 @@ async def stream_response( # noqa: PLR0913
|
||||
async def get_follow_ups(
|
||||
follow_up_agent: Agent[None, FollowUpOptions],
|
||||
history: list[dict[str, str]],
|
||||
image: ImageData | None = None,
|
||||
images: list[ImageData] | None = None,
|
||||
) -> list[str]:
|
||||
message_history = build_message_history(history) if history else None
|
||||
|
||||
if image:
|
||||
prompt: list[str | BinaryContent] = [
|
||||
"Suggest follow-up options based on this conversation and image.",
|
||||
BinaryContent(data=image.data, media_type=image.media_type),
|
||||
]
|
||||
if images:
|
||||
prompt: list[str | BinaryContent] = ["Process this:"]
|
||||
prompt.extend(
|
||||
BinaryContent(data=img.data, media_type=img.media_type) for img in images
|
||||
)
|
||||
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)
|
||||
return result.output["options"]
|
||||
|
||||
@@ -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
|
||||
- Step by step, clean, no fluff"""
|
||||
|
||||
EXAM_FOLLOW_UP = """You see a problem set image. List available problem numbers.
|
||||
Output only the numbers that exist in the image, like: 1, 2, 3, 4, 5
|
||||
If problems have letters (a, b, c), list them as: 1a, 1b, 2a, etc.
|
||||
Keep it minimal - just the identifiers."""
|
||||
EXAM_FOLLOW_UP = """Look at the problem set image and list problem numbers as options.
|
||||
If problems have sub-parts (a, b, c), list as: 1a, 1b, 2a, etc.
|
||||
Only output identifiers that exist in the image."""
|
||||
|
||||
DEFAULT_FOLLOW_UP = (
|
||||
"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:
|
||||
|
||||
Reference in New Issue
Block a user