| Copyright | (c) 2025 Tushar Adhatrao |
|---|---|
| License | MIT |
| Maintainer | Tushar Adhatrao <tusharadhatrao@gmail.com> |
| Stability | experimental |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
Langchain.LLM.Ollama
Description
Ollama implementation of LangChain's LLM interface , supporting:
- Text generation
- Chat interactions
- Streaming responses
- Callback integration
Example usage:
-- Create Ollama configuration ollamaLLM = Ollama "llama3" [stdOutCallback] -- Generate text response <- generate ollamaLLM "Explain Haskell monads" Nothing -- Right "Monads in Haskell..." -- Chat interaction let messages = UserMessage "What's the capital of France?" :| [] chatResponse <- chat ollamaLLM messages Nothing -- Right "The capital of France is Paris." -- Streaming streamHandler = StreamHandler print (putStrLn Done) streamResult <- stream ollamaLLM messages streamHandler Nothing
Documentation
Ollama LLM configuration Contains:
- Model name (e.g., "llama3:latest")
- Callbacks for event tracking
Example:
>>>Ollama "nomic-embed" [logCallback]Ollama "nomic-embed"
Constructors
| Ollama | |
Instances
| Show Ollama Source # | |
| LLM Ollama Source # | Ollama implementation of the LLM typeclass Note: Params argument is currently ignored (see TODOs). Example instance usage: -- Generate text with error handling case generate ollamaLLM Hello Nothing of Left err -> putStrLn $ "Error: " ++ err Right res -> putStrLn res |
| Runnable Ollama Source # | |
Defined in Langchain.LLM.Ollama Methods invoke :: Ollama -> RunnableInput Ollama -> IO (Either String (RunnableOutput Ollama)) Source # batch :: Ollama -> [RunnableInput Ollama] -> IO (Either String [RunnableOutput Ollama]) Source # stream :: Ollama -> RunnableInput Ollama -> (RunnableOutput Ollama -> IO ()) -> IO (Either String ()) Source # | |
| type RunnableInput Ollama Source # | |
Defined in Langchain.LLM.Ollama | |
| type RunnableOutput Ollama Source # | |
Defined in Langchain.LLM.Ollama | |