-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add agent_interpreter tool and enhance Python code interpreter functi…
…onality (#749)
- Loading branch information
Showing
23 changed files
with
302 additions
and
78 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
packages/core/src/genaisrc/system.agent_interpreter.genai.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
system({ | ||
title: "Agent that can run code interpreters for Python, Math.", | ||
}) | ||
|
||
const model = env.vars.agentInterpreterModel | ||
defTool( | ||
"agent_interpreter", | ||
"Run code interpreters for Python, Math. Use this agent to ground computation questions.", | ||
{ | ||
query: { | ||
type: "string", | ||
description: "Query to answer", | ||
}, | ||
required: ["query"], | ||
}, | ||
async (args) => { | ||
const { context, query } = args | ||
context.log(`agent interpreter: ${query}`) | ||
const res = await runPrompt( | ||
(_) => { | ||
_.def("QUERY", query) | ||
_.$`You are an agent that can run code interpreters for Python, Math. | ||
Analyze and answer QUERY. Use the best tool to ground computation questions. | ||
- Assume that your answer will be analyzed by an AI, not a human. | ||
- Prefer math_eval for math expressions as it is much more efficient. | ||
- To use file data in python, prefer copying data files using python_code_interpreter_copy_files rather than inline data in code. | ||
- If you cannot answer the query, return an empty string. | ||
` | ||
}, | ||
{ | ||
model, | ||
system: [ | ||
"system", | ||
"system.tools", | ||
"system.explanations", | ||
"system.math", | ||
"system.python_code_interpreter", | ||
], | ||
label: "agent interpreter", | ||
} | ||
) | ||
return res | ||
} | ||
) |
Oops, something went wrong.