import subprocess

def run_ollama_prompt(prompt, model="deepseek-r1:1.5b"):
    """Runs a prompt using Ollama CLI and returns the response."""
    command = ["ollama", "run", model, prompt]

    try:
        result = subprocess.run(command, capture_output=True, text=True, check=True, encoding="utf-8")
        response = result.stdout.strip()
        
        # Remove <think> tags if present
        response = response.replace("<think>", "").replace("</think>", "").strip()
        return response
    except subprocess.CalledProcessError as e:
        print("Error running Ollama:", e)
        return None

if __name__ == "__main__":
    while True:
        prompt = input("Enter your prompt (type 'exit' to exit): ")
        
        if prompt.lower() == "exit":
            print("Exiting...")
            break
        
        response = run_ollama_prompt(prompt)
        
        if response:
            print("Response:", response)
        else:
            print("Failed to get a response.")
