Files
ISAIP-1/test.py
2026-04-22 09:50:49 -04:00

23 lines
708 B
Python

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)