mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
## Description This PR addresses the following: **Fixes Issue #25343:** - Adds additional logic to parse shallowly nested JSON-encoded strings in tool call arguments, allowing for proper parsing of responses like that of Llama3.1 and 3.2 with nested schemas. **Adds Integration Test for Fix:** - Adds a Ollama specific integration test to ensure the issue is resolved and to prevent regressions in the future. **Fixes Failing Integration Tests:** - Fixes failing integration tests (even prior to changes) caused by `llama3-groq-tool-use` model. Previously, tests`test_structured_output_async` and `test_structured_output_optional_param` failed due to the model not issuing a tool call in the response. Resolved by switching to `llama3.1`. ## Issue Fixes #25343. ## Dependencies No dependencies. ____ Done in collaboration with @ishaan-upadhyay @mirajismail @ZackSteine.
langchain-ollama
This package contains the LangChain integration with Ollama
Installation
pip install -U langchain-ollama
You will also need to run the Ollama server locally. You can download it here.
Chat Models
ChatOllama class exposes chat models from Ollama.
from langchain_ollama import ChatOllama
llm = ChatOllama(model="llama3-groq-tool-use")
llm.invoke("Sing a ballad of LangChain.")
Embeddings
OllamaEmbeddings class exposes embeddings from Ollama.
from langchain_ollama import OllamaEmbeddings
embeddings = OllamaEmbeddings(model="llama3")
embeddings.embed_query("What is the meaning of life?")
LLMs
OllamaLLM class exposes LLMs from Ollama.
from langchain_ollama import OllamaLLM
llm = OllamaLLM(model="llama3")
llm.invoke("The meaning of life is")