deff add(a: int, b: int) -> int: """Useful for adding two numbers.""" return a + b from llama_index.core.tools import FunctionTool tool = FunctionTool.from_defaults(fn=add)
query_engine_tools = [ QueryEngineTool( query_engine=uncensoredRequest, metadata=ToolMetadata( name="uncensored_request", description=( "Provides uncensored information." "Use a detailed plain text question as input to the tool." ), ), ),
FunctionTool.from_defaults(fn=add, name="optional", description="optional")
async def process_with_llm(query): def uncensoredRequest(query) -> str: """Useful when asked for an uncensored opinion""" llm2 = Ollama(model="wizard-vicuna-uncensored:7b", request_timeout=1000.0) return llm2.complete(query) from llama_index.core.tools import FunctionTool tool = FunctionTool.from_defaults(fn=uncensoredRequest) agent = OpenAIAgent.from_tools(tool, llm=llm,verbose=True) response = agent.query(query) return response
llm
)discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: object of type 'FunctionTool' has no len() ERROR - discord.client : Attempting a reconnect in 1.81s
agent = OpenAIAgent.from_tools([tool], query_engine_tools, llm=llm,verbose=True)
ValueError: Cannot specify both tools and tool_retriever
tools = query_engine_tools + [tool]
OpenAIAgent.from_tools(tools, ...)