Coder Social home page Coder Social logo

Comments (2)

mackong avatar mackong commented on September 15, 2024 1

@Jeomon You should call invoke like this

shell_tool.invoke(input={"command": 'python sum.py', "script_args": None, "inputs": '5\n'})

from langchain.

Jeomon avatar Jeomon commented on September 15, 2024 1

[0:tasks] Starting step 0 with 1 task:

  • start -> {'input': 'Writer Python program to Find the sum of two numbers and save this '
    'file in the current directory with the name sum.py and this program '
    'must take user input.'}
    [0:writes] Finished step 0 with writes to 1 channel:
  • input -> ('Writer Python program to Find the sum of two numbers and save this file in '
    'the current directory with the name sum.py and this program must take user '
    'input.')
    [1:tasks] Starting step 1 with 1 task:
  • coder -> {'input': 'Writer Python program to Find the sum of two numbers and save this '
    'file in the current directory with the name sum.py and this program '
    'must take user input.',
    'messages': []}

Entering new Python Code Agent chain...
Question: Write a Python program to find the sum of two numbers and save the file in the current directory with the name sum.py.
Thought: The program should take user input for the two numbers.
Action:

{
  "action": "Write Tool",
  "action_input": {
    "directory": "D:\\Personal Projects\\Python-Assistant",
    "file_name": "sum.py",
    "content": "num1 = int(input('Enter first number: '))\nnum2 = int(input('Enter second number: '))\nsum = num1 + num2\nprint('The sum of the two numbers is:', sum)"   
  }
}
```The sum.py successfully saved to D:\Personal Projects\Python-Assistant\sum.pyAction:

{
"action": "Final Answer",
"action_input": "The Python program to find the sum of two numbers has been successfully written and saved as sum.py in the current directory. You can run the program by executing python sum.py in the command line."
}


> Finished chain.
[1:writes] Finished step 1 with writes to 2 channels:
- input -> ('Writer Python program to Find the sum of two numbers and save this file in '
 'the current directory with the name sum.py and this program must take user '
 'input.')
- messages -> [HumanMessage(content='The Python program to find the sum of two numbers has been successfully written and saved as sum.py in the current directory. You can run the program by executing `python sum.py` in the command line.', name='Python Code Agent')]
[2:tasks] Starting step 2 with 1 task:
- executor -> {'input': 'Writer Python program to Find the sum of two numbers and save this '
          'file in the current directory with the name sum.py and this program '
          'must take user input.',
 'messages': [HumanMessage(content='The Python program to find the sum of two numbers has been successfully written and saved as sum.py in the current directory. You can run the program by executing `python sum.py` in the command line.', name='Python Code Agent')]}


> Entering new Python Executor Agent chain...
Could not parse LLM output: Action:

{
"action": "shell_tool",
"action_input": {
"command": "python sum.py",
"script_args": None,
"inputs": "2\n3\n"
}
}

The method you mentioned worked when I invoked it (in standalone without any llm the earlier case) but when I used it as tool for a react agent (executor agent) it is giving Invalid or incomplete responseCould not parse LLM output and then looping around this until the iteration limit is reached but the shell tool isn't invoked at all in that iterations.

from langchain.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.