# Programmer: Seonwoo Kang
# Purpose: Maker faire exhibit (2024.11 Orlando)
# Date: 2024.9
# 
import subprocess, os, threading, time, sys

command = ["ollama", "run", "llama2"]

def run_ollama():
	try:
		os.system("ollama run llama2")
		# result = subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
		# print("Output:", result.stdout)
	except subprocess.CalledProcessError as e:
		print("Error:", e.stderr)
	except Exception as e:
		print("An error occurred:", str(e))

# Create and start the thread
ollama_thread = threading.Thread(target=run_ollama)
ollama_thread.start()
time.sleep(5)

while True:
    sys.stdout.write('tell me a short joke about LLM, more\n')
    sys.stdout.write('\n')  # Outputs the Enter key equivalent (newline character)
    sys.stdout.flush()
    time.sleep(5)
