trading_agent.tools.edit_file_tool
¶
The edit_file tool: replaces exact text in a file in the desk's own folders.
Typical usage example:
tool = EditFileTool(policy, checkpoints)
EditFileArguments
¶
Bases: BaseModel
The arguments of edit_file.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
str
|
The file; a relative path starts at your desk folder. |
old_text |
str
|
The exact text to replace, copied from the file. |
new_text |
str
|
The text to put in its place. |
replace_all |
bool
|
Whether to replace every occurrence instead of exactly one. |
EditFileTool
¶
Bases: Tool
Replaces exact text in a file.
Creates the tool.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
PathPolicy
|
The desk's read and write rules. |
required |
checkpoints
|
Checkpoints | None
|
Snapshots the desk's files before each change, or None to take none. |
None
|
Source code in src/trading_agent/tools/edit_file_tool.py
run
async
¶
Makes the replacement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arguments
|
EditFileArguments
|
The file, the text to find and its replacement. |
required |
Returns:
| Type | Description |
|---|---|
ToolResult
|
How many places changed, or an error saying why nothing did. |