Skip to content

Commit 0901687

Browse files
committed
tabulated agents, tools and providers lists
1 parent 18775ec commit 0901687

File tree

2 files changed

+135
-51
lines changed

2 files changed

+135
-51
lines changed

README.md

Lines changed: 70 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,110 @@
1-
### Cognitrix
2-
Cognitrix is an open-source autonous AI agents orchestrator built in Python. It allows you to create and manage AI agents easily.
1+
# Cognitrix
32

4-
### Features
5-
- **`Agent Creation and Management`:** Create, list, and load AI agents with customizable names, tasks, and configurations.
6-
- **`LLM Integration`:** Seamlessly integrate with multiple LLM providers, including Anthropic (Claude), Cohere, Groq, Google, OpenAI, and Together.
7-
- **`Modular Architecture`:** Easily extend the framework by adding new tools, agents, and LLM integrations.
8-
- **`Conversational Interface`:** Interact with AI agents through a command-line interface, providing queries and receiving responses.
9-
- **`Tool Integration`:** Agents can utilize a variety of tools, such as calculators, web searches, file system browsers, and more.
10-
- **`Autonomous Agent Mode`:** Enable agents to operate autonomously, visually perceiving the screen, interacting with UI elements, and performing tasks.
11-
- **`Multimodal Support`:** Agents can handle both text and image inputs/outputs, enabling multimodal interactions.
3+
Cognitrix is an open-source autonomous AI agents orchestrator built in Python. It allows you to create and manage AI agents with ease and integrates seamlessly with large language models (LLMs) from various providers.
124

13-
### Architecture
14-
Cognitrix's architecture is designed to be modular and extensible, with core components including:
5+
## Features
156

16-
1. **`Agents`:** The base Agent class and specialized classes like AIAssistant for creating and managing AI agents.
17-
2. **`LLMs`:** A collection of classes for integrating with various LLM providers, such as Cohere, OpenAI, Claude, and more.
18-
3. **`Tools`:** A set of tools that agents can utilize, including calculators, web searches, file system browsers, and more.
19-
4. **`Templates`:** Customizable prompt templates for guiding the behavior and output formats of LLMs.
7+
- **Agent Creation and Management:** Create, list, and load AI agents with customizable names, tasks, and configurations.
8+
- **LLM Integration:** Integrates with multiple LLM providers, including Anthropic (Claude), Cohere, Groq, Google, OpenAI, and Together.
9+
- **Modular Architecture:** Easily extensible, allowing the addition of new tools, agents, and LLM integrations.
10+
- **Conversational Interface:** Interact with AI agents through a command-line interface, providing queries and receiving responses.
11+
- **Tool Integration:** Agents can utilize a variety of tools, including calculators, web searches, file system browsers, and more.
12+
- **Autonomous Agent Mode:** Agents can operate autonomously, visually perceiving the screen, interacting with UI elements, and performing tasks.
13+
- **Multimodal Support:** Handles both text and image inputs/outputs, enabling multimodal interactions.
2014

21-
The architecture is highly modular and extensible. New tools and capabilities can be easily added.
15+
## Architecture
2216

23-
### Getting Started
17+
Cognitrix's architecture is designed to be highly modular and extensible:
18+
19+
- **Agents:** The base `Agent` class and specialized classes like `AIAssistant` for creating and managing AI agents.
20+
- **LLMs:** A collection of classes for integrating with various LLM providers (Cohere, OpenAI, Claude, etc.).
21+
- **Tools:** A set of tools that agents can utilize. Each tool has a `category` attribute for grouping and management.
22+
- **Templates:** Customizable prompt templates guide the behavior and output formats of LLMs.
23+
24+
More tools can be added by creating new classes that inherit from the `Tool` base class and specifying a unique `category`.
25+
26+
## Installation
2427

25-
### Installation
2628
```bash
2729
pip install cognitrix
2830
```
29-
or
31+
32+
Alternatively, you can install directly from GitHub:
33+
3034
```bash
3135
pip install https://github.com/theonlyamos/cognitrix/archive/main.zip
3236
```
3337

34-
### Usage
35-
Run with default settings
38+
## Usage
39+
40+
To run Cognitrix with default settings:
41+
3642
```bash
3743
cognitrix
3844
```
3945

40-
List supported providers
46+
To list supported LLM providers:
47+
4148
```bash
4249
cognitrix --providers
4350
```
4451

45-
Run with specific provider
52+
To list created agents:
53+
4654
```bash
47-
cognitrix --provider <provider_name>
55+
cognitrix agents
4856
```
4957

50-
Create a new agent
58+
To list available tools:
59+
5160
```bash
52-
cognitrix agents --new
61+
cognitrix --tools
5362
```
5463

55-
List created agents
64+
To run Cognitrix with a specific provider:
65+
5666
```bash
57-
cognitrix agents
67+
cognitrix --provider <provider_name>
5868
```
5969

60-
Run with specific agent
70+
To run Cognitrix with a specific agent:
71+
6172
```bash
6273
cognitrix --agent <agent_name>
6374
```
6475

65-
Print help message
76+
To run Cognitrix with a category of tools:
77+
78+
```bash
79+
cognitrix --load-tools "web"
80+
```
81+
82+
To run Cognitrix with categories of tools:
83+
84+
```bash
85+
cognitrix --load-tools "web,general"
86+
```
87+
88+
To create a new agent:
89+
90+
```bash
91+
cognitrix agents --new
92+
```
93+
94+
For more options and usage details, use the help command:
95+
6696
```bash
6797
cognitrix --help
6898
```
6999

70-
### Contributing
71-
Cognitrix is open source and contributions are welcome. See [CONTRIBUTING.md](CONTRIBUTING.md) for more details.
100+
## Contributing
101+
102+
Cognitrix is open source and contributions are welcome! Please refer to [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute.
103+
104+
## License
105+
106+
This project is licensed under the MIT license. See [LICENSE.md](LICENSE.md) for more information.
72107

73-
### License
74-
This project is licensed under the MIT license. See [LICENSE.md](LICENSE.md) for more details.
108+
## Acknowledgments
75109

76-
### Acknowledgments
77-
Cognitrix was created by [Amos Amissah](https://github.com/theonlyamos) and is heavily inspired by projects like AutoGPT and GPT Engineer. Special thanks to the open-source community for their contributions and the AI companies providing LLM APIs.
110+
Cognitrix was created by [Amos Amissah](https://github.com/theonlyamos) and is inspired by projects like AutoGPT and GPT Engineer. Special thanks to the open-source community and AI companies providing LLM APIs.

cognitrix/cli.py

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,58 @@ def add_agent():
2929
sys.exit()
3030

3131
def list_agents():
32-
agents_str = "\nAvailable Agents:"
33-
for index, agent in enumerate(asyncio.run(Agent.list_agents())):
34-
agents_str += (f"\n[{index}] {agent.name}") #type: ignore
35-
print(agents_str)
32+
agents = asyncio.run(Agent.list_agents())
33+
agent_names = [agent.name for agent in agents]
34+
max_col = len(max(agent_names, key=len))
35+
max_width = 10
36+
max_col = max_col if max_col >= max_width else max_width
37+
38+
print(max_col)
39+
print("\nAvailable Agents:")
40+
print(f" {'_'*((int(len(agents)/10)+5)+max_width+1)}")
41+
print(f"| #{' '*(int(len(agents)/10))} | {'Agent Name'+' '*(max_col-max_width)} |")
42+
print(f"|{'-'*(int(len(agents)/10)+3)}|-{'-'*(max_col)}-|")
43+
for index, a in enumerate(agents):
44+
padding = (len(str(index)))-int(len(agents)/10)
45+
padding = padding if padding else padding + 2
46+
print(f"| {str(index) + ' '*padding}| {a.name + ' '*(max_col-len(a.name))} |")
3647

3748
def list_providers():
38-
print("\nAvailable providers:")
39-
for index, l in enumerate(LLM.list_llms()):
40-
print(f"[{index}] {l}")
49+
providers = LLM.list_llms()
50+
provider_names = [p for p in providers]
51+
max_col = len(max(provider_names, key=len))
52+
max_width = 9
53+
max_col = max_col if max_col >= max_width else max_width
54+
55+
print("\nAvailable Providers:")
56+
print(f" {'_'*((int(len(providers)/10)+5)+max_width+1)}")
57+
print(f"| #{' '*(int(len(providers)/10))} | {'Provider'+' '*(max_col-7)}|")
58+
print(f"|{'-'*(int(len(providers)/10)+3)}|-{'-'*(max_col)}-|")
59+
for index, p in enumerate(providers):
60+
padding = (len(str(index)))-int(len(providers)/10)
61+
padding = padding if padding else padding + 2
62+
print(f"| {str(index) + ' '*padding}| {p + ' '*(max_col-len(p))} |")
63+
4164

42-
def list_tools():
65+
def list_tools(category='all'):
66+
tools = []
67+
if category == 'all':
68+
tools = Tool.list_all_tools()
69+
else:
70+
tools = Tool.get_tools_by_category(category)
71+
tool_names = [t.name for t in tools]
72+
max_col = len(max(tool_names, key=len))
73+
max_width = 13
74+
max_col = max_col if max_col >= max_width else max_width
75+
4376
print("\nAvailable Tools:")
44-
for index, l in enumerate(Tool.list_all_tools()):
45-
print(f"[{index}] {l.name}")
77+
print(f" {'_'*((int(len(tools)/10)+5)+max_col+max_width+4)}")
78+
print(f"| #{' '*(int(len(tools)/10))} | {'Tool Name'+' '*(max_col-9)} | {'Tool category'+' '*(max_width-13)} |")
79+
print(f"|{'-'*(int(len(tools)/10)+3)}|-{'-'*(max_col)}-|-{'-'*(max_width)}-|")
80+
for index, t in enumerate(tools):
81+
padding = (len(str(index)))-int(len(tools)/10)
82+
padding = padding if padding else padding + 2
83+
print(f"| {str(index) + ' '*padding}| {t.name + ' '*(max_col-len(t.name))} | {t.category + ' '*(max_width-len(t.category))} |")
4684

4785
def list_sessions():
4886
print("\nSaved Sessions:")
@@ -54,14 +92,25 @@ def manage_agents(args: Namespace):
5492
try:
5593
if args.new:
5694
add_agent()
57-
elif args.list:
95+
if args.list:
5896
list_agents()
5997
except KeyboardInterrupt:
6098
print()
6199
sys.exit()
62100
except Exception as e:
63101
logging.exception(e)
64102
sys.exit(1)
103+
104+
def manage_tools(args: Namespace):
105+
try:
106+
if args.list:
107+
list_tools(args.list)
108+
except KeyboardInterrupt:
109+
print()
110+
sys.exit()
111+
except Exception as e:
112+
logging.exception(e)
113+
sys.exit(1)
65114

66115
def str_or_file(string):
67116
if len(string) > 100:
@@ -145,18 +194,20 @@ def get_arguments():
145194
agents_parser = subparsers.add_parser('agents', help="Manage agents")
146195
agents_parser.add_argument("name", type=str, nargs="?", help="Name of an agent to manage (details|update|remove)")
147196
agents_parser.add_argument('--new', action='store_true', help='Create a new agent')
148-
agents_parser.add_argument('--list', action='store_false', help='List all saved agents')
197+
agents_parser.add_argument('-l', '--list', action='store_false', help='List all saved agents')
149198
agents_parser.add_argument('--update', action='store_true', help='Update an agent')
150199
agents_parser.add_argument('--remove', action='store_true', help='Delete an agent')
151-
152200
agents_parser.set_defaults(func=manage_agents)
201+
202+
agents_parser = subparsers.add_parser('tools', help="Manage tools")
203+
agents_parser.add_argument('-l', '--list', type=str, default='all', nargs='?', choices=['all', 'general', 'system', 'web'], help='List tools by category')
204+
agents_parser.set_defaults(func=manage_tools)
153205

154206
parser.add_argument('--name', type=str, default='Assistant', help='Set name of agent')
155207
parser.add_argument('--provider', default='', help='Set llm provider to use')
156208
parser.add_argument('--providers', action='store_true', help='Get a list of all supported providers')
157209
parser.add_argument('--agents', action='store_true', help='List all saved agents')
158210
parser.add_argument('--agent', type=str, default='Assistant', help='Set which saved agent to use')
159-
parser.add_argument('--tools', action='store_true', help='List all available tools')
160211
parser.add_argument('--load-tools', type=lambda s: [i for i in s.split(',')], default='general', help='Add tools by categories to agent')
161212
parser.add_argument('--model', type=str, default='', help='Specify model or model_url to use')
162213
parser.add_argument('--api-key', type=str, default='', help='Set api key of selected llm')

0 commit comments

Comments
 (0)