at least this kind of works
This commit is contained in:
23
test.py
Normal file
23
test.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import ollama
|
||||
|
||||
# 1. Define your variables
|
||||
system_prompt = "You are a helpful assistant with a witty personality."
|
||||
context_prompt = "The current topic of conversation is quantum computing."
|
||||
user_input = "Can you explain it like I'm five?"
|
||||
|
||||
# 2. Combine the prompts
|
||||
# We merge the system and context for the 'system' role
|
||||
combined_system = f"{system_prompt}\n\nContext: {context_prompt}"
|
||||
|
||||
# 3. Stream the response
|
||||
stream = ollama.chat(
|
||||
model='llama3.2', # or your preferred model
|
||||
messages=[
|
||||
{'role': 'system', 'content': combined_system},
|
||||
{'role': 'user', 'content': user_input},
|
||||
],
|
||||
stream=True,
|
||||
)
|
||||
|
||||
for chunk in stream:
|
||||
print(chunk['message']['content'], end='', flush=True)
|
||||
Reference in New Issue
Block a user