langchain-hs-ollama 0.0.6.1 → 0.0.6.2
raw patch · 4 files changed
+29/−35 lines, 4 filesdep ~langchain-hs-corePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: langchain-hs-core
API changes (from Hackage documentation)
- Langchain.Embeddings.Ollama: instance GHC.Internal.Show.Show Langchain.Embeddings.Ollama.OllamaEmbeddings
- Langchain.Provider.Ollama: instance GHC.Internal.Base.Monoid Langchain.Provider.Ollama.OllamaConfig
- Langchain.Provider.Ollama: instance GHC.Internal.Base.Semigroup Langchain.Provider.Ollama.OllamaConfig
- Langchain.Provider.Ollama: instance GHC.Internal.Generics.Generic Langchain.Provider.Ollama.OllamaConfig
- Langchain.Provider.Ollama: instance GHC.Internal.Show.Show (Langchain.Provider.Ollama.OllamaWithTools m)
- Langchain.Provider.Ollama: instance GHC.Internal.Show.Show Langchain.Provider.Ollama.Ollama
- Langchain.Provider.Ollama: instance GHC.Internal.Show.Show Langchain.Provider.Ollama.OllamaConfig
+ Langchain.Embeddings.Ollama: instance GHC.Show.Show Langchain.Embeddings.Ollama.OllamaEmbeddings
+ Langchain.Provider.Ollama: instance GHC.Base.Monoid Langchain.Provider.Ollama.OllamaConfig
+ Langchain.Provider.Ollama: instance GHC.Base.Semigroup Langchain.Provider.Ollama.OllamaConfig
+ Langchain.Provider.Ollama: instance GHC.Generics.Generic Langchain.Provider.Ollama.OllamaConfig
+ Langchain.Provider.Ollama: instance GHC.Show.Show (Langchain.Provider.Ollama.OllamaWithTools m)
+ Langchain.Provider.Ollama: instance GHC.Show.Show Langchain.Provider.Ollama.Ollama
+ Langchain.Provider.Ollama: instance GHC.Show.Show Langchain.Provider.Ollama.OllamaConfig
Files
- CHANGELOG.md +8/−2
- README.md +1/−1
- langchain-hs-ollama.cabal +2/−2
- src/Langchain/Provider/Ollama.hs +18/−30
CHANGELOG.md view
@@ -1,9 +1,15 @@ # Changelog for langchain-hs-ollama +## 0.0.6.2 - 2026-11-14++- Coordinated monorepo release alignment to `0.0.6.2`.+- Forward streamed tool calls from `ollama-haskell` in `ChatModel.stream` as `LLMChunk "" (Just toolCall)`.+- Updated `langchain-hs-core` dependency bound to `>= 0.0.6.2 && < 0.0.7`.+ ## 0.0.6.1 - 2026-10-25 -- Upgrade to `ollama-haskell >= 0.4.2.0`.-- Update `ToolCall`, `Message`, and `ChatRequest` constructors and accessors for `ollama-haskell-0.4.2.0` compatibility.+- Upgrade dependency `ollama-haskell` to `>= 0.4.2.0 && < 0.5`.+- Update message and tool call conversions for `ollama-haskell-0.4.2.0`. ## 0.0.6.0 - 2026-10-02
README.md view
@@ -9,7 +9,7 @@ ```yaml # stack.yaml extra-deps-- langchain-hs-ollama-0.0.6.0+- langchain-hs-ollama-0.0.6.2 ``` ```yaml
langchain-hs-ollama.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: langchain-hs-ollama-version: 0.0.6.1+version: 0.0.6.2 synopsis: Ollama provider and embeddings for langchain-hs description: Ollama ChatModel provider and text embeddings integration for langchain-hs. Depends only on ollama-haskell; does not pull in OpenAI or Gemini dependencies. category: AI@@ -43,7 +43,7 @@ , base >=4.17 && <5 , bytestring >=0.10 && <0.13 , conduit ==1.3.*- , langchain-hs-core ==0.0.6.*+ , langchain-hs-core >=0.0.6.2 && <0.0.7 , mtl >=2.2 && <2.4 , ollama-haskell >=0.4.2.0 && <0.5 , text >=1.2 && <3
src/Langchain/Provider/Ollama.hs view
@@ -65,7 +65,7 @@ ) where import Control.Applicative ((<|>))-import Control.Monad (when)+import Control.Monad (forM_, unless) import Control.Monad.Except (throwError) import Control.Monad.IO.Class (MonadIO, liftIO) import Data.Aeson (Result (..), decode, fromJSON, toJSON, (.=))@@ -73,7 +73,7 @@ import qualified Data.ByteString.Lazy.Char8 as LBSC import Data.Conduit (await, transPipe, yield, (.|)) import qualified Data.List.NonEmpty as NonEmpty-import Data.Maybe (fromMaybe, isJust, mapMaybe)+import Data.Maybe (fromMaybe, mapMaybe) import Data.Proxy (Proxy (..)) import Data.Text (Text) import qualified Data.Text as T@@ -234,9 +234,10 @@ Just tcs -> Just [ OTool.mkToolCall- (OTool.mkToolCallFunction- (toolCallName tc)- (parseArgs (toolCallArguments tc)))+ ( OTool.mkToolCallFunction+ (toolCallName tc)+ (parseArgs (toolCallArguments tc))+ ) | tc <- tcs ] parseArgs v = case v of@@ -247,15 +248,7 @@ _ -> case fromJSON v of Success m -> m _ -> mempty- in O.Message- { O.messageRole = r- , O.messageContent = txt- , O.messageImages = imgs- , O.messageToolCalls = tools- , O.messageToolName = messageName msg- , O.messageThinking = Nothing- , O.messageToolCallId = Nothing- }+ in O.Message r txt imgs tools (messageName msg) Nothing Nothing -- | Convert Ollama 'O.Message' to core 'Message'. fromOllamaMessage :: O.Message -> Message@@ -268,7 +261,7 @@ Just [ ToolCall { toolCallId = fromMaybe "" (OTool.tcId tc)- , toolCallType = fromMaybe "function" (OTool.tcType tc)+ , toolCallType = "function" , toolCallName = OTool.tcfName (OTool.tcFunction tc) , toolCallArguments = toJSON (OTool.tcfArguments (OTool.tcFunction tc)) }@@ -293,17 +286,13 @@ (m : ms) -> NonEmpty.map toOllamaMessage (m NonEmpty.:| ms) [] -> O.userMessage "" NonEmpty.:| [] cfg = fromMaybe defaultOllamaConfig mbConfig- in OllamaChat.ChatRequest- { OllamaChat.chatModel = ModelName mName- , OllamaChat.chatMessages = oMsgs- , OllamaChat.chatTools = ollamaTools cfg+ in (OllamaChat.chatRequest (ModelName mName) oMsgs)+ { OllamaChat.chatTools = ollamaTools cfg , OllamaChat.chatFormat = ollamaFormat cfg , OllamaChat.chatOptions = ollamaOptions cfg , OllamaChat.chStream = Just False , OllamaChat.chatKeepAlive = ollamaKeepAlive cfg , OllamaChat.chatThink = ollamaThink cfg- , OllamaChat.chatLogprobs = Nothing- , OllamaChat.chatTopLogprobs = Nothing } instance ChatModel Ollama where@@ -320,7 +309,7 @@ stream model inputMsgs mbConfig = do let runId_ = "ollama-run"- req = toChatRequest model inputMsgs mbConfig+ req = (toChatRequest model inputMsgs mbConfig) {OllamaChat.chStream = Just True} resolvedModel = ollamaModelName model yield $ LLMStart runId_ resolvedModel inputMsgs@@ -346,26 +335,25 @@ Just tcs -> Just [ ToolCall- { toolCallId = ""+ { toolCallId = fromMaybe "" (OTool.tcId tc) , toolCallType = "function" , toolCallName = OTool.tcfName (OTool.tcFunction tc) , toolCallArguments = toJSON (OTool.tcfArguments (OTool.tcFunction tc)) } | tc <- tcs ]- toolDelta = case toolCalls of- Just (tc : _) -> Just tc- _ -> Nothing newAccChunks = if T.null chunkTxt then accChunks else chunkTxt : accChunks newTools = case toolCalls of- Just tcs -> Just $ maybe tcs (++ tcs) mbLastTools- Nothing -> mbLastTools+ Just tcs@(_ : _) -> Just $ maybe tcs (++ tcs) mbLastTools+ _ -> mbLastTools newUsage = case (OllamaChat.crPromptEvalCount resp, OllamaChat.crEvalCount resp) of (Just p, Just c) -> Just $ TokenUsage p c (p + c) _ -> mbLastUsage- when (not (T.null chunkTxt) || isJust toolDelta) $+ unless (T.null chunkTxt) $ yield $- LLMChunk rId chunkTxt toolDelta+ LLMChunk rId chunkTxt Nothing+ forM_ (fromMaybe [] toolCalls) $ \tc ->+ yield $ LLMChunk rId "" (Just tc) loop newAccChunks newUsage newTools instance CacheableChatModel Ollama where