Skip to content

Instantly share code, notes, and snippets.

@robert-mcdermott
Created October 8, 2023 23:12
Show Gist options
  • Save robert-mcdermott/2c6eb4976d2ba07f20a5f3477c6fd6d7 to your computer and use it in GitHub Desktop.
Save robert-mcdermott/2c6eb4976d2ba07f20a5f3477c6fd6d7 to your computer and use it in GitHub Desktop.
chatting with local ollama using langchain
from langchain.chat_models import ChatOllama
from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain.schema import HumanMessage
chat_model = ChatOllama(model="mistral", base_url = "http://localhost:11434", callback_manager = CallbackManager([StreamingStdOutCallbackHandler()]))
#chat_model = ChatOllama(model="mistral")
messages = [
HumanMessage(content="Why is the sky blue?")
]
chat_model(messages)
#print(chat_model(messages))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment