Spaces:
Runtime error
Runtime error
Upload agent
Browse files- agent.json +14 -11
- app.py +3 -2
- prompts.yaml +10 -154
agent.json
CHANGED
|
@@ -15,20 +15,20 @@
|
|
| 15 |
"prompt_templates": {
|
| 16 |
"system_prompt": "You are a helpful assistant.",
|
| 17 |
"planning": {
|
| 18 |
-
"initial_facts": "
|
| 19 |
-
"initial_plan": "
|
| 20 |
-
"update_facts_pre_messages": "
|
| 21 |
-
"update_facts_post_messages": "
|
| 22 |
-
"update_plan_pre_messages": "
|
| 23 |
-
"update_plan_post_messages": "
|
| 24 |
},
|
| 25 |
"managed_agent": {
|
| 26 |
-
"task": "
|
| 27 |
-
"report": "
|
| 28 |
},
|
| 29 |
"final_answer": {
|
| 30 |
-
"pre_messages": "
|
| 31 |
-
"post_messages": "
|
| 32 |
},
|
| 33 |
"custom": "You are a helpful assistant."
|
| 34 |
},
|
|
@@ -40,5 +40,8 @@
|
|
| 40 |
"description": null,
|
| 41 |
"requirements": [
|
| 42 |
"smolagents"
|
| 43 |
-
]
|
|
|
|
|
|
|
|
|
|
| 44 |
}
|
|
|
|
| 15 |
"prompt_templates": {
|
| 16 |
"system_prompt": "You are a helpful assistant.",
|
| 17 |
"planning": {
|
| 18 |
+
"initial_facts": "",
|
| 19 |
+
"initial_plan": "",
|
| 20 |
+
"update_facts_pre_messages": "",
|
| 21 |
+
"update_facts_post_messages": "",
|
| 22 |
+
"update_plan_pre_messages": "",
|
| 23 |
+
"update_plan_post_messages": ""
|
| 24 |
},
|
| 25 |
"managed_agent": {
|
| 26 |
+
"task": "",
|
| 27 |
+
"report": ""
|
| 28 |
},
|
| 29 |
"final_answer": {
|
| 30 |
+
"pre_messages": "",
|
| 31 |
+
"post_messages": ""
|
| 32 |
},
|
| 33 |
"custom": "You are a helpful assistant."
|
| 34 |
},
|
|
|
|
| 40 |
"description": null,
|
| 41 |
"requirements": [
|
| 42 |
"smolagents"
|
| 43 |
+
],
|
| 44 |
+
"model_settings": {
|
| 45 |
+
"temperature": 0.0
|
| 46 |
+
}
|
| 47 |
}
|
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import yaml
|
| 2 |
import os
|
| 3 |
-
from smolagents import GradioUI,
|
| 4 |
|
| 5 |
# Get current directory path
|
| 6 |
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
@@ -20,7 +20,7 @@ final_answer = FinalAnswer()
|
|
| 20 |
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
|
| 21 |
prompt_templates = yaml.safe_load(stream)
|
| 22 |
|
| 23 |
-
agent =
|
| 24 |
model=model,
|
| 25 |
tools=[],
|
| 26 |
managed_agents=[],
|
|
@@ -30,6 +30,7 @@ agent = ToolCallingAgent(
|
|
| 30 |
planning_interval=None,
|
| 31 |
name=None,
|
| 32 |
description=None,
|
|
|
|
| 33 |
prompt_templates=prompt_templates
|
| 34 |
)
|
| 35 |
if __name__ == "__main__":
|
|
|
|
| 1 |
import yaml
|
| 2 |
import os
|
| 3 |
+
from smolagents import GradioUI, HfPaiToolAgent, LiteLLMModel
|
| 4 |
|
| 5 |
# Get current directory path
|
| 6 |
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
| 20 |
with open(os.path.join(CURRENT_DIR, "prompts.yaml"), 'r') as stream:
|
| 21 |
prompt_templates = yaml.safe_load(stream)
|
| 22 |
|
| 23 |
+
agent = HfPaiToolAgent(
|
| 24 |
model=model,
|
| 25 |
tools=[],
|
| 26 |
managed_agents=[],
|
|
|
|
| 30 |
planning_interval=None,
|
| 31 |
name=None,
|
| 32 |
description=None,
|
| 33 |
+
model_settings={'temperature': 0.0},
|
| 34 |
prompt_templates=prompt_templates
|
| 35 |
)
|
| 36 |
if __name__ == "__main__":
|
prompts.yaml
CHANGED
|
@@ -1,161 +1,17 @@
|
|
| 1 |
"system_prompt": |-
|
| 2 |
You are a helpful assistant.
|
| 3 |
"planning":
|
| 4 |
-
"initial_facts":
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
---
|
| 12 |
-
### 1. Facts given in the task
|
| 13 |
-
List here the specific facts given in the task that could help you (there might be nothing here).
|
| 14 |
-
|
| 15 |
-
### 2. Facts to look up
|
| 16 |
-
List here any facts that we may need to look up.
|
| 17 |
-
Also list where to find each of these, for instance a website, a file... - maybe the task contains some sources that you should re-use here.
|
| 18 |
-
|
| 19 |
-
### 3. Facts to derive
|
| 20 |
-
List here anything that we want to derive from the above by logical reasoning, for instance computation or simulation.
|
| 21 |
-
|
| 22 |
-
Keep in mind that "facts" will typically be specific names, dates, values, etc. Your answer should use the below headings:
|
| 23 |
-
### 1. Facts given in the task
|
| 24 |
-
### 2. Facts to look up
|
| 25 |
-
### 3. Facts to derive
|
| 26 |
-
Do not add anything else.
|
| 27 |
-
|
| 28 |
-
Here is the task:
|
| 29 |
-
```
|
| 30 |
-
{{task}}
|
| 31 |
-
```
|
| 32 |
-
Now begin!
|
| 33 |
-
"initial_plan": |-
|
| 34 |
-
You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
|
| 35 |
-
|
| 36 |
-
Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
|
| 37 |
-
This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
|
| 38 |
-
Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
|
| 39 |
-
After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
|
| 40 |
-
|
| 41 |
-
Here is your task:
|
| 42 |
-
|
| 43 |
-
Task:
|
| 44 |
-
```
|
| 45 |
-
{{task}}
|
| 46 |
-
```
|
| 47 |
-
You can leverage these tools:
|
| 48 |
-
{%- for tool in tools.values() %}
|
| 49 |
-
- {{ tool.name }}: {{ tool.description }}
|
| 50 |
-
Takes inputs: {{tool.inputs}}
|
| 51 |
-
Returns an output of type: {{tool.output_type}}
|
| 52 |
-
{%- endfor %}
|
| 53 |
-
|
| 54 |
-
{%- if managed_agents and managed_agents.values() | list %}
|
| 55 |
-
You can also give tasks to team members.
|
| 56 |
-
Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task', a long string explaining your task.
|
| 57 |
-
Given that this team member is a real human, you should be very verbose in your task.
|
| 58 |
-
Here is a list of the team members that you can call:
|
| 59 |
-
{%- for agent in managed_agents.values() %}
|
| 60 |
-
- {{ agent.name }}: {{ agent.description }}
|
| 61 |
-
{%- endfor %}
|
| 62 |
-
{%- endif %}
|
| 63 |
-
|
| 64 |
-
List of facts that you know:
|
| 65 |
-
```
|
| 66 |
-
{{answer_facts}}
|
| 67 |
-
```
|
| 68 |
-
|
| 69 |
-
Now begin! Write your plan below.
|
| 70 |
-
"update_facts_pre_messages": |-
|
| 71 |
-
You are a world expert at gathering known and unknown facts based on a conversation.
|
| 72 |
-
Below you will find a task, and a history of attempts made to solve the task. You will have to produce a list of these:
|
| 73 |
-
### 1. Facts given in the task
|
| 74 |
-
### 2. Facts that we have learned
|
| 75 |
-
### 3. Facts still to look up
|
| 76 |
-
### 4. Facts still to derive
|
| 77 |
-
Find the task and history below:
|
| 78 |
-
"update_facts_post_messages": |-
|
| 79 |
-
Earlier we've built a list of facts.
|
| 80 |
-
But since in your previous steps you may have learned useful new facts or invalidated some false ones.
|
| 81 |
-
Please update your list of facts based on the previous history, and provide these headings:
|
| 82 |
-
### 1. Facts given in the task
|
| 83 |
-
### 2. Facts that we have learned
|
| 84 |
-
### 3. Facts still to look up
|
| 85 |
-
### 4. Facts still to derive
|
| 86 |
-
|
| 87 |
-
Now write your new list of facts below.
|
| 88 |
-
"update_plan_pre_messages": |-
|
| 89 |
-
You are a world expert at making efficient plans to solve any task using a set of carefully crafted tools.
|
| 90 |
-
|
| 91 |
-
You have been given a task:
|
| 92 |
-
```
|
| 93 |
-
{{task}}
|
| 94 |
-
```
|
| 95 |
-
|
| 96 |
-
Find below the record of what has been tried so far to solve it. Then you will be asked to make an updated plan to solve the task.
|
| 97 |
-
If the previous tries so far have met some success, you can make an updated plan based on these actions.
|
| 98 |
-
If you are stalled, you can make a completely new plan starting from scratch.
|
| 99 |
-
"update_plan_post_messages": |-
|
| 100 |
-
You're still working towards solving this task:
|
| 101 |
-
```
|
| 102 |
-
{{task}}
|
| 103 |
-
```
|
| 104 |
-
|
| 105 |
-
You can leverage these tools:
|
| 106 |
-
{%- for tool in tools.values() %}
|
| 107 |
-
- {{ tool.name }}: {{ tool.description }}
|
| 108 |
-
Takes inputs: {{tool.inputs}}
|
| 109 |
-
Returns an output of type: {{tool.output_type}}
|
| 110 |
-
{%- endfor %}
|
| 111 |
-
|
| 112 |
-
{%- if managed_agents and managed_agents.values() | list %}
|
| 113 |
-
You can also give tasks to team members.
|
| 114 |
-
Calling a team member works the same as for calling a tool: simply, the only argument you can give in the call is 'task'.
|
| 115 |
-
Given that this team member is a real human, you should be very verbose in your task, it should be a long string providing informations as detailed as necessary.
|
| 116 |
-
Here is a list of the team members that you can call:
|
| 117 |
-
{%- for agent in managed_agents.values() %}
|
| 118 |
-
- {{ agent.name }}: {{ agent.description }}
|
| 119 |
-
{%- endfor %}
|
| 120 |
-
{%- endif %}
|
| 121 |
-
|
| 122 |
-
Here is the up to date list of facts that you know:
|
| 123 |
-
```
|
| 124 |
-
{{facts_update}}
|
| 125 |
-
```
|
| 126 |
-
|
| 127 |
-
Now for the given task, develop a step-by-step high-level plan taking into account the above inputs and list of facts.
|
| 128 |
-
This plan should involve individual tasks based on the available tools, that if executed correctly will yield the correct answer.
|
| 129 |
-
Beware that you have {remaining_steps} steps remaining.
|
| 130 |
-
Do not skip steps, do not add any superfluous steps. Only write the high-level plan, DO NOT DETAIL INDIVIDUAL TOOL CALLS.
|
| 131 |
-
After writing the final step of the plan, write the '\n<end_plan>' tag and stop there.
|
| 132 |
-
|
| 133 |
-
Now write your new plan below.
|
| 134 |
"managed_agent":
|
| 135 |
-
"task":
|
| 136 |
-
|
| 137 |
-
You have been submitted this task by your manager.
|
| 138 |
-
---
|
| 139 |
-
Task:
|
| 140 |
-
{{task}}
|
| 141 |
-
---
|
| 142 |
-
You're helping your manager solve a wider task: so make sure to not provide a one-line answer, but give as much information as possible to give them a clear understanding of the answer.
|
| 143 |
-
|
| 144 |
-
Your final_answer WILL HAVE to contain these parts:
|
| 145 |
-
### 1. Task outcome (short version):
|
| 146 |
-
### 2. Task outcome (extremely detailed version):
|
| 147 |
-
### 3. Additional context (if relevant):
|
| 148 |
-
|
| 149 |
-
Put all these in your final_answer tool, everything that you do not pass as an argument to final_answer will be lost.
|
| 150 |
-
And even if your task resolution is not successful, please return as much context as possible, so that your manager can act upon this feedback.
|
| 151 |
-
"report": |-
|
| 152 |
-
Here is the final answer from your managed agent '{{name}}':
|
| 153 |
-
{{final_answer}}
|
| 154 |
"final_answer":
|
| 155 |
-
"pre_messages":
|
| 156 |
-
|
| 157 |
-
"post_messages": |-
|
| 158 |
-
Based on the above, please provide an answer to the following user task:
|
| 159 |
-
{{task}}
|
| 160 |
"custom": |-
|
| 161 |
You are a helpful assistant.
|
|
|
|
| 1 |
"system_prompt": |-
|
| 2 |
You are a helpful assistant.
|
| 3 |
"planning":
|
| 4 |
+
"initial_facts": ""
|
| 5 |
+
"initial_plan": ""
|
| 6 |
+
"update_facts_pre_messages": ""
|
| 7 |
+
"update_facts_post_messages": ""
|
| 8 |
+
"update_plan_pre_messages": ""
|
| 9 |
+
"update_plan_post_messages": ""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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