PraisonAI 2.0.61__cp313-cp313-manylinux_2_39_x86_64.whl
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.
Potentially problematic release.
This version of PraisonAI might be problematic. Click here for more details.
- praisonai/__init__.py +6 -0
- praisonai/__main__.py +10 -0
- praisonai/agents_generator.py +648 -0
- praisonai/api/call.py +292 -0
- praisonai/auto.py +238 -0
- praisonai/chainlit_ui.py +304 -0
- praisonai/cli.py +518 -0
- praisonai/deploy.py +138 -0
- praisonai/inbuilt_tools/__init__.py +24 -0
- praisonai/inbuilt_tools/autogen_tools.py +117 -0
- praisonai/inc/__init__.py +2 -0
- praisonai/inc/config.py +96 -0
- praisonai/inc/models.py +128 -0
- praisonai/public/android-chrome-192x192.png +0 -0
- praisonai/public/android-chrome-512x512.png +0 -0
- praisonai/public/apple-touch-icon.png +0 -0
- praisonai/public/fantasy.svg +3 -0
- praisonai/public/favicon-16x16.png +0 -0
- praisonai/public/favicon-32x32.png +0 -0
- praisonai/public/favicon.ico +0 -0
- praisonai/public/game.svg +3 -0
- praisonai/public/logo_dark.png +0 -0
- praisonai/public/logo_light.png +0 -0
- praisonai/public/movie.svg +3 -0
- praisonai/public/praison-ai-agents-architecture-dark.png +0 -0
- praisonai/public/praison-ai-agents-architecture.png +0 -0
- praisonai/public/thriller.svg +3 -0
- praisonai/setup/__init__.py +1 -0
- praisonai/setup/build.py +21 -0
- praisonai/setup/config.yaml +60 -0
- praisonai/setup/post_install.py +23 -0
- praisonai/setup/setup_conda_env.py +25 -0
- praisonai/setup/setup_conda_env.sh +72 -0
- praisonai/setup.py +16 -0
- praisonai/test.py +105 -0
- praisonai/train.py +276 -0
- praisonai/ui/README.md +21 -0
- praisonai/ui/agents.py +822 -0
- praisonai/ui/callbacks.py +57 -0
- praisonai/ui/chat.py +387 -0
- praisonai/ui/code.py +440 -0
- praisonai/ui/colab.py +474 -0
- praisonai/ui/colab_chainlit.py +81 -0
- praisonai/ui/components/aicoder.py +269 -0
- praisonai/ui/config/.chainlit/config.toml +120 -0
- praisonai/ui/config/.chainlit/translations/bn.json +231 -0
- praisonai/ui/config/.chainlit/translations/en-US.json +229 -0
- praisonai/ui/config/.chainlit/translations/gu.json +231 -0
- praisonai/ui/config/.chainlit/translations/he-IL.json +231 -0
- praisonai/ui/config/.chainlit/translations/hi.json +231 -0
- praisonai/ui/config/.chainlit/translations/kn.json +231 -0
- praisonai/ui/config/.chainlit/translations/ml.json +231 -0
- praisonai/ui/config/.chainlit/translations/mr.json +231 -0
- praisonai/ui/config/.chainlit/translations/ta.json +231 -0
- praisonai/ui/config/.chainlit/translations/te.json +231 -0
- praisonai/ui/config/.chainlit/translations/zh-CN.json +229 -0
- praisonai/ui/config/chainlit.md +1 -0
- praisonai/ui/config/translations/bn.json +231 -0
- praisonai/ui/config/translations/en-US.json +229 -0
- praisonai/ui/config/translations/gu.json +231 -0
- praisonai/ui/config/translations/he-IL.json +231 -0
- praisonai/ui/config/translations/hi.json +231 -0
- praisonai/ui/config/translations/kn.json +231 -0
- praisonai/ui/config/translations/ml.json +231 -0
- praisonai/ui/config/translations/mr.json +231 -0
- praisonai/ui/config/translations/ta.json +231 -0
- praisonai/ui/config/translations/te.json +231 -0
- praisonai/ui/config/translations/zh-CN.json +229 -0
- praisonai/ui/context.py +283 -0
- praisonai/ui/db.py +291 -0
- praisonai/ui/public/fantasy.svg +3 -0
- praisonai/ui/public/game.svg +3 -0
- praisonai/ui/public/logo_dark.png +0 -0
- praisonai/ui/public/logo_light.png +0 -0
- praisonai/ui/public/movie.svg +3 -0
- praisonai/ui/public/praison.css +3 -0
- praisonai/ui/public/thriller.svg +3 -0
- praisonai/ui/realtime.py +476 -0
- praisonai/ui/realtimeclient/__init__.py +653 -0
- praisonai/ui/realtimeclient/realtimedocs.txt +1484 -0
- praisonai/ui/realtimeclient/tools.py +236 -0
- praisonai/ui/sql_alchemy.py +707 -0
- praisonai/ui/tools.md +133 -0
- praisonai/version.py +1 -0
- praisonai-2.0.61.dist-info/LICENSE +20 -0
- praisonai-2.0.61.dist-info/METADATA +679 -0
- praisonai-2.0.61.dist-info/RECORD +89 -0
- praisonai-2.0.61.dist-info/WHEEL +4 -0
- praisonai-2.0.61.dist-info/entry_points.txt +5 -0
praisonai/ui/tools.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# Understanding Tool Integration in AI Agents - A Beginner's Guide
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This guide explains how to properly integrate tools (functions) that an AI agent can use, making them both understandable to the OpenAI API and executable by your code.
|
|
5
|
+
|
|
6
|
+
## Key Components
|
|
7
|
+
|
|
8
|
+
### 1. Tool Definition Structure
|
|
9
|
+
```python
|
|
10
|
+
# Example tool definition in tools.py
|
|
11
|
+
def search_tool(query: str) -> list:
|
|
12
|
+
"""
|
|
13
|
+
Perform a web search using DuckDuckGo.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
query (str): The search query string.
|
|
17
|
+
|
|
18
|
+
Returns:
|
|
19
|
+
list: Search results with title, url, and snippet.
|
|
20
|
+
"""
|
|
21
|
+
# Function implementation...
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### 2. Tool Dictionary Format
|
|
25
|
+
```python
|
|
26
|
+
tools_dict = {
|
|
27
|
+
'search_tool': {
|
|
28
|
+
'type': 'function',
|
|
29
|
+
'function': {
|
|
30
|
+
'name': 'search_tool',
|
|
31
|
+
'description': '...',
|
|
32
|
+
'parameters': {
|
|
33
|
+
'type': 'object',
|
|
34
|
+
'properties': {
|
|
35
|
+
'query': {'type': 'string'}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
'callable': search_tool # The actual Python function
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## The Two-Part System
|
|
45
|
+
|
|
46
|
+
### Part 1: OpenAI API Communication
|
|
47
|
+
```python
|
|
48
|
+
# task_tools: What OpenAI understands
|
|
49
|
+
task_tools = []
|
|
50
|
+
tool_def = tools_dict[tool_name].copy()
|
|
51
|
+
callable_func = tool_def.pop("callable") # Remove the Python function
|
|
52
|
+
task_tools.append(tool_def) # Add clean JSON-serializable definition
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Part 2: Function Execution
|
|
56
|
+
```python
|
|
57
|
+
# role_tools: What your code executes
|
|
58
|
+
role_tools = []
|
|
59
|
+
role_tools.append(callable_func) # Store the actual function
|
|
60
|
+
agent.tools = role_tools # Give agent access to executable functions
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Putting It All Together
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# Initialize empty lists
|
|
67
|
+
role_tools = [] # For executable functions
|
|
68
|
+
task_tools = [] # For OpenAI API definitions
|
|
69
|
+
|
|
70
|
+
# Process each tool
|
|
71
|
+
for tool_name in tools_list:
|
|
72
|
+
if tool_name in tools_dict:
|
|
73
|
+
# 1. Get the tool definition
|
|
74
|
+
tool_def = tools_dict[tool_name].copy()
|
|
75
|
+
|
|
76
|
+
# 2. Separate the callable function
|
|
77
|
+
callable_func = tool_def.pop("callable")
|
|
78
|
+
|
|
79
|
+
# 3. Store the function for execution
|
|
80
|
+
role_tools.append(callable_func)
|
|
81
|
+
|
|
82
|
+
# 4. Store the API definition
|
|
83
|
+
task_tools.append(tool_def)
|
|
84
|
+
|
|
85
|
+
# 5. Give agent access to functions
|
|
86
|
+
agent.tools = role_tools
|
|
87
|
+
|
|
88
|
+
# Create task with API definitions
|
|
89
|
+
task = Task(
|
|
90
|
+
description="...",
|
|
91
|
+
tools=task_tools, # OpenAI API will use these
|
|
92
|
+
agent=agent, # Agent has access to callable functions
|
|
93
|
+
# ... other parameters ...
|
|
94
|
+
)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Why This Works
|
|
98
|
+
|
|
99
|
+
1. **API Communication**
|
|
100
|
+
- OpenAI API receives clean JSON tool definitions
|
|
101
|
+
- No Python functions that would cause serialization errors
|
|
102
|
+
|
|
103
|
+
2. **Function Execution**
|
|
104
|
+
- Agent has access to actual Python functions
|
|
105
|
+
- Can execute tools when OpenAI decides to use them
|
|
106
|
+
|
|
107
|
+
3. **Separation of Concerns**
|
|
108
|
+
- `task_tools`: Describes what tools can do (for OpenAI)
|
|
109
|
+
- `role_tools`: Actually does the work (for Python)
|
|
110
|
+
|
|
111
|
+
## Common Errors and Solutions
|
|
112
|
+
|
|
113
|
+
1. **"Invalid type for 'tools[0]'"**
|
|
114
|
+
- Cause: Sending null or invalid tool definition to OpenAI
|
|
115
|
+
- Solution: Use proper tool definition format in `task_tools`
|
|
116
|
+
|
|
117
|
+
2. **"Object of type function is not JSON serializable"**
|
|
118
|
+
- Cause: Trying to send Python function to OpenAI API
|
|
119
|
+
- Solution: Remove callable function from API definition
|
|
120
|
+
|
|
121
|
+
3. **"Tool is not callable"**
|
|
122
|
+
- Cause: Agent doesn't have access to executable functions
|
|
123
|
+
- Solution: Set `agent.tools = role_tools`
|
|
124
|
+
|
|
125
|
+
## Best Practices
|
|
126
|
+
|
|
127
|
+
1. Always initialize both `task_tools` and `role_tools` lists
|
|
128
|
+
2. Make clean copies of tool definitions to avoid modifying originals
|
|
129
|
+
3. Keep tool definitions JSON-serializable for API communication
|
|
130
|
+
4. Ensure agents have access to callable functions
|
|
131
|
+
5. Document tool parameters and return values clearly
|
|
132
|
+
|
|
133
|
+
This structure maintains clean separation between API communication and actual function execution, making your AI agent system both reliable and maintainable.
|
praisonai/version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.1"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|