RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /Courses
  5. /First Local Chatbot
  6. /Ch. 9
First Local Chatbot

09. Personality Configuration

Chapter 9 of 15 · 20 min
KEY INSIGHT

The system prompt is the single most effective lever for controlling chatbot behavior—more than temperature or model selection.

System prompts control the chatbot's personality. Ollama accepts a messages array where the first message has role: "system". Store the system prompt in the session and prepend it to every request:

DEFAULT_SYSTEM = "You are a helpful, concise assistant. Answer in plain text, no markdown unless requested."

@app.post("/chat")
async def chat(session_id: str, model: str, messages: list[dict], system_prompt: str = DEFAULT_SYSTEM):
    if session_id not in sessions:
        sessions[session_id] = []

    # Inject system prompt at the start
    full_messages = [{"role": "system", "content": system_prompt}] + sessions[session_id]

    def stream():
        from app.ollama_client import stream_chat
        for chunk in stream_chat(model, full_messages):
            yield chunk

    return StreamingResponse(stream(), media_type="text/event-stream")

On the frontend, add a system prompt textarea to the settings panel:

<label>System Prompt:</label>
<textarea id="systemPrompt" rows="3">You are a helpful, concise assistant.</textarea>

Send it with each request:

const systemPrompt = document.getElementById("systemPrompt").value;
const response = await fetch(`/chat?session_id=${sessionId}&model=${model}&system_prompt=${encodeURIComponent(systemPrompt)}`, { ... });

Temperature controls randomness. Add a slider:

<label>Temperature: <span id="tempVal">0.7</span></label>
<input type="range" id="tempSlider" min="0" max="2" step="0.1" value="0.7" />

Pass it in the payload and update stream_chat to include temperature in the request body.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

Local verification checkpoint

Run the smallest example from this chapter in a local workspace and record the package version, runtime, data path, and observed output. If the result depends on model size, vector count, CPU/GPU backend, or available memory, note that constraint beside the exercise so the lesson remains reproducible.

EXERCISE

Create a "Code Assistant" persona with the system prompt: You are a senior software engineer. Write clean, tested code with comments. Prefer idiomatic Python. Test it against a general-purpose prompt.

← Chapter 8
Session Management
Chapter 10 →
Multiple Model Selection