Replies: 1 comment 1 reply
-
🤖 It seems like you're trying to define a tool using the Here's how you can define your from llama_index.tools import BaseTool, ToolMetadata, ToolOutput
class DateTool(BaseTool):
@property
def metadata(self):
return ToolMetadata(
description="Tool Returns today's date in dd-mm-yyyy format",
name="get_today_date",
)
def __call__(self, input: Any) -> ToolOutput:
return ToolOutput(datetime.today().strftime('%d-%m-%Y')) And here's how you can use it in your agent: def agent(message, history):
date_tool = DateTool()
agent = ReActAgent.from_tools(tools=[date_tool], llm=llm, verbose=True)
response = agent.chat(message)
return response Please note that the Also, please note that there might have been changes in the tool definition and usage from LlamaIndex v0.8.42 to v0.9.33. I recommend updating to the latest version of LlamaIndex to ensure compatibility with the provided code. For more information, you can refer to the llama_index/tools/types.py file in the LlamaIndex repository. I hope this helps! If you have any more questions, feel free to ask. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Am learning Llama-Index to build an agent.
To understand the flow, for now am adding a simple tool to get today's date.
I tried FunctionTool and BaseToolSpec class APIs to acheive this. But am running into a KeyError: 'tool name (one of get_today_date)'
Below is my source code:
Full Trace of Error:
Beta Was this translation helpful? Give feedback.
All reactions