Find answers from the community

Updated last week

``` A Powerful Llm-based Agent With Versatile Tools ```

and use
Plain Text
llm = OpenAI(
      model=os.getenv("OPENAI_MODEL_NAME"),
      api_key=os.getenv("OPENAI_API_KEY")
    )

tools = [
      FunctionTool.from_defaults(
        fn=search_llm_tool,
        name="search_llm_tool",
        description=SEARCH_TOOL_DESCRIPTION.format(query=self.query_data.query, file_attached=file_attached)
      ),
      FunctionTool.from_defaults(
        fn=file_tool_wrapper,
        description=FILE_TOOL_DESCRIPTION.format(file_attached=file_attached)
      ),
      FunctionTool.from_defaults(
        fn=lambda query: gen_image_tool(query),
        description="ONLY use this to generate an image as requested by the user."
      ),
    ]
    # Create the agent
    agent = ReActAgent.from_tools(tools, llm=llm, verbose=True)
L
s
15 comments
The verbose logs should give more details on its thought process
thing is it used to work.
started breaking only recently
without any code changes
like i get this in the end

Action: Action Input: {"query": "generate an image of a frog"}
in the logs, i see

Plain Text
> Running step 7a1351bc-709f-4306-94ca-db32ed5bed4b. Step input: Please respond to the conversation
Thought: (Implicit) I can answer without any more tools!
Answer: Action: <lambda>
Action Input: {"query": "generate an image of a frog"}
full_response Action: <lambda>
Action Input: {"query": "generate an image of a frog"}
hmmm, I think passing in your function as a lambda might be breaking things
I'm surprised this worked before honestly
define an actual function instead
Plain Text
def gen_image_tool(query: str) -> None:
  "ONLY use this to generate an image as requested by the user.":
  ...

tool = FunctionTool.from_defaults(gen_image_tool)
hmm how do you pass in the parameters to the function then? like query in this case?
What do you mean? The llm will pass it to the tool
Basically this turns the function into a JSON schema that the LLM can understsand
and it will write the inputs
This is why the type annotations are important
Add a reply
Sign up and join the conversation on Discord