Closed umairgillani93 closed 1 month ago
You spelled RunnableSequence as RunnalbeSequence.
Is ollama supporting tools?
Well, apparently ChatOllama successfully creates a agent instance when passed as an argument to create_openai_functions_agent. Here's the output, you can check it returns "RunnableSequence", and doesn't complain about argument tools and also shows tools information in response object.
middle=[ChatPromptTemplate(input_variables=['agent_scratchpad', 'input'], input_types={'agent_scratchpad': typing.List[typing.Union[langchain_core.messages.ai.AIMessage, langchain_core.messages.human.HumanMessage, langchain_core.messages.chat.ChatMessage, langchain_core.messages.system.SystemMessage, langchain_core.messages.function.FunctionMessage, langchain_core.messages.tool.ToolMessage]]}, messages=[HumanMessagePromptTemplate(prompt=PromptTemplate(input_variables=['input'], template='{input}')), MessagesPlaceholder(variable_name='agent_scratchpad')])] last=RunnableBinding(bound=ChatOllama(), kwargs={'functions': [{'name': 'run_query', 'description': 'runs the passed query\nand returns the result.', 'parameters': {'type': 'object', 'properties': {}, 'required': ['query']}}]})
The issue arises when the agent is executed calling invoke method on it, as AgentExecutor expects agent to be Union[BaseSingleActionAgent, BaseMultiActionAgent] but our agent is not either of those. So far it hasn't thrown any error specifically related to "tools" but I was reading out the issues and stumbled upon an issue that said, "custom tools are not working with other than ChatGpt models".
I'm trying to write a custom Wrapper that inherits from BaseSingleActionAgent and has all the required method like "input_keys", "plan" etc implemented, and uses ChatOllama for an agent.
Take a look at #22339 which should have addressed this issue. The PR was approved and merged yesterday but a release is yet to be cut from it and should happen in the next few days.
In the meantime, you may try and install langchain-experimental
directly from langchain's source like this:
pip install git+https://github.com/langchain-ai/langchain.git\#egg=langchain-experimental\&subdirectory=libs/experimental
I hope this helps.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
values, fields_set, validation_error = validate_model(__pydantic_self__.__class__, data)
System Info