api/modules/transcription/llm_client.py

54 lines
1.7 KiB
Python

"""Pluggable LLM client for transcription summaries.
Phase 1: Stub implementation — returns TODO string.
Phase 3: Wire up Anthropic, OpenAI, and Ollama providers.
"""
import os
from typing import Optional
async def call_llm(
provider: str,
model: str,
api_key: str,
system_prompt: str,
user_message: str,
) -> str:
"""Call an LLM to generate a summary.
Phase 1 stub — returns a TODO string.
Phase 3 will implement actual provider routing.
Args:
provider: 'anthropic', 'openai', 'ollama', 'openrouter', 'google'
model: Model name (e.g. 'claude-sonnet-4-6', 'gpt-4o', 'llama3')
api_key: User's API key (from localStorage, passed per-request)
system_prompt: System prompt template (already filled with transcript)
user_message: User message content
Returns:
LLM-generated summary text
"""
# Phase 1 stub — TODO: implement in Phase 3
return f"[TODO: Implement LLM call for provider={provider}, model={model}]"
async def call_anthropic(api_key: str, model: str, system_prompt: str, user_message: str) -> str:
"""Call Anthropic Claude API."""
# Phase 3 implementation placeholder
return f"[TODO: Anthropic call — model={model}]"
async def call_openai(api_key: str, model: str, system_prompt: str, user_message: str) -> str:
"""Call OpenAI API."""
# Phase 3 implementation placeholder
return f"[TODO: OpenAI call — model={model}]"
async def call_ollama(api_key: str, model: str, system_prompt: str, user_message: str) -> str:
"""Call local Ollama instance."""
# Phase 3 implementation placeholder
ollama_url = os.getenv("OLLAMA_URL", "https://ollama.kevlarai.com")
return f"[TODO: Ollama call — url={ollama_url}, model={model}]"