mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
langchain-ollama (partners) / langchain-core: allow passing ChatMessages to Ollama (including arbitrary roles) (#30411)
Replacement for PR #30191 (@ccurme) **Description**: currently, ChatOllama [will raise a value error if a ChatMessage is passed to it](https://github.com/langchain-ai/langchain/blob/master/libs/partners/ollama/langchain_ollama/chat_models.py#L514), as described https://github.com/langchain-ai/langchain/pull/30147#issuecomment-2708932481. Furthermore, ollama-python is removing the limitations on valid roles that can be passed through chat messages to a model in ollama - https://github.com/ollama/ollama-python/pull/462#event-16917810634. This PR removes the role limitations imposed by langchain and enables passing langchain ChatMessages with arbitrary 'role' values through the langchain ChatOllama class to the underlying ollama-python Client. As this PR relies on [merged but unreleased functionality in ollama-python]( https://github.com/ollama/ollama-python/pull/462#event-16917810634), I have temporarily pointed the ollama package source to the main branch of the ollama-python github repo. Format, lint, and tests of new functionality passing. Need to resolve issue with recently added ChatOllama tests. (Now resolved) **Issue**: resolves #30122 (related to ollama issue https://github.com/ollama/ollama/issues/8955) **Dependencies**: no new dependencies [x] PR title [x] PR message [x] Lint and test: format, lint, and test all running successfully and passing --------- Co-authored-by: Ryan Stewart <ryanstewart@Ryans-MacBook-Pro.local> Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
@@ -6,7 +6,10 @@ build-backend = "pdm.backend"
|
||||
authors = []
|
||||
license = { text = "MIT" }
|
||||
requires-python = "<4.0,>=3.9"
|
||||
dependencies = ["ollama<1,>=0.4.4", "langchain-core<1.0.0,>=0.3.52"]
|
||||
dependencies = [
|
||||
"ollama>=0.4.8,<1.0.0",
|
||||
"langchain-core<1.0.0,>=0.3.52",
|
||||
]
|
||||
name = "langchain-ollama"
|
||||
version = "0.3.2"
|
||||
description = "An integration package connecting Ollama and LangChain"
|
||||
|
||||
Reference in New Issue
Block a user