|
|
1 year ago | |
|---|---|---|
| .. | ||
| micro | 1 year ago | |
| prompts | 1 year ago | |
| README.md | 1 year ago | |
| __init__.py | 1 year ago | |
| codeact_agent.py | 1 year ago | |
| function_calling.py | 1 year ago | |
This folder is an implementation of OpenHands's main agent, the CodeAct Agent. It is based on (CodeAct, tweet), an idea of consolidating LLM agents' actions into a unified code action space for both simplicity and performance.
The CodeAct agent operates through a function calling interface. At each turn, the agent can:
bash commands with execute_bashexecute_ipython_cellbrowser and web_readstr_replace_editor or edit_fileThe agent provides several built-in tools:
execute_bashexecute_ipython_cell%pipweb_read and browserweb_read: Read and convert webpage content to markdownbrowser: Interact with webpages through Python codestr_replace_editoredit_file (LLM-based)Tools can be enabled/disabled through configuration parameters:
codeact_enable_browsing: Enable browser interaction toolscodeact_enable_jupyter: Enable IPython code executioncodeact_enable_llm_editor: Enable LLM-based file editing (falls back to string replacement editor if disabled)The agent includes specialized micro-agents for specific tasks:
The CodeAct agent uses a function calling interface based on litellm's ChatCompletionToolParam. To add a new tool:
Define the tool in function_calling.py:
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
},
),
)
Add the tool to get_tools() in function_calling.py
Implement the corresponding action handler in the agent class
The agent is implemented in two main files:
codeact_agent.py: Core agent implementation with:
function_calling.py: Tool definitions and function calling interface with: