|
|
1 рік тому | |
|---|---|---|
| .. | ||
| micro | 1 рік тому | |
| prompts | 1 рік тому | |
| README.md | 1 рік тому | |
| __init__.py | 1 рік тому | |
| codeact_agent.py | 1 рік тому | |
| function_calling.py | 1 рік тому | |
This folder implements the CodeAct idea (paper, tweet) that consolidates LLM agents’ actions into a unified code action space for both simplicity and performance (see paper for more details).
The conceptual idea is illustrated below. At each turn, the agent can:
bash commandPython code with an interactive Python interpreter. This is simulated through bash command, see plugin system below for more details.The CodeAct agent uses a function calling interface to define tools that the agent can use. Tools are defined in function_calling.py using the ChatCompletionToolParam class from litellm. Each tool consists of:
ChatCompletionToolParam that specifies:
Here's an example of how a tool is defined:
MyTool = ChatCompletionToolParam(
type='function',
function=ChatCompletionToolParamFunctionChunk(
name='my_tool',
description='Description of what the tool does and how to use it',
parameters={
'type': 'object',
'properties': {
'param1': {
'type': 'string',
'description': 'Description of parameter 1',
},
'param2': {
'type': 'integer',
'description': 'Description of parameter 2',
},
},
'required': ['param1'], # List required parameters here
},
),
)
To add a new tool:
function_calling.py following the pattern aboveget_tools() function in function_calling.pyThe agent currently supports several built-in tools:
execute_bash: Execute bash commandsexecute_ipython_cell: Run Python code in IPythonbrowser: Interact with a web browserstr_replace_editor: Edit files using string replacementedit_file: Edit files using LLM-based editingTools can be enabled/disabled through configuration parameters:
codeact_enable_browsing: Enable browser interactioncodeact_enable_jupyter: Enable IPython code executioncodeact_enable_llm_editor: Enable LLM-based file editing (if disabled, uses string replacement editor instead)