Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to agent with tool from example #476

Open
vaidikcs opened this issue May 23, 2024 · 6 comments
Open

Not able to agent with tool from example #476

vaidikcs opened this issue May 23, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@vaidikcs
Copy link

vaidikcs commented May 23, 2024

i tried to run code from your example

@tool
def search_api(query: str):
# Add your logic here
return query

Initializing the agent with the OpenAI instance and other parameters

agent = Agent(
agent_name="Covid-19-Chat",
agent_description=(
"This agent provides information about COVID-19 symptoms."
),
llm=llm,
max_loops="auto",
autosave=True,
verbose=True,
stopping_condition="finish",
tools=[search_api],
)

Defining the task and image path

task = ("What are the symptoms of COVID-19?",)

Running the agent with the specified task and image

out = agent.run(task)
print(out)

i got error

image

and one more thing is there any blog or something to see working of multi agents with tools.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@vaidikcs vaidikcs added the bug Something isn't working label May 23, 2024
Copy link

Hello there, thank you for opening an Issue ! 🙏🏻 The team was notified and they will get back to you asap.

@kyegomez
Copy link
Owner

@vaidikcs try another llm like Anthropic or Llama3Hosted, this has a parsing error but it did run!

@aimzieslol
Copy link

@kyegomez @vaidikcs I'm having this problem as well using Groq with the OpenAIChat class. @tool definition looks like this:

@tool(name='dumb_string', return_string=True, return_dict=False)
def dumb_string(dumb_str: str):
    return f'this is dumb: {dumb_str}'

I've tried removing all params from @tool, different params, using just @tool(), etc.

@Vits-99
Copy link

Vits-99 commented Jul 20, 2024

@kyegomez got same error here

@kyegomez
Copy link
Owner

@Vits-99 @aimzieslol @nictuku no more tool decorator is needed, just the function with types, and doc strings.

@Vits-99
Copy link

Vits-99 commented Jul 21, 2024

@kyegomez thanks! But why running the Devin Example I get this error in tool parsing?

2024-07-21T11:16:58.305840+0200 Error parsing and executing JSON: Expecting value: line 1 column 1 (char 0)

Or anyway I get this after providing file name and content in the terminal after interaction even if the agent understand it should be using the create_file tool:
Tool Call Output: {}

The code I am running is this:

from swarms import Agent, OpenAIChat
import subprocess

# Tools in swarms are simple python functions and docstrings
def terminal(
    code: str,
):
    """
    Run code in the terminal.

    Args:
        code (str): The code to run in the terminal.

    Returns:
        str: The output of the code.
    """
    out = subprocess.run(
        code, shell=True, capture_output=True, text=True
    ).stdout
    return str(out)

def browser(query: str):
    """
    Search the query in the browser with the `browser` tool.

    Args:
        query (str): The query to search in the browser.

    Returns:
        str: The search results.
    """
    import webbrowser

    url = f"https://www.google.com/search?q={query}"
    webbrowser.open(url)
    return f"Searching for {query} in the browser."

def create_file(file_path: str, content: str):
    """
    Create a file using the file editor tool.

    Args:
        file_path (str): The path to the file.
        content (str): The content to write to the file.

    Returns:
        str: The result of the file creation operation.
    """
    with open(file_path, "w") as file:
        file.write(content)
    return f"File {file_path} created successfully."

def file_editor(file_path: str, mode: str, content: str):
    """
    Edit a file using the file editor tool.

    Args:
        file_path (str): The path to the file.
        mode (str): The mode to open the file in.
        content (str): The content to write to the file.

    Returns:
        str: The result of the file editing operation.
    """
    with open(file_path, mode) as file:
        file.write(content)
    return f"File {file_path} edited successfully."


# Agent
agent = Agent(
    agent_name="Devin",
    system_prompt=(
        "Autonomous agent that can interact with humans and other"
        " agents. Be Helpful and Kind. Use the tools provided to"
        " assist the user. Return all code in markdown format."
    ),
    llm=OpenAIChat(model_name="gpt-4o-mini", openai_api_key="..."),
    max_loops="auto",
    autosave=True,
    dashboard=False,
    verbose=True,
    interactive=True,
    tools=[terminal, browser, file_editor, create_file],
    code_interpreter=True,
)

# Run the agent
out = agent("Create a new file for a plan to take over the world.")
print(out)

I can then interact with it but it is not able to use the tools. Any suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants