# Code examples from: Run an LLM on Your Own Laptop with Ollama (Private, Free, Offline)
# https://www.atulvij.com/run-local-llm-ollama
# Review and adapt before running; examples use sample values.

# ---- Example 1 (bash) ----
ollama run llama3.2          # downloads ~2 GB the first time, then opens a chat
ollama list                  # models you have
ollama pull qwen2.5:7b       # get another model
ollama rm qwen2.5:7b         # free the disk space

# ---- Example 2 (python) ----
import requests

def ask(prompt, model="llama3.2"):
    r = requests.post("http://localhost:11434/api/generate",
                      json={"model": model, "prompt": prompt, "stream": False},
                      timeout=300)
    return r.json()["response"]

print(ask("Give an Excel formula to extract the domain from an email in A2."))

# ---- Example 3 (python) ----
import pandas as pd
df = pd.read_excel("feedback.xlsx")               # column: Comment
df["Sentiment"] = [ask(f"Reply with one word, Positive, Negative or Neutral:\n{c}").strip()
                   for c in df["Comment"]]
df.to_excel("feedback_tagged.xlsx", index=False)

# ---- Example 4 (text) ----
FROM llama3.2
PARAMETER temperature 0.2
SYSTEM You are an Excel expert. Reply with the formula first, then one line explaining it. Assume Excel 365.

# ---- Example 5 (bash) ----
ollama create excel-helper -f Modelfile
ollama run excel-helper

