Initial commit

This commit is contained in:
Chris Proctor
2026-04-07 22:49:53 -04:00
commit acb9585eb6
9 changed files with 377 additions and 0 deletions

35
goodmorning.py Normal file
View File

@@ -0,0 +1,35 @@
import ollama
MODEL = "tinyllama"
SYSTEM_PROMPT = """
You are a helpful morning assistant. Help me get ready for school.
"""
def send_message(messages):
"""Sends a conversation to the model, streaming its reply to the screen."""
print("\nAssistant: ", end="", flush=True)
reply = ""
for chunk in ollama.chat(model=MODEL, messages=messages, stream=True):
piece = chunk.message.content
print(piece, end="", flush=True)
reply += piece
print()
return reply
def run():
"""Runs a chat loop, keeping track of the conversation."""
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
print("Good morning! Type 'quit' to exit.")
while True:
user_input = input("\nYou: ")
if user_input.strip().lower() == "quit":
break
messages.append({"role": "user", "content": user_input})
reply = send_message(messages)
messages.append({"role": "assistant", "content": reply})
run()