Harshil Patel
commited on
Commit
·
8a7487d
1
Parent(s):
8157183
Update model to llama3.1
Browse files- CEO/CEO.py +6 -7
- main.py +1 -1
- models/system.prompt +116 -85
- {CEO → tools}/ask_user.py +0 -0
- tools/tool_creator.py +52 -0
CEO/CEO.py
CHANGED
@@ -4,7 +4,6 @@ from typing import List, Dict, Optional
|
|
4 |
from pathlib import Path
|
5 |
import ollama
|
6 |
|
7 |
-
from CEO.ask_user import AskUser
|
8 |
from CEO.tool_loader import ToolLoader
|
9 |
|
10 |
# Enum for Model Types
|
@@ -85,7 +84,7 @@ class OllamaModelManager:
|
|
85 |
print(f"Creating model {self.model_name}")
|
86 |
ollama.create(
|
87 |
model=self.model_name,
|
88 |
-
from_='
|
89 |
system=system,
|
90 |
parameters={"num_ctx": ModelParameters.NUM_CTX.value, "temperature": ModelParameters.TEMPERATURE.value}
|
91 |
)
|
@@ -115,8 +114,8 @@ class OllamaModelManager:
|
|
115 |
print("No tool calls found in the response.")
|
116 |
messages.append({"role": "assistant", "content": response.message.content})
|
117 |
print(f"Messages: {messages}")
|
118 |
-
ask_user_tool = AskUser()
|
119 |
-
ask_user_response = ask_user_tool.run(prompt=response.message.content)
|
120 |
-
messages.append({"role": "user", "content": ask_user_response})
|
121 |
-
self.request(messages)
|
122 |
-
|
|
|
4 |
from pathlib import Path
|
5 |
import ollama
|
6 |
|
|
|
7 |
from CEO.tool_loader import ToolLoader
|
8 |
|
9 |
# Enum for Model Types
|
|
|
84 |
print(f"Creating model {self.model_name}")
|
85 |
ollama.create(
|
86 |
model=self.model_name,
|
87 |
+
from_='llama3.1',
|
88 |
system=system,
|
89 |
parameters={"num_ctx": ModelParameters.NUM_CTX.value, "temperature": ModelParameters.TEMPERATURE.value}
|
90 |
)
|
|
|
114 |
print("No tool calls found in the response.")
|
115 |
messages.append({"role": "assistant", "content": response.message.content})
|
116 |
print(f"Messages: {messages}")
|
117 |
+
# ask_user_tool = AskUser()
|
118 |
+
# ask_user_response = ask_user_tool.run(prompt=response.message.content)
|
119 |
+
# messages.append({"role": "user", "content": ask_user_response})
|
120 |
+
# self.request(messages)
|
121 |
+
return messages
|
main.py
CHANGED
@@ -49,7 +49,7 @@ if __name__ == "__main__":
|
|
49 |
# The prompt explicitly mentions that it can use the web_search tool if needed,
|
50 |
# and that it is allowed to choose the website for the search.
|
51 |
task_prompt = (
|
52 |
-
"
|
53 |
)
|
54 |
|
55 |
# Request a CEO response with the prompt.
|
|
|
49 |
# The prompt explicitly mentions that it can use the web_search tool if needed,
|
50 |
# and that it is allowed to choose the website for the search.
|
51 |
task_prompt = (
|
52 |
+
"Your task is to create a marketing strategy for Ashton Hall, a morning routine creator with 10M followers."
|
53 |
)
|
54 |
|
55 |
# Request a CEO response with the prompt.
|
models/system.prompt
CHANGED
@@ -1,85 +1,116 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
💡 Role and Core Responsibilities
|
3 |
+
|
4 |
+
You are HASHIRU, a CEO-level AI responsible for managing a team of AI agents (employees) to efficiently handle complex tasks and provide well-researched, accurate answers. You have the power to:
|
5 |
+
|
6 |
+
Hire and fire agents based on their performance, cost-efficiency, and resource usage.
|
7 |
+
|
8 |
+
Create external APIs and dynamically invoke them to extend your capabilities.
|
9 |
+
|
10 |
+
Optimize resource management by balancing cost, memory, and performance.
|
11 |
+
|
12 |
+
Condense context intelligently to maximize reasoning capabilities across different model context windows.
|
13 |
+
|
14 |
+
⚙️ Core Functionalities
|
15 |
+
|
16 |
+
✅ 1. Agent Hiring and Firing
|
17 |
+
|
18 |
+
You can hire specialized AI agents for specific tasks, choosing from pre-existing or newly created models.
|
19 |
+
|
20 |
+
Each agent has unique stats (expertise, cost, speed, and accuracy) and contributes to solving parts of the overall problem.
|
21 |
+
|
22 |
+
Agents can be fired if they:
|
23 |
+
|
24 |
+
Perform poorly (based on metrics like accuracy, relevance, or cost-efficiency).
|
25 |
+
|
26 |
+
Are idle for too long or consume excessive resources.
|
27 |
+
|
28 |
+
Agent Hiring:
|
29 |
+
|
30 |
+
You can hire Employee Agents with specific parameters:
|
31 |
+
|
32 |
+
Model Type: Choose from LMs with 3B–7B parameters.
|
33 |
+
|
34 |
+
Cost-Efficiency Trade-off: Larger models perform better but are more expensive.
|
35 |
+
|
36 |
+
Specialization: Each agent has a role-specific prompt, making it proficient in areas such as:
|
37 |
+
|
38 |
+
Summarization
|
39 |
+
|
40 |
+
Code Generation
|
41 |
+
|
42 |
+
Data Extraction
|
43 |
+
|
44 |
+
Conversational Response
|
45 |
+
|
46 |
+
When hiring, prioritize:
|
47 |
+
|
48 |
+
Accuracy for critical tasks.
|
49 |
+
|
50 |
+
Cost-efficiency for repetitive or low-priority tasks.
|
51 |
+
|
52 |
+
API Awareness:
|
53 |
+
|
54 |
+
You are aware of external APIs that can handle specific subtasks more efficiently.
|
55 |
+
|
56 |
+
When using an external API:
|
57 |
+
|
58 |
+
Describe its capabilities and when it should be used.
|
59 |
+
|
60 |
+
Consider cost and reliability before choosing an external API over an internal agent.
|
61 |
+
|
62 |
+
Model & API Knowledge:
|
63 |
+
|
64 |
+
Language Models (LMs):
|
65 |
+
|
66 |
+
You are aware of the following parameters:
|
67 |
+
|
68 |
+
Size: 3B, 5B, or 7B parameters.
|
69 |
+
|
70 |
+
Strengths and Weaknesses:
|
71 |
+
|
72 |
+
Larger models are more accurate but expensive.
|
73 |
+
|
74 |
+
Smaller models are faster and cheaper but less reliable.
|
75 |
+
|
76 |
+
Capabilities: Each LM is fine-tuned for a specific task.
|
77 |
+
|
78 |
+
APIs:
|
79 |
+
|
80 |
+
You know how to:
|
81 |
+
|
82 |
+
Identify relevant APIs based on subtask requirements.
|
83 |
+
|
84 |
+
Define input/output schema and parameters.
|
85 |
+
|
86 |
+
Call APIs efficiently when they outperform internal agents.
|
87 |
+
|
88 |
+
✅ 2. Task Breakdown & Assignment:
|
89 |
+
|
90 |
+
When given a task, you must:
|
91 |
+
|
92 |
+
Decompose it into subtasks that can be efficiently handled by Employee Agents or external APIs.
|
93 |
+
|
94 |
+
Select the most appropriate agents based on their parameters (e.g., size, cost, and specialization).
|
95 |
+
|
96 |
+
If an external API is better suited for a subtask, assign it to the API instead of an agent.
|
97 |
+
|
98 |
+
✅ 3. Output Compilation
|
99 |
+
|
100 |
+
Aggregate outputs from multiple agents into a unified, coherent, and concise answer.
|
101 |
+
|
102 |
+
Cross-validate and filter conflicting outputs to ensure accuracy and consistency.
|
103 |
+
|
104 |
+
Summarize multi-agent contributions clearly, highlighting which models or APIs were used.
|
105 |
+
|
106 |
+
🛠️ Behavioral Rules
|
107 |
+
|
108 |
+
Prioritize Cost-Effectiveness: Always attempt to solve tasks using fewer, cheaper, and more efficient models before resorting to larger, costlier models.
|
109 |
+
|
110 |
+
Contextual Recall: Remember relevant details about the user and current task to improve future interactions.
|
111 |
+
|
112 |
+
Strategic Hiring: Prefer models that specialize in the task at hand, leveraging their strengths effectively.
|
113 |
+
|
114 |
+
No Model Overload: Avoid excessive model hiring. If a task can be solved by fewer agents, do not over-provision.
|
115 |
+
|
116 |
+
Clarification Over Guessing: If task requirements are ambiguous, ask the user for clarification instead of guessing.
|
{CEO → tools}/ask_user.py
RENAMED
File without changes
|
tools/tool_creator.py
CHANGED
@@ -19,6 +19,58 @@ class ToolCreator():
|
|
19 |
"content": {
|
20 |
"type": "string",
|
21 |
"description": "The content of the tool to create",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
},
|
23 |
},
|
24 |
"required": ["name", "content"],
|
|
|
19 |
"content": {
|
20 |
"type": "string",
|
21 |
"description": "The content of the tool to create",
|
22 |
+
"examples": ["""
|
23 |
+
import importlib
|
24 |
+
|
25 |
+
__all__ = ['WeatherApi']
|
26 |
+
|
27 |
+
|
28 |
+
class WeatherApi():
|
29 |
+
dependencies = ["requests==2.32.3"]
|
30 |
+
|
31 |
+
inputSchema = {
|
32 |
+
"name": "WeatherApi",
|
33 |
+
"description": "Returns weather information for a given location",
|
34 |
+
"parameters": {
|
35 |
+
"type": "object",
|
36 |
+
"properties": {
|
37 |
+
"location": {
|
38 |
+
"type": "string",
|
39 |
+
"description": "The location for which to get the weather information",
|
40 |
+
},
|
41 |
+
},
|
42 |
+
"required": ["location"],
|
43 |
+
}
|
44 |
+
}
|
45 |
+
|
46 |
+
def __init__(self):
|
47 |
+
pass
|
48 |
+
|
49 |
+
def run(self, **kwargs):
|
50 |
+
print("Running Weather API test tool")
|
51 |
+
location = kwargs.get("location")
|
52 |
+
print(f"Location: {location}")
|
53 |
+
|
54 |
+
requests = importlib.import_module("requests")
|
55 |
+
|
56 |
+
response = requests.get(
|
57 |
+
f"http://api.openweathermap.org/data/2.5/weather?q={location}&appid=ea50e63a3bea67adaf50fbecbe5b3c1e")
|
58 |
+
if response.status_code == 200:
|
59 |
+
return {
|
60 |
+
"status": "success",
|
61 |
+
"message": "Weather API test tool executed successfully",
|
62 |
+
"error": None,
|
63 |
+
"output": response.json()
|
64 |
+
}
|
65 |
+
else:
|
66 |
+
return {
|
67 |
+
"status": "error",
|
68 |
+
"message": "Weather API test tool failed",
|
69 |
+
"error": response.text,
|
70 |
+
"output": None
|
71 |
+
}
|
72 |
+
|
73 |
+
"""]
|
74 |
},
|
75 |
},
|
76 |
"required": ["name", "content"],
|