Files
DungeonsDragons/backend/app/llm/client.py
T
Thorsten f37dc9fa76 Add Phase 1 MVP: D&D text-adventure server
FastAPI + Postgres backend with fastapi-users auth, games/characters
CRUD, and a WebSocket chat endpoint where an x.ai Grok DM narrates
play, rolls dice, and maintains character sheets via tool calls.
React + Tailwind frontend covers registration/login, game list and
creation, participation-code join flow, character viewer, and a
real-time chat session view. Docker Compose skeleton (Postgres +
backend) included; Caddy/frontend container wiring is deferred to
the deploy milestone.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-31 18:43:08 +02:00

19 lines
432 B
Python

from functools import lru_cache
from pathlib import Path
from openai import AsyncOpenAI
from app.config import settings
PROMPTS_DIR = Path(__file__).parent / "prompts"
@lru_cache
def get_dm_system_prompt() -> str:
return (PROMPTS_DIR / "dm_system_prompt.txt").read_text(encoding="utf-8")
@lru_cache
def get_llm_client() -> AsyncOpenAI:
return AsyncOpenAI(api_key=settings.xai_api_key, base_url=settings.xai_base_url)