Replies: 2 comments
-
python_repl.run("3*4は?") Uses the python interpreter to run the given string rather than the agent. If you're getting this during operation of the agent, it's because the agent isn't able to create a valid python expression. You can wrap the python repl tool with a try except that catches SyntaxErrors and translates them into ToolExceptionErrors to give feedback to the agent that it was using incorrect python syntax. |
Beta Was this translation helpful? Give feedback.
-
i try it. `try:
except Exception as e: tools = [ ] llm = ChatOpenAI(temperature=0.9,model = "gpt-4") agent_= initialize_agent( python_repl.run("3*4は?") `
"Sorry for the delay. What should I do?" |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
II want to run python code in langchain.
However, I often get a syntax error and I don't know how to solve it.
Below is the code defined by python_repl and the result of its execution.
The error has been identified as being due to the fact that blocks of Python code are enclosed in ````.
#14357
What should I do?
I am translating it into English, so please ask me if you don't understand.
Beta Was this translation helpful? Give feedback.
All reactions