fix: env var overrides for campaign settings (hf_token, ollama_host etc)
Some checks failed
Build and Push / build (push) Has been cancelled
Some checks failed
Build and Push / build (push) Has been cancelled
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from .. import database as db, config
|
||||
from .. import database as db
|
||||
from ..config import CAMPAIGN_SETTINGS, merge_campaign_settings_with_env
|
||||
|
||||
router = APIRouter(prefix="/api/campaigns", tags=["campaigns"])
|
||||
|
||||
@@ -52,17 +53,14 @@ def get_campaign_settings(campaign_id: str):
|
||||
if not db.get_campaign(campaign_id):
|
||||
raise HTTPException(404, "Campaign not found")
|
||||
raw = db.get_campaign_settings(campaign_id)
|
||||
# return defaults for any missing keys
|
||||
merged = {**config.CAMPAIGN_SETTINGS, **raw}
|
||||
return merged
|
||||
return merge_campaign_settings_with_env(raw)
|
||||
|
||||
|
||||
@router.post("/{campaign_id}/settings")
|
||||
def update_campaign_settings(campaign_id: str, body: dict):
|
||||
if not db.get_campaign(campaign_id):
|
||||
raise HTTPException(404, "Campaign not found")
|
||||
clean = {k: str(v) for k, v in body.items() if k in config.CAMPAIGN_SETTINGS}
|
||||
clean = {k: str(v) for k, v in body.items() if k in CAMPAIGN_SETTINGS}
|
||||
db.update_campaign_settings(campaign_id, clean)
|
||||
raw = db.get_campaign_settings(campaign_id)
|
||||
merged = {**config.CAMPAIGN_SETTINGS, **raw}
|
||||
return merged
|
||||
return merge_campaign_settings_with_env(raw)
|
||||
|
||||
@@ -2,6 +2,7 @@ import requests
|
||||
from fastapi import APIRouter, Query
|
||||
|
||||
from .. import database as db
|
||||
from ..config import merge_campaign_settings_with_env
|
||||
|
||||
router = APIRouter(prefix="/api/models", tags=["models"])
|
||||
|
||||
@@ -10,7 +11,7 @@ router = APIRouter(prefix="/api/models", tags=["models"])
|
||||
def list_ollama_models(campaign_id: str = Query("default")):
|
||||
"""List models already pulled on the configured Ollama host, so the setup
|
||||
wizard can offer a dropdown instead of asking the user to type a tag blind."""
|
||||
settings = db.get_campaign_settings(campaign_id)
|
||||
settings = merge_campaign_settings_with_env(db.get_campaign_settings(campaign_id))
|
||||
host = settings.get("ollama_host", "http://host.docker.internal:11434")
|
||||
try:
|
||||
resp = requests.get(f"{host.rstrip('/')}/api/tags", timeout=5)
|
||||
|
||||
@@ -3,6 +3,7 @@ from pathlib import Path
|
||||
from fastapi import APIRouter, HTTPException, Request
|
||||
|
||||
from .. import database as db, jobs
|
||||
from ..config import merge_campaign_settings_with_env
|
||||
from ..pipeline.turns import load_turns
|
||||
from ..pipeline.summarize import summarize_session
|
||||
|
||||
@@ -19,7 +20,7 @@ async def generate_notes(session_id: str, request: Request):
|
||||
raise HTTPException(400, "Session hasn't been transcribed yet")
|
||||
|
||||
cid = session["campaign_id"] or "default"
|
||||
settings = db.get_campaign_settings(cid)
|
||||
settings = merge_campaign_settings_with_env(db.get_campaign_settings(cid))
|
||||
speaker_map = {r["raw_label"]: r["display_name"] for r in
|
||||
db.get_conn().execute("SELECT raw_label, display_name FROM speakers WHERE session_id = ?", (session_id,))
|
||||
if r["display_name"]}
|
||||
|
||||
@@ -6,6 +6,7 @@ from pathlib import Path
|
||||
from fastapi import APIRouter, UploadFile, File, Form, HTTPException
|
||||
|
||||
from .. import database as db, config, jobs
|
||||
from ..config import merge_campaign_settings_with_env
|
||||
from ..errors import PipelineError
|
||||
from ..pipeline.audio import extract_audio
|
||||
from ..pipeline.transcribe import transcribe_and_diarize
|
||||
@@ -86,7 +87,7 @@ def get_session(session_id: str):
|
||||
|
||||
def _run_transcription(session_id: str, video_path: Path, audio_path: Path, transcript_path: Path, campaign_id: str | None = None):
|
||||
cid = campaign_id or "default"
|
||||
settings = db.get_campaign_settings(cid)
|
||||
settings = merge_campaign_settings_with_env(db.get_campaign_settings(cid))
|
||||
|
||||
def run(progress_cb):
|
||||
db.get_conn() # ensure thread-local connection exists in this worker thread
|
||||
|
||||
Reference in New Issue
Block a user