Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,59 +39,87 @@ except Exception as e:
|
|
| 39 |
prompt_templates = {
|
| 40 |
"system_prompt": (
|
| 41 |
"You are a helpful assistant that responds in the same language as the user's query. "
|
| 42 |
-
"Detect the language of the query and respond
|
| 43 |
-
"For time-related questions (e.g., 'What time is it in [place]?'), use the `get_current_time_in_timezone` tool "
|
| 44 |
"with the appropriate timezone (e.g., 'Europe/Moscow' for Moscow, 'Asia/Yekaterinburg' for Birsk). "
|
| 45 |
"NEVER redefine tools—use only the provided ones. "
|
| 46 |
-
"Always return the response via `final_answer()
|
| 47 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
),
|
| 49 |
"default": "Response: {{question}}",
|
| 50 |
"planning": {
|
| 51 |
"initial_plan": (
|
| 52 |
"Analyze the query: {{question}}. Determine if a tool is needed. "
|
| 53 |
-
"If the query is about time, use `get_current_time_in_timezone` with the correct timezone (e.g., 'Asia/Yekaterinburg' for Birsk). "
|
| 54 |
-
"
|
|
|
|
|
|
|
|
|
|
| 55 |
),
|
| 56 |
"update_plan_pre_messages": (
|
| 57 |
"Review the query: {{question}} and previous steps. "
|
| 58 |
-
"If the plan needs adjustment (e.g., wrong timezone
|
| 59 |
-
"Write corrected code
|
|
|
|
|
|
|
|
|
|
| 60 |
),
|
| 61 |
"update_plan_post_messages": (
|
| 62 |
"Review the query: {{question}} and execution results. "
|
| 63 |
"If the result is incorrect or incomplete, adjust the plan and code. "
|
| 64 |
-
"Return the
|
|
|
|
|
|
|
|
|
|
| 65 |
)
|
| 66 |
},
|
| 67 |
"managed_agent": {
|
| 68 |
"execute": (
|
| 69 |
"Execute the task: {{question}}. Use tools as specified in the plan. "
|
| 70 |
-
"
|
| 71 |
-
"
|
|
|
|
|
|
|
|
|
|
| 72 |
),
|
| 73 |
"report": (
|
| 74 |
"Summarize the execution of the task: {{question}}. "
|
| 75 |
-
"
|
| 76 |
-
"
|
|
|
|
|
|
|
| 77 |
),
|
| 78 |
"task": (
|
| 79 |
"Define the task based on the query: {{question}}. "
|
| 80 |
-
"Identify the required tools and steps
|
| 81 |
-
"Return the task definition via
|
|
|
|
|
|
|
|
|
|
| 82 |
)
|
| 83 |
},
|
| 84 |
"final_answer": {
|
| 85 |
"pre_messages": (
|
| 86 |
"Prepare the final response for the query: {{question}}. "
|
| 87 |
"Ensure the answer is clear and in the same language as the query. "
|
| 88 |
-
"
|
|
|
|
|
|
|
|
|
|
| 89 |
),
|
| 90 |
"template": "Final response: {{answer}}",
|
| 91 |
"post_messages": (
|
| 92 |
"Review the formatted response for the query: {{question}}. "
|
| 93 |
"Ensure the response is accurate and complete. "
|
| 94 |
-
"Return the final response via
|
|
|
|
|
|
|
|
|
|
| 95 |
)
|
| 96 |
}
|
| 97 |
}
|
|
|
|
| 39 |
prompt_templates = {
|
| 40 |
"system_prompt": (
|
| 41 |
"You are a helpful assistant that responds in the same language as the user's query. "
|
| 42 |
+
"Detect the language of the query and respond with the result only, without extra explanations. "
|
| 43 |
+
"For time-related questions (e.g., 'What time is it in [place]?') or city names (e.g., 'Birsk'), use the `get_current_time_in_timezone` tool "
|
| 44 |
"with the appropriate timezone (e.g., 'Europe/Moscow' for Moscow, 'Asia/Yekaterinburg' for Birsk). "
|
| 45 |
"NEVER redefine tools—use only the provided ones. "
|
| 46 |
+
"Always return the response via `final_answer()` in a code block like this:\n"
|
| 47 |
+
"```py\n"
|
| 48 |
+
"final_answer('YOUR ANSWER HERE')\n"
|
| 49 |
+
"```\n"
|
| 50 |
+
"Do NOT include tool calls (e.g., get_current_time_in_timezone()) inside final_answer(). "
|
| 51 |
+
"Execute the tool first, then pass the result as a string to final_answer(). "
|
| 52 |
+
"If the query is unclear, ask for clarification in the same language via final_answer()."
|
| 53 |
),
|
| 54 |
"default": "Response: {{question}}",
|
| 55 |
"planning": {
|
| 56 |
"initial_plan": (
|
| 57 |
"Analyze the query: {{question}}. Determine if a tool is needed. "
|
| 58 |
+
"If the query is about time or mentions a city (e.g., 'Birsk'), use `get_current_time_in_timezone` with the correct timezone (e.g., 'Asia/Yekaterinburg' for Birsk). "
|
| 59 |
+
"Write code to execute the tool and return the result via final_answer() in a code block:\n"
|
| 60 |
+
"```py\n"
|
| 61 |
+
"final_answer('YOUR ANSWER HERE')\n"
|
| 62 |
+
"```"
|
| 63 |
),
|
| 64 |
"update_plan_pre_messages": (
|
| 65 |
"Review the query: {{question}} and previous steps. "
|
| 66 |
+
"If the plan needs adjustment (e.g., wrong timezone), update it. "
|
| 67 |
+
"Write corrected code in a code block:\n"
|
| 68 |
+
"```py\n"
|
| 69 |
+
"final_answer('YOUR ANSWER HERE')\n"
|
| 70 |
+
"```"
|
| 71 |
),
|
| 72 |
"update_plan_post_messages": (
|
| 73 |
"Review the query: {{question}} and execution results. "
|
| 74 |
"If the result is incorrect or incomplete, adjust the plan and code. "
|
| 75 |
+
"Return the result via final_answer() in a code block:\n"
|
| 76 |
+
"```py\n"
|
| 77 |
+
"final_answer('YOUR ANSWER HERE')\n"
|
| 78 |
+
"```"
|
| 79 |
)
|
| 80 |
},
|
| 81 |
"managed_agent": {
|
| 82 |
"execute": (
|
| 83 |
"Execute the task: {{question}}. Use tools as specified in the plan. "
|
| 84 |
+
"Write code in a code block:\n"
|
| 85 |
+
"```py\n"
|
| 86 |
+
"result = get_current_time_in_timezone('TIMEZONE')\n"
|
| 87 |
+
"final_answer(result)\n"
|
| 88 |
+
"```"
|
| 89 |
),
|
| 90 |
"report": (
|
| 91 |
"Summarize the execution of the task: {{question}}. "
|
| 92 |
+
"Return the result via final_answer() in a code block:\n"
|
| 93 |
+
"```py\n"
|
| 94 |
+
"final_answer('YOUR ANSWER HERE')\n"
|
| 95 |
+
"```"
|
| 96 |
),
|
| 97 |
"task": (
|
| 98 |
"Define the task based on the query: {{question}}. "
|
| 99 |
+
"Identify the required tools and steps. "
|
| 100 |
+
"Return the task definition via final_answer() in a code block:\n"
|
| 101 |
+
"```py\n"
|
| 102 |
+
"final_answer('YOUR TASK DEFINITION HERE')\n"
|
| 103 |
+
"```"
|
| 104 |
)
|
| 105 |
},
|
| 106 |
"final_answer": {
|
| 107 |
"pre_messages": (
|
| 108 |
"Prepare the final response for the query: {{question}}. "
|
| 109 |
"Ensure the answer is clear and in the same language as the query. "
|
| 110 |
+
"Return the response via final_answer() in a code block:\n"
|
| 111 |
+
"```py\n"
|
| 112 |
+
"final_answer('YOUR ANSWER HERE')\n"
|
| 113 |
+
"```"
|
| 114 |
),
|
| 115 |
"template": "Final response: {{answer}}",
|
| 116 |
"post_messages": (
|
| 117 |
"Review the formatted response for the query: {{question}}. "
|
| 118 |
"Ensure the response is accurate and complete. "
|
| 119 |
+
"Return the final response via final_answer() in a code block:\n"
|
| 120 |
+
"```py\n"
|
| 121 |
+
"final_answer('YOUR ANSWER HERE')\n"
|
| 122 |
+
"```"
|
| 123 |
)
|
| 124 |
}
|
| 125 |
}
|