Initial commit — Cortex API + Inara identity
Cortex: FastAPI backend serving Inara via Claude/Gemini CLI backends. Includes SSE streaming chat, session persistence, Google Chat webhook handler, and Docker support. Inara: Identity files (persona, soul, protocols, memory, context tiers) mounted read-only into the container at runtime. Features in initial cut: - /chat endpoint with SSE keepalive + LLM fallback - Session store with rolling history window - Markdown rendering, copy-to-clipboard, links open in new tab - Stacked right-column input controls (height selector, enter toggle, note mode with public/private) — semi-hidden until textarea grows - /note endpoint for injecting public context into session history - Docker Compose config (local dev runs natively; Docker for server) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
41
cortex/config.py
Normal file
41
cortex/config.py
Normal file
@@ -0,0 +1,41 @@
|
||||
from pathlib import Path
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
anthropic_api_key: str | None = None # not used — claude CLI handles auth
|
||||
inara_dir: Path = Path("../inara")
|
||||
sessions_dir: Path = Path("./data/sessions")
|
||||
default_model: str = "claude-sonnet-4-6"
|
||||
default_tier: int = 2
|
||||
max_history_messages: int = 40 # rolling window — 20 turns (user + assistant)
|
||||
primary_backend: str = "claude" # "claude" or "gemini" — other is always fallback
|
||||
|
||||
# Per-backend timeouts in seconds
|
||||
timeout_claude: int = 60
|
||||
timeout_gemini: int = 120 # frequently slow under load
|
||||
timeout_local: int = 300 # local models may need to load first
|
||||
|
||||
# Google Chat must receive a response within 30s or shows an error to the user
|
||||
google_chat_timeout: int = 25
|
||||
# Backend forced for Google Chat — Claude is more reliable within the 25s deadline
|
||||
google_chat_backend: str = "claude"
|
||||
host: str = "0.0.0.0"
|
||||
port: int = 8000
|
||||
|
||||
model_config = SettingsConfigDict(env_file=".env", env_file_encoding="utf-8", extra="ignore")
|
||||
|
||||
def inara_path(self) -> Path:
|
||||
"""Resolve inara_dir relative to this file's location if not absolute."""
|
||||
if self.inara_dir.is_absolute():
|
||||
return self.inara_dir
|
||||
return (Path(__file__).parent / self.inara_dir).resolve()
|
||||
|
||||
def sessions_path(self) -> Path:
|
||||
"""Resolve sessions_dir relative to this file's location if not absolute."""
|
||||
if self.sessions_dir.is_absolute():
|
||||
return self.sessions_dir
|
||||
return (Path(__file__).parent / self.sessions_dir).resolve()
|
||||
|
||||
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user