052591281d
- Complete agent system with planning and execution - Bridge API with FastAPI server - WhatsApp-style mobile dashboard - Enhanced web search with query improvement - Security guards and policy checks - Comprehensive documentation
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
"""Build a structured instruction string from a run goal.
|
|
|
|
The instruction is the prompt that gets sent to the adapter.
|
|
In V1.1 this is a deterministic text transformation — no LLM required.
|
|
A future stage could replace this with an LLM-based planner.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
|
|
def build(goal: str) -> str:
|
|
"""Format goal into an adapter-ready instruction string."""
|
|
|
|
# Add specific instructions for search tasks
|
|
search_keywords = ["search", "найди", "поиск", "news", "новости", "найти информацию", "find"]
|
|
is_search_task = any(kw in goal.lower() for kw in search_keywords)
|
|
|
|
instruction = f"Task: {goal.strip()}\n\n"
|
|
instruction += "Please complete the task above. Respond with a concise result.\n\n"
|
|
|
|
if is_search_task:
|
|
instruction += (
|
|
"IMPORTANT INSTRUCTIONS FOR SEARCH TASKS:\\n"
|
|
"1. Use web_search to find relevant information\\n"
|
|
"2. Carefully analyze all search results (titles and snippets)\\n"
|
|
"3. Choose the most relevant result based on the snippets and your task\\n"
|
|
"4. Use the chosen result's URL to call web_fetch\\n"
|
|
"5. Analyze the fetched content and provide your answer\\n"
|
|
)
|
|
|
|
return instruction
|