Open bibhas2 opened 4 months ago
Chat with history is perhaps the most common use case. In fact ollama run works like that. An example with that use case will be great for the newcomers. Here's a sample code:
ollama run
import ollama messages = [] def send(chat): messages.append( { 'role': 'user', 'content': chat, } ) stream = ollama.chat(model='mistral:instruct', messages=messages, stream=True, ) response = "" for chunk in stream: part = chunk['message']['content'] print(part, end='', flush=True) response = response + part messages.append( { 'role': 'assistant', 'content': response, } ) print("") while True: chat = input(">>> ") if chat == "/exit": break elif len(chat) > 0: send(chat)
Related to:
https://github.com/ollama/ollama-python/issues/63
And:
https://github.com/ollama/ollama-python/pull/64
Examples are always great! How about adding: system prompt & temperature setting?
Chat with history is perhaps the most common use case. In fact
ollama run
works like that. An example with that use case will be great for the newcomers. Here's a sample code: