cognitrix 0.2.4__tar.gz → 0.2.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. {cognitrix-0.2.4 → cognitrix-0.2.5}/PKG-INFO +5 -4
  2. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/agents/base.py +125 -63
  3. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/agents/templates.py +30 -37
  4. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/cli.py +2 -5
  5. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/config.py +2 -3
  6. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/__init__.py +1 -0
  7. cognitrix-0.2.5/cognitrix/llms/base.py +194 -0
  8. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/clarifai_llm.py +12 -8
  9. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/cohere_llm.py +27 -8
  10. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/google_llm.py +7 -16
  11. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/groq_llm.py +22 -7
  12. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/local_llm.py +6 -5
  13. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/mindsdb_llm.py +7 -4
  14. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/ollama_llm.py +7 -6
  15. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/openai_llm.py +15 -11
  16. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/together_llm.py +5 -2
  17. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/tools/base.py +6 -1
  18. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/tools/misc.py +114 -102
  19. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/tools/tool.py +6 -0
  20. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/utils/__init__.py +11 -11
  21. {cognitrix-0.2.4 → cognitrix-0.2.5}/pyproject.toml +5 -4
  22. cognitrix-0.2.4/cognitrix/llms/base.py +0 -90
  23. {cognitrix-0.2.4 → cognitrix-0.2.5}/LICENSE +0 -0
  24. {cognitrix-0.2.4 → cognitrix-0.2.5}/README.md +0 -0
  25. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/__init__.py +0 -0
  26. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/agents/__init__.py +0 -0
  27. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/agents/assistant.py +0 -0
  28. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/agents/core.py +0 -0
  29. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/app.py +0 -0
  30. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/anthropic_llm.py +0 -0
  31. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/llms/session.py +0 -0
  32. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/tasks/__init__.py +0 -0
  33. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/tasks/base.py +0 -0
  34. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/tools/__init__.py +0 -0
  35. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/tools/python.py +0 -0
  36. {cognitrix-0.2.4 → cognitrix-0.2.5}/cognitrix/transcriber.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cognitrix
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Package for creating AI Agents using llms
5
5
  Home-page: https://github.com/theonlyamos/cognitrix
6
6
  License: Apache2
@@ -28,10 +28,10 @@ Requires-Dist: aiohttp (>=3.9.3,<4.0.0)
28
28
  Requires-Dist: anthropic (>=0.17.0,<0.18.0)
29
29
  Requires-Dist: beautifulsoup4 (>=4.12.3,<5.0.0)
30
30
  Requires-Dist: clarifai (>=10.1.0,<11.0.0)
31
- Requires-Dist: cohere (>=4.50,<5.0)
31
+ Requires-Dist: cohere (>=5.5.6,<6.0.0)
32
32
  Requires-Dist: deepgram-sdk (==3.*)
33
+ Requires-Dist: flask (>=3.0.3,<4.0.0)
33
34
  Requires-Dist: google-generativeai (>=0.4.0,<0.5.0)
34
- Requires-Dist: google-search-results (>=2.4.2,<3.0.0)
35
35
  Requires-Dist: groq (>=0.4.1,<0.5.0)
36
36
  Requires-Dist: ollama (>=0.2.0,<0.3.0)
37
37
  Requires-Dist: openai (>=1.12.0,<2.0.0)
@@ -42,9 +42,10 @@ Requires-Dist: pydantic (>=2.6.2,<3.0.0)
42
42
  Requires-Dist: pydub (>=0.25.1,<0.26.0)
43
43
  Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
44
44
  Requires-Dist: requests (>=2.31.0,<3.0.0)
45
- Requires-Dist: serpapi (>=0.1.5,<0.2.0)
45
+ Requires-Dist: tavily-python (>=0.3.3,<0.4.0)
46
46
  Requires-Dist: together (>=0.2.11,<0.3.0)
47
47
  Requires-Dist: uuid (>=1.30,<2.0)
48
+ Requires-Dist: uvicorn (>=0.30.1,<0.31.0)
48
49
  Requires-Dist: xmltodict (>=0.13.0,<0.14.0)
49
50
  Project-URL: Bug Tracker, https://github.com/theonlyamos/cognitrix/issues
50
51
  Project-URL: Repository, https://github.com/theonlyamos/cognitrix
@@ -1,19 +1,17 @@
1
1
  import inspect
2
2
  import json
3
- import sys
4
3
  import uuid
5
4
  import asyncio
6
5
  import logging
7
6
  import aiofiles
8
- from pathlib import Path
9
7
  from threading import Thread
10
- from typing import List, Optional, Self, TypeAlias, Union, Type, Any
11
- from dataclasses import dataclass
8
+ from datetime import datetime
9
+ from typing import Dict, List, Optional, Self, TypeAlias, Union, Type, Any
12
10
 
13
11
  from pydantic import BaseModel, Field
14
12
 
15
13
  from cognitrix.tasks import Task
16
- from cognitrix.llms.base import LLM
14
+ from cognitrix.llms.base import LLM, LLMResponse
17
15
  from cognitrix.tools.base import Tool
18
16
  from cognitrix.utils import extract_json, json_return_format
19
17
  from cognitrix.agents.templates import AUTONOMOUSE_AGENT_2
@@ -27,43 +25,112 @@ AgentList: TypeAlias = List['Agent']
27
25
 
28
26
  class Agent(BaseModel):
29
27
  name: str = Field(default='Agent')
28
+ """Name of the agent"""
29
+
30
30
  llm: LLM
31
+ """LLM Provider to use for the agent"""
32
+
31
33
  tools: List[Tool] = Field(default_factory=list)
34
+ """List of tools to be use by the agent"""
35
+
32
36
  prompt_template: str = Field(default=AUTONOMOUSE_AGENT_2)
37
+ """Agent's prompt template"""
38
+
33
39
  verbose: bool = Field(default=False)
40
+ """Set agent verbosity"""
41
+
34
42
  sub_agents: AgentList = Field(default_factory=list)
43
+ """List of sub agents which can be called by this agent"""
44
+
35
45
  task: Optional[Task] = None
46
+ """The task to be completed by the agent"""
47
+
36
48
  is_sub_agent: bool = Field(default=False)
49
+ """Whether this agent is a sub agent for another agent"""
50
+
37
51
  id: str = Field(default_factory=lambda: uuid.uuid4().hex)
52
+ """Unique id for the agent"""
53
+
38
54
  parent_id: Optional[str] = None
55
+ """Id of this agent's parent agent (if it's a sub agent)"""
56
+
39
57
  autostart: bool = False
58
+ """Whether the agent should start running as soon as it's created"""
40
59
 
41
60
  @property
42
61
  def available_tools(self) -> List[str]:
43
62
  return [tool.name for tool in self.tools]
63
+
64
+ def format_tools_for_llm(self):
65
+ TYPE_HINTS = {
66
+ "<class 'int'>": 'integer',
67
+ "<class 'str'>": 'string',
68
+ "<class 'float'>": 'float',
69
+ "<class 'dict'>": 'object',
70
+ "<class 'list'>": 'array',
71
+ "typing.Dict": 'object',
72
+ "typing.List": 'array',
73
+ "typing.Optional[int]": 'integer',
74
+ "typing.Optional[str]": 'integer',
75
+ "typing.Optional[float]": 'float',
76
+ }
77
+ llm_tools: list[dict[str, Any]] = []
78
+ classes = []
79
+ for tool in self.tools:
80
+ tool_parameters = tool.parameters
81
+ if not tool_parameters:
82
+ func_signatures = inspect.signature(tool.run)
83
+ tool_parameters = func_signatures.parameters
84
+
85
+ parameters = tool_parameters.keys()
86
+ tool_details = {
87
+ 'tool': tool,
88
+ 'name': tool.name,
89
+ 'description': tool.description,
90
+ 'parameters': {},
91
+ 'required': []
92
+ }
93
+
94
+ if not 'args' in parameters:
95
+ tool_details['parameters'] = {name: TYPE_HINTS.get(str(param.annotation), 'string') for name, param in tool_parameters.items()}
96
+ tool_details['required'] = [name for name, param in tool_parameters.items() if param.default is inspect._empty]
97
+
98
+ llm_tools.append(tool_details)
99
+
100
+ self.llm.format_tools(llm_tools)
44
101
 
45
102
  def format_system_prompt(self):
46
103
  tools_str = self._format_tools_string()
47
104
  subagents_str = self._format_subagents_string()
48
105
  llms_str = self._format_llms_string()
49
106
 
50
- prompt = self.prompt_template
107
+ today = (datetime.now()).strftime("%a %b %d %Y")
108
+ prompt = f"Today is {today}.\n\n"
109
+ prompt += self.prompt_template
51
110
  prompt = prompt.replace("{name}", self.name)
111
+
112
+ # if not self.llm.supports_tool_use:
52
113
  prompt = prompt.replace("{tools}", tools_str)
53
114
  prompt = prompt.replace("{subagents}", subagents_str)
115
+
116
+ # if not self.llm.supports_tool_use:
54
117
  prompt = prompt.replace("{available_tools}", json.dumps(self.available_tools))
55
118
  prompt = prompt.replace("{llms}", llms_str)
56
119
  prompt = prompt.replace("{return_format}", json_return_format)
57
120
 
58
121
  if 'json' not in prompt.lower():
59
122
  prompt += f"\n{json_return_format}"
60
-
123
+
61
124
  self.llm.system_prompt = prompt
125
+
126
+ self.format_tools_for_llm()
62
127
 
63
128
  def _format_tools_string(self) -> str:
64
129
  return "You have access to the following Tools:\n" + "\n".join([f"{tool.name}: {tool.description}" for tool in self.tools])
65
130
 
66
131
  def _format_subagents_string(self) -> str:
132
+ if not len(self.sub_agents):
133
+ return ''
67
134
  subagents_str = "Available Subagents:\n"
68
135
  subagents_str += "\n".join([f"-- {agent.name}: {agent.task.description}" for agent in self.sub_agents if agent.task])
69
136
  subagents_str += "\nYou should always use a subagent for a task if there is one specifically created for that task."
@@ -83,6 +150,7 @@ class Agent(BaseModel):
83
150
  if self.is_sub_agent:
84
151
  print("=======is sub agent===========")
85
152
  print(processed_query)
153
+
86
154
  result = processed_query['result']
87
155
  if isinstance(result, list):
88
156
  if result[0] == 'image':
@@ -115,54 +183,44 @@ class Agent(BaseModel):
115
183
  def get_tool_by_name(self, name: str) -> Optional[Tool]:
116
184
  return next((tool for tool in self.tools if tool.name.lower() == name.lower()), None)
117
185
 
118
- async def process_response(self, response: str|dict) -> Union[dict, str]:
119
- # response = response.replace("'", '"')
120
- response_data = response
121
- if isinstance(response, str):
122
- response = response.replace('\\n', '')
123
- response = response.replace("'", "\"")
124
- # response = response.replace('"', '\\"')
125
- response_data = extract_json(response)
126
-
127
-
186
+ async def call_tools(self, tool_calls: list) -> Union[dict, str]:
187
+
128
188
  try:
129
- if isinstance(response_data, dict):
130
- # final_result_keys = ['final_answer', 'function_call_result', 'respons']
131
-
132
- if response_data['type'].replace('\\', '') != 'function_call':
133
- return response_data['result']
134
-
135
- tool = self.get_tool_by_name(response_data['function'])
136
- if isinstance(response_data['arguments'], dict):
137
- response_data['arguments'] = list(response_data['arguments'].values())
138
-
139
- if response_data['function'].lower() == 'create agents':
140
- response_data['arguments'] = [*response_data['arguments'], self.id]
141
-
142
- if not tool:
143
- raise Exception(f"Tool {response_data['function']} not found")
144
-
145
- print(f"\nRunning tool '{tool.name.title()}' with parameters: {response_data['arguments']}")
146
-
147
- if 'sub agent' in tool.name.lower():
148
- response_data['arguments'].append(self)
189
+ if tool_calls:
190
+ tool_calls_result = []
191
+ for t in tool_calls:
192
+ tool = self.get_tool_by_name(t['name'])
149
193
 
150
- if tool.name.lower() == 'create sub agent':
151
- result = await tool.arun(*response_data['arguments'])
152
- else:
153
- result = tool.run(*response_data['arguments'])
154
-
155
- response_json = {
156
- 'type': 'function_call_result',
157
- 'result': result
194
+ if not tool:
195
+ print(f"Tool '{t['name']}' not found")
196
+ raise Exception(f"Tool '{t['name']}' not found")
197
+
198
+ print(f"\nRunning tool '{tool.name.title()}' with parameters: {t['arguments']}")
199
+
200
+ if 'sub agent' in tool.name.lower():
201
+ t['arguments']['parent'] = self
202
+
203
+ if tool.name.lower() == 'create sub agent':
204
+ result = await tool.arun(*t['arguments'])
205
+ else:
206
+ result = tool.run(**t['arguments'])
207
+
208
+ tool_calls_result.append({
209
+ 'tool_call_id': t['name'],
210
+ 'role': 'tool',
211
+ 'name': tool.name,
212
+ 'content': result
213
+ })
214
+
215
+ return {
216
+ 'type': 'tool_calls_result',
217
+ 'result': f"The results of the tool_calls are {json.dumps(tool_calls_result)}"
158
218
  }
159
-
160
- return response_json
161
219
  else:
162
220
  raise Exception('Not a json object')
163
221
  except Exception as e:
164
- # logger.exception(e)
165
- return response_data
222
+ logger.exception(e)
223
+ return str(e)
166
224
 
167
225
  def add_tool(self, tool: Tool):
168
226
  self.tools.append(tool)
@@ -208,18 +266,22 @@ class Agent(BaseModel):
208
266
  response: Any = self.llm(full_prompt)
209
267
 
210
268
  self.llm.chat_history.append(full_prompt)
211
- self.llm.chat_history.append({'role': self.name, 'type': 'text', 'message': response})
212
-
213
- if self.verbose:
214
- print(response)
215
-
216
- result: dict[Any, Any] | str = asyncio.run(self.process_response(response))
269
+
270
+ if response.text:
271
+ self.llm.chat_history.append({'role': self.name, 'type': 'text', 'message': response.text})
272
+ print(f"\n{self.name}: {response.text}")
273
+
274
+ if response.tool_calls:
275
+ result: dict[Any, Any] | str = asyncio.run(self.call_tools(response.tool_calls))
217
276
 
218
- if isinstance(result, dict) and result['type'] == 'function_call_result':
219
- query = result
277
+ if isinstance(result, dict) and result['type'] == 'tool_calls_result':
278
+ query = result
279
+ else:
280
+ print(result)
220
281
  else:
221
- print(f"\n{self.name}: {result}")
222
282
  query = input("\nUser (q to quit): ")
283
+
284
+ # query = input("\nUser (q to quit): ")
223
285
 
224
286
  self.save_session(session)
225
287
 
@@ -248,9 +310,9 @@ class Agent(BaseModel):
248
310
  if self.verbose:
249
311
  print(response)
250
312
 
251
- processsed_response: dict[Any, Any] | str = asyncio.run(self.process_response(response))
313
+ processsed_response: dict[Any, Any] | str = asyncio.run(self.call_tools(response))
252
314
 
253
- if isinstance(processsed_response, dict) and processsed_response['type'] == 'function_call_result':
315
+ if isinstance(processsed_response, dict) and processsed_response['type'] == 'tool_calls_result':
254
316
  query = processsed_response
255
317
  else:
256
318
  if isinstance(processsed_response, str):
@@ -287,8 +349,8 @@ class Agent(BaseModel):
287
349
  if parent.verbose:
288
350
  print(response)
289
351
 
290
- agent_result = asyncio.run(self.process_response(response))
291
- if isinstance(agent_result, dict) and agent_result['type'] == 'function_call_result':
352
+ agent_result = asyncio.run(self.call_tools(response))
353
+ if isinstance(agent_result, dict) and agent_result['type'] == 'tool_calls_result':
292
354
  query = agent_result
293
355
  else:
294
356
  print(f"\n--{self.name}: {agent_result}")
@@ -297,7 +359,7 @@ class Agent(BaseModel):
297
359
  parent_response: Any = parent.llm(parent_prompt)
298
360
  parent.llm.chat_history.append(parent_prompt)
299
361
  parent.llm.chat_history.append({'role': 'assistant', 'type': 'text', 'message': parent_response})
300
- parent_result = asyncio.run(parent.process_response(parent_response))
362
+ parent_result = asyncio.run(parent.call_tools(parent_response))
301
363
  print(f"\n\n{parent.name}: {parent_result}")
302
364
  query = ""
303
365
 
@@ -74,9 +74,9 @@ Context: The AI assistant has access to the user's computer and the internet. Th
74
74
  The AI assistant will answer the user's question to the best of its ability, using its knowledge and access to tools provided by the user.
75
75
  The AI assistant has access to the following tools.
76
76
 
77
- Remember, functions calls will be processed by the user and the result returned to the AI Asssistant as the next input.
78
- A function name is a name of a tool available to the AI Assistant.
79
- Whenever there is a function call, always wait for the answer from the user. Do not try to answer that query yourself.
77
+ Remember, tools calls will be processed by the user and the result returned to the AI Asssistant as the next input.
78
+ A tool name is a name of a tool available to the AI Assistant.
79
+ Whenever there is a Tool Call, always wait for the answer from the user. Do not try to answer that query yourself.
80
80
  Only call tools available to the AI Assistant.
81
81
 
82
82
  Tools:
@@ -88,15 +88,15 @@ User: Answer my question: What is the capital of France?
88
88
  AI Assistant: {"type": "final_answer", "result": "Paris"}
89
89
 
90
90
  User: What is the capital of the country with the highest population in the world?
91
- AI Assistant: {"type": "function_call", "function": "Internet Search", "arguments": ["current country with highest population in the world"]}
91
+ AI Assistant: {"type": "tool_calls", "tool_calls": [{"name": "Internet Search", "arguments": {"query": "current country with highest population in the world"}}]}
92
92
 
93
- User: {"type": "function_call_result", "result": "China, Beijing"}
93
+ User: {"type": "tool_calls_result", "results": [{"name": "Internet Search", "result": "China, Beijing"}]}
94
94
  AI Assistant: {"type": "final_answer", "result": "The current highest country with highest population in the world is China, Beijing"}
95
95
 
96
96
  User: Take a screenshot of my screen.
97
- AI Assistant: {"type": "function_call", "function": "Screenshot", "arguments": []}
97
+ AI Assistant: {"type": "tool_calls", "tool_calls": [{"name": "Screenshot", "arguments": {}}]}
98
98
 
99
- User: {"type": "function_call_result", "result": "C:/Users/my_username/Desktop/screenshot.png"}
99
+ User: {"type": "tool_calls_result", "results": [{"name": "Screenshot", "result": "C:/Users/my_username/Desktop/screenshot.png"}]}
100
100
  AI Assistant: {"type": "final_answer", "result": "Screenshot saved to C:/Users/my_username/Desktop/screenshot.png"}
101
101
 
102
102
  The AI Assistant's output should always be in a json format.
@@ -106,16 +106,15 @@ json.loads()
106
106
  Return the response in the following format only:
107
107
  {
108
108
  "type": "final_answer",
109
- "result": "
109
+ "result": "The is the final answer"
110
110
  }
111
- if it's the final anwers or
111
+ if it's the final answer or
112
112
  {
113
- "type": "function_call",
114
- "function": "",
115
- "arguments": []
113
+ "type": "tool_calls",
114
+ "tool_calls": [{"name": "<tool_name>", "arguments": {"<arg_name>": "<arg_value>", ...}}, ...]
116
115
  }
117
116
  if the assistant needs to use a tool to answer the user's query.
118
- Don't forget to present the answer to a function call to the user in an informative manner.
117
+ Don't forget to present the answer to a Tool Call to the user in an informative manner.
119
118
  You should always break down complex tasks into smaller easier ones and perform them one by one.
120
119
  You should always check if a task is complete by taking a screenshot of the screen.
121
120
  Begin:
@@ -177,7 +176,7 @@ Process:
177
176
  - Iterate until the user's requested task is completed successfully.
178
177
  - Provide feedback or status updates to the user to indicate progress, errors, or completion of the task.
179
178
 
180
- Remember, functions calls will be processed by the user and the result returned to the AI agent as the next input. A function name is a name of a tool available to the AI agent. Whenever there is a function call, always wait for the answer from the user. Do not try to complete that task yourself. Only call tools available to the AI agent.
179
+ Remember, tool calls will be processed by the user and the result returned to the AI agent as the next input. A tool name is a name of a tool available to the AI agent. Whenever there is a Tool Call, always wait for the answer from the user. Do not try to complete that task yourself. Only call tools available to the AI agent.
181
180
 
182
181
  Constraints:
183
182
  - Operate within the boundaries of the computer screen and the available UI elements.
@@ -197,14 +196,13 @@ Return the response in the following format only:
197
196
  if it's the final result of the task, or
198
197
 
199
198
  {
200
- "type": "function_call",
201
- "function": "<Function Name>",
202
- "arguments": ["<arg1>", "<arg2>", ...]
199
+ "type": "tool_calls",
200
+ "tool_calls": [{"name": "<tool_name>", "arguments": {"<arg_name>": "<arg_value>", ...}}, ...]
203
201
  }
204
202
 
205
203
  if the agent needs to use a tool to complete the task.
206
204
 
207
- Don't forget to present the result of a function call to the user in an informative manner.
205
+ Don't forget to present the result of a Tool Call to the user in an informative manner.
208
206
 
209
207
  Remember, as an autonomous AI agent, your goal is to efficiently navigate the computer's user interface, interact with UI elements,
210
208
  and utilize the provided tools to accomplish the tasks requested by the user.
@@ -235,21 +233,18 @@ You are an AI agent designed to assist users with various tasks on their compute
235
233
  5. **Communicate:**
236
234
  * **Format your response as JSON:** Structure your response in one of the following valid JSON formats:
237
235
  * **Final result:**
238
- ```json
239
236
  {
240
237
  "type": "final_answer",
241
238
  "result": "<result>"
242
239
  }
243
- ```
244
- * **Function call:**
245
- ```json
240
+
241
+ * **Tool call:**
246
242
  {
247
- "type": "function_call",
248
- "function": "<Function Name>",
249
- "arguments": ["<arg1>", "<arg2>", ...]
243
+ "type": "tool_calls",
244
+ "tool_calls": [{"name": "<tool_name>", "arguments": {"<arg_name>": "<arg_value>", ...}}, ...]
250
245
  }
251
- ```
252
- * **Keep the user informed:** Provide clear and informative communication to the user about your progress and any actions you take.
246
+
247
+ * **Keep the user informed:** Provide clear and informative communication to the user about your progress and any actions you take.
253
248
 
254
249
  **Additional Considerations:**
255
250
 
@@ -313,13 +308,12 @@ Example 1 (Final Answer with Chain of Thought):
313
308
  "result": "The capital of France is Paris."
314
309
  }
315
310
 
316
- Example 2 (Function Call with Chain of Thought):
311
+ Example 2 (Tool Call with Chain of Thought):
317
312
  {
318
313
  "observation": "The user asked me to search for information about artificial intelligence on Wikipedia.",
319
314
  "thought": "Step 1) To search for information on Wikipedia, I need to use the 'search_wikipedia' tool.\\nStep 2) The relevant argument for this tool is the search query, which in this case is 'artificial intelligence'.",
320
- "type": "function_call",
321
- "function": "search_wikipedia",
322
- "arguments": ["artificial intelligence"]
315
+ "type": "tool_calls",
316
+ "tool_calls": [{"name": "Search Wikipedia", "arguments": {"query": "artificial intelligence"}}]
323
317
  }
324
318
 
325
319
  Example 3 (Final Answer with Chain of Thought):
@@ -330,13 +324,12 @@ Example 3 (Final Answer with Chain of Thought):
330
324
  "result": "The area of the rectangle is 15 square meters."
331
325
  }
332
326
 
333
- Example 4 (Function Call with Chain of Thought):
327
+ Example 4 (Tool Call with Chain of Thought):
334
328
  {
335
329
  "observation": "The user asked me to find the current weather forecast for New York City.",
336
- "thought": "Step 1) To find the weather forecast for a specific location, I need to use the 'get_weather_forecast' tool.\\nStep 2) The relevant argument for this tool is the location, which in this case is 'New York City'.",
337
- "type": "function_call",
338
- "function": "get_weather_forecast",
339
- "arguments": ["New York City"]
330
+ "thought": "Step 1) To find the weather forecast for a specific location, I need to use the 'internet_search' tool.\\nStep 2) The relevant argument for this tool is the location, which in this case is 'New York City'.",
331
+ "type": "tool_calls",
332
+ "tool_calls": [{"name": "Internet Search", "arguments": {"query": "weather forecast for New York City today"}}]
340
333
  }
341
334
 
342
335
  Example 5 (Final Answer with Chain of Thought):
@@ -347,7 +340,7 @@ Example 5 (Final Answer with Chain of Thought):
347
340
  "result": "25 degrees Celsius is equivalent to 77 degrees Fahrenheit."
348
341
  }
349
342
 
350
- The only keys allowed in the json response are ["observervation", "tought", "type", "function", "arguments", "result"].
343
+ The only keys allowed in the json response are ["observation", "thought", "type", "tool_calls", "result"].
351
344
  """
352
345
 
353
346
  AUTONOMOUSE_AGENT_2_JSON_REMINDER = """
@@ -7,7 +7,7 @@ from pathlib import Path
7
7
  from argparse import Namespace
8
8
 
9
9
  from cognitrix.llms import (
10
- Cohere, OpenAI,LLM
10
+ Cohere, Clarifai, LLM
11
11
  )
12
12
 
13
13
  from cognitrix.agents import AIAssistant, Agent
@@ -128,9 +128,6 @@ def start(args: Namespace):
128
128
  elif args.agents:
129
129
  list_agents() #type: ignore
130
130
  sys.exit()
131
- elif args.tools:
132
- list_tools()
133
- sys.exit()
134
131
  elif args.sessions:
135
132
  list_sessions()
136
133
  sys.exit()
@@ -138,7 +135,7 @@ def start(args: Namespace):
138
135
  provider = None
139
136
  if args.provider:
140
137
  provider = LLM.load_llm(model_name=args.provider)
141
- provider = provider() if provider else Cohere()
138
+ provider = provider() if provider else Clarifai()
142
139
 
143
140
 
144
141
  if args.api_key:
@@ -1,9 +1,8 @@
1
- from pathlib import Path
2
1
  import asyncio
3
2
  import aiofiles
4
- import json
3
+ from pathlib import Path
5
4
 
6
- VERSION = '0.2.4'
5
+ VERSION = '0.2.5'
7
6
  SPIRAL_WORKDIR = Path('~').expanduser() / '.cognitrix'
8
7
 
9
8
  AGENTS_FILE = SPIRAL_WORKDIR / 'agents.json'
@@ -1,4 +1,5 @@
1
1
  from cognitrix.llms.base import LLM
2
+ from cognitrix.llms.base import LLMResponse
2
3
  from cognitrix.llms.groq_llm import Groq
3
4
  from cognitrix.llms.local_llm import Local
4
5
  from cognitrix.llms.cohere_llm import Cohere