Open natecard opened 5 months ago
You can refer to this https://python.langchain.com/docs/integrations/chat/
@natecard The documentation is out of sync with the code.
The addition of the the bind_tools
interface (#20360) to the BaseChatModel
(which ChatOllama
subclasses) was merged after the last release of langchain-core
(#20332). With the next release of langchain-core
you should see a slightly more informative "Not Implemented" message.
All of which is to say that please check the page sent by @liugddx - hopefully one of the models that supports the bind_tools
interface right now is available to you and can be used in your project.
@natecard ChatOllama or its underlying base class _OllamaCommon don't yet implement bind_tools. While implementing this function is pretty straight forward, using this code as reference, that alone won't be sufficient for the purposes of tool calling as neither the ChatOllama not the Ollama classes within langchain_community support tool calling directly at this time. There is an implementation within langchain_experimental.llms for OllamaFunctions which is a somewhat outdated implementation of tool calling and needs to be brought up to date if the intent is to use OpenAI style function calling. Worth checking out.
Posted a PR to add bind_tools to OllamaFunctions https://github.com/langchain-ai/langchain/pull/20881
reference for javascript implementation for bindtool? cc @natecard @lalanikarim
There still is no bind_tools for ChatOllama in the latest version from today's github. Any suggestions how this can be implemented?
There still is no bind_tools for ChatOllama in the latest version from today's github. Any suggestions how this can be implemented?
bind_tools is included in OllamaFunctions which is part of the langchain-experimental package. OllamaFunctions is an extension of ChatOllama for tool calling. The latest version of the published package is still missing some functionality, however a PR #22339 was approved and merged today which fixes that.
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.
thanks! is it possible to use FewShotPrompting with OllamaFunctions?
The Javascript SDK is also missing the implementation for tools using Ollama.
The official documentation says that ChatOllama supports bind_tools: https://python.langchain.com/v0.2/docs/integrations/chat/ollama/#tool-calling , is that true ? from my test it does not seem like it but i might have done something wrong.
The official documentation says that ChatOllama supports bind_tools: https://python.langchain.com/v0.2/docs/integrations/chat/ollama/#tool-calling , is that true ? from my test it does not seem like it but i might have done something wrong.
are you sure you are pulling ChatOllama
as in from langchain_ollama import ChatOllama
with package langhain-ollama installed?
The official documentation says that ChatOllama supports bind_tools: python.langchain.com/v0.2/docs/integrations/chat/ollama#tool-calling , is that true ? from my test it does not seem like it but i might have done something wrong.
are you sure you are pulling
ChatOllama
as infrom langchain_ollama import ChatOllama
with package langhain-ollama installed?
hmm I think I had an issue with my installations, that's what i imported from at the start but it did not work, so i switched back to from langchain_community.chat_models.ollama import ChatOllama
and then i forgot i did this change.
thanks !
The official documentation says that ChatOllama supports bind_tools: https://python.langchain.com/v0.2/docs/integrations/chat/ollama/#tool-calling , is that true ? from my test it does not seem like it but i might have done something wrong.
are you sure you are pulling
ChatOllama
as infrom langchain_ollama import ChatOllama
with package langhain-ollama installed?
@natecard I think this resolves the issue.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
In the docs for ChatOllama it says there is the method bind_tools() here. When I attempt to run the Ollama instance and bind the search tool it throws the AttributeError saying it has no attribute 'bind_tools'
System Info
System Information
Package Information
Packages not installed (Not Necessarily a Problem)
The following packages were not found: