38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
import os
|
|
|
|
|
|
def tools_mapping(schema, handler, name=None):
|
|
tool_name = name or schema["function"]["name"]
|
|
return {"name": tool_name, "schema": schema, "handler": handler}
|
|
|
|
|
|
def tool_schemas(tools_definition):
|
|
return [t["schema"] for t in tools_definition]
|
|
|
|
|
|
def tool_handlers(tools_definition):
|
|
return {t["name"]: t["handler"] for t in tools_definition}
|
|
|
|
|
|
def build_system_prompt(tools_definition):
|
|
lines = [
|
|
"You are a coding agent that assists with software engineering tasks. "
|
|
"You have access to the following tools:",
|
|
""
|
|
]
|
|
for i, tool in enumerate(tools_definition, 1):
|
|
name = tool["name"]
|
|
desc = tool["schema"]["function"]["description"]
|
|
lines.append(f"{i}. {name}: {desc}")
|
|
lines.extend([
|
|
"",
|
|
"Use tools by returning tool calls when needed. After receiving tool "
|
|
"results, continue your reasoning. When you have the final answer, "
|
|
"return it as plain text without tool calls.",
|
|
"",
|
|
f"Your workspace directory is: {os.getcwd()}. "
|
|
"All file operations are relative to this directory."
|
|
])
|
|
return "\n".join(lines)
|
|
|