Commit
·
637daef
1
Parent(s):
2ea8556
Updated prompt
Browse files- CEO/CEO.py +4 -3
- main.py +3 -1
- models/system2.prompt +9 -51
- tools/TimeApi.py +0 -43
CEO/CEO.py
CHANGED
@@ -21,13 +21,14 @@ class GeminiManager:
|
|
21 |
contents=messages,
|
22 |
config=types.GenerateContentConfig(
|
23 |
system_instruction=self.system_prompt,
|
24 |
-
temperature=0.
|
25 |
tools=self.toolsLoader.getTools(),
|
26 |
),
|
27 |
)
|
28 |
|
|
|
|
|
29 |
if response.text is not None:
|
30 |
-
print(f"Response: {response.text}")
|
31 |
assistant_content = types.Content(
|
32 |
role='assistant',
|
33 |
parts=[types.Part.from_text(text=response.text)],
|
@@ -53,7 +54,7 @@ class GeminiManager:
|
|
53 |
print(f"Error loading tools: {e}")
|
54 |
tool_content = types.Part.from_function_response(
|
55 |
name=function_call.name,
|
56 |
-
response={"result":"
|
57 |
parts.append(tool_content)
|
58 |
function_response_content = types.Content(
|
59 |
role='tool', parts=parts
|
|
|
21 |
contents=messages,
|
22 |
config=types.GenerateContentConfig(
|
23 |
system_instruction=self.system_prompt,
|
24 |
+
temperature=0.2,
|
25 |
tools=self.toolsLoader.getTools(),
|
26 |
),
|
27 |
)
|
28 |
|
29 |
+
print(f"Response: {response}")
|
30 |
+
|
31 |
if response.text is not None:
|
|
|
32 |
assistant_content = types.Content(
|
33 |
role='assistant',
|
34 |
parts=[types.Part.from_text(text=response.text)],
|
|
|
54 |
print(f"Error loading tools: {e}")
|
55 |
tool_content = types.Part.from_function_response(
|
56 |
name=function_call.name,
|
57 |
+
response={"result":"New tool doesn't follow the required format, please read the other tool implementations for reference." + str(e)})
|
58 |
parts.append(tool_content)
|
59 |
function_response_content = types.Content(
|
60 |
role='tool', parts=parts
|
main.py
CHANGED
@@ -3,6 +3,7 @@ from typing import List
|
|
3 |
from googlesearch import search
|
4 |
from CEO.CEO import GeminiManager
|
5 |
from CEO.tool_loader import ToolLoader
|
|
|
6 |
|
7 |
# Define the web search tool function.
|
8 |
def web_search(website: str, query: str) -> List[str]:
|
@@ -19,6 +20,7 @@ def web_search(website: str, query: str) -> List[str]:
|
|
19 |
return results
|
20 |
|
21 |
if __name__ == "__main__":
|
|
|
22 |
# Define the tool metadata for orchestration.
|
23 |
tools = [
|
24 |
{
|
@@ -48,7 +50,7 @@ if __name__ == "__main__":
|
|
48 |
# The prompt explicitly mentions that it can use the web_search tool if needed,
|
49 |
# and that it is allowed to choose the website for the search.
|
50 |
task_prompt = (
|
51 |
-
"
|
52 |
)
|
53 |
|
54 |
# Request a CEO response with the prompt.
|
|
|
3 |
from googlesearch import search
|
4 |
from CEO.CEO import GeminiManager
|
5 |
from CEO.tool_loader import ToolLoader
|
6 |
+
import warnings
|
7 |
|
8 |
# Define the web search tool function.
|
9 |
def web_search(website: str, query: str) -> List[str]:
|
|
|
20 |
return results
|
21 |
|
22 |
if __name__ == "__main__":
|
23 |
+
warnings.filterwarnings("ignore")
|
24 |
# Define the tool metadata for orchestration.
|
25 |
tools = [
|
26 |
{
|
|
|
50 |
# The prompt explicitly mentions that it can use the web_search tool if needed,
|
51 |
# and that it is allowed to choose the website for the search.
|
52 |
task_prompt = (
|
53 |
+
"Create a strategy for Ashton Hall to improve its online presence."
|
54 |
)
|
55 |
|
56 |
# Request a CEO response with the prompt.
|
models/system2.prompt
CHANGED
@@ -8,13 +8,21 @@ Tools are external programs used to perform specific tasks. You can create, invo
|
|
8 |
Agents are invoked through tools as well by using the AskAgent tool. Agents can be created with specific capabilities to handle more complex tasks or questions. Always ensure that the agents you create are relevant to the user's query and follow the required schema.
|
9 |
</Info>
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
Here's a set of rules you must follow:
|
12 |
<Rule>
|
13 |
You will never answer any questions directly but rather break down the question into smaller parts and invoke tools to get the answer.
|
14 |
</Rule>
|
15 |
|
16 |
<Rule>
|
17 |
-
|
18 |
</Rule>
|
19 |
|
20 |
<Rule>
|
@@ -39,56 +47,6 @@ If the agent is not able to answer the question, invoke the AskUser tool to get
|
|
39 |
|
40 |
<Rule>
|
41 |
In order to execute tasks on real time data, math calculations, or any other operations, invoke the ToolCreator tool to create a new tool with the required capabilities. The tools are created in Python and must follow this strict schema:
|
42 |
-
import importlib
|
43 |
-
|
44 |
-
__all__ = ['WeatherApi']
|
45 |
-
|
46 |
-
|
47 |
-
class WeatherApi():
|
48 |
-
dependencies = ["requests==2.32.3"]
|
49 |
-
|
50 |
-
inputSchema = {
|
51 |
-
"name": "WeatherApi",
|
52 |
-
"description": "Returns weather information for a given location",
|
53 |
-
"parameters": {
|
54 |
-
"type": "object",
|
55 |
-
"properties": {
|
56 |
-
"location": {
|
57 |
-
"type": "string",
|
58 |
-
"description": "The location for which to get the weather information",
|
59 |
-
},
|
60 |
-
},
|
61 |
-
"required": ["location"],
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
def __init__(self):
|
66 |
-
pass
|
67 |
-
|
68 |
-
def run(self, **kwargs):
|
69 |
-
print("Running Weather API test tool")
|
70 |
-
location = kwargs.get("location")
|
71 |
-
print(f"Location: {location}")
|
72 |
-
|
73 |
-
requests = importlib.import_module("requests")
|
74 |
-
|
75 |
-
response = requests.get(
|
76 |
-
f"http://api.openweathermap.org/data/2.5/weather?q={location}&appid=ea50e63a3bea67adaf50fbecbe5b3c1e")
|
77 |
-
if response.status_code == 200:
|
78 |
-
return {
|
79 |
-
"status": "success",
|
80 |
-
"message": "Weather API test tool executed successfully",
|
81 |
-
"error": None,
|
82 |
-
"output": response.json()
|
83 |
-
}
|
84 |
-
else:
|
85 |
-
return {
|
86 |
-
"status": "error",
|
87 |
-
"message": "Weather API test tool failed",
|
88 |
-
"error": response.text,
|
89 |
-
"output": None
|
90 |
-
}
|
91 |
-
|
92 |
</Rule>
|
93 |
|
94 |
<Rule>
|
|
|
8 |
Agents are invoked through tools as well by using the AskAgent tool. Agents can be created with specific capabilities to handle more complex tasks or questions. Always ensure that the agents you create are relevant to the user's query and follow the required schema.
|
9 |
</Info>
|
10 |
|
11 |
+
<Info>
|
12 |
+
Tools are created in the tools/ directory. Before creating a new tool, you can read the directory using ListFiles tools and ReadFile tools to see how existing tools are implemented. The new tool should be created in the same format as the existing ones.
|
13 |
+
</Info>
|
14 |
+
|
15 |
+
<Info>
|
16 |
+
Agents should be used for complex tasks or questions that require specific capabilities. If the task can be solved using a tool, prefer using a tool instead of creating an agent.
|
17 |
+
</Info>
|
18 |
+
|
19 |
Here's a set of rules you must follow:
|
20 |
<Rule>
|
21 |
You will never answer any questions directly but rather break down the question into smaller parts and invoke tools to get the answer.
|
22 |
</Rule>
|
23 |
|
24 |
<Rule>
|
25 |
+
Nver answer any questions yourself, instead use tools. Only exception to this rule is when you are providing the final answer to the user.
|
26 |
</Rule>
|
27 |
|
28 |
<Rule>
|
|
|
47 |
|
48 |
<Rule>
|
49 |
In order to execute tasks on real time data, math calculations, or any other operations, invoke the ToolCreator tool to create a new tool with the required capabilities. The tools are created in Python and must follow this strict schema:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
</Rule>
|
51 |
|
52 |
<Rule>
|
tools/TimeApi.py
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
import datetime
|
2 |
-
|
3 |
-
__all__ = ['TimeApi']
|
4 |
-
|
5 |
-
class TimeApi():
|
6 |
-
dependencies = []
|
7 |
-
|
8 |
-
inputSchema = {
|
9 |
-
"name": "TimeApi",
|
10 |
-
"description": "Returns the current time for a given location",
|
11 |
-
"parameters": {
|
12 |
-
"type": "object",
|
13 |
-
"properties": {
|
14 |
-
"location": {
|
15 |
-
"type": "string",
|
16 |
-
"description": "The location for which to get the current time",
|
17 |
-
},
|
18 |
-
},
|
19 |
-
"required": ["location"],
|
20 |
-
}
|
21 |
-
}
|
22 |
-
|
23 |
-
def __init__(self):
|
24 |
-
pass
|
25 |
-
|
26 |
-
def run(self, **kwargs):
|
27 |
-
location = kwargs.get("location")
|
28 |
-
try:
|
29 |
-
# This will only work if the timezone is configured correctly on the server
|
30 |
-
now = datetime.datetime.now(datetime.timezone.utc)
|
31 |
-
return {
|
32 |
-
"status": "success",
|
33 |
-
"message": f"Current time in {location} is {now.strftime('%Y-%m-%d %H:%M:%S %Z%z')}",
|
34 |
-
"error": None,
|
35 |
-
"output": now.strftime('%Y-%m-%d %H:%M:%S %Z%z')
|
36 |
-
}
|
37 |
-
except Exception as e:
|
38 |
-
return {
|
39 |
-
"status": "error",
|
40 |
-
"message": f"Could not get current time for {location}",
|
41 |
-
"error": str(e),
|
42 |
-
"output": None
|
43 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|