langchain_core/langchain_community: add ControlMessage to langchain_core and enable passing messages with 'control' role through ChatOllama#30147
Conversation
…t_messages_to_ollama_messages and deprecated _format_message_as_text methods
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
ccurme (ccurme)
left a comment
There was a problem hiding this comment.
Several issues with this:
- It's unlikely we are going to add a new message type to core until multiple large providers adopt something similar.
- We should be updating
langchain-ollamainlibs/partners/ollamainstead of the community implementation, which is deprecated (you should be seeing warning messages if you are using it).
Are you able to use use ChatMessage with a custom role for this instead?
|
ccurme (@ccurme) a ChatMessage with a custom role can potentially work, but there is currently an incompatibility between the type of the Also, ChatOllama's So in order to go that route, 1) the and 2) either the ChatMessage's The ChatMessage can technically work after addressing item If you are ok with this proposed route ccurme (@ccurme) (open to any feedback or alternative suggestions), and if that would satisfy your requirements/use-case Clément PAPPALARDO (@lemassykoi), I am happy to make those changes and open a new PR. |
|
Very much appreciate the detailed plan! Let's go for it, we can work around / document the issues with |
…ges 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 #30147 (comment). Furthermore, ollama-python is removing the limitations on valid roles that can be passed through chat messages to a model in ollama - ollama/ollama-python#462 (comment). 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]( ollama/ollama-python#462 (comment)), 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 ollama/ollama#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>
…ges 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 langchain-ai/langchain#30147 (comment). Furthermore, ollama-python is removing the limitations on valid roles that can be passed through chat messages to a model in ollama - ollama/ollama-python#462 (comment). 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]( ollama/ollama-python#462 (comment)), 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 ollama/ollama#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>
Description: this creates a ControlMessage class in langchain_core for messages with the 'control' role, and allows passing messages with 'control' role through to ollama through ChatOllama. The update to langchain_ollama’s ChatOllama relies on the added ControlMessage class in langchain_core, so updates to both libs are included in this PR
Issue: Granite 3.2 Thinking #30122
Dependencies: no new dependencies
PR title:
PR message:
Lint and test: format, lint, and test completed and passing in langchain_core and langchain_community.