Instruction file imported from Bryan-Roe-ai/Aria (
.github/instructions/functions.instructions.md). Copyright stays with the author.
Azure Functions – function_app.py
- Endpoints:
/api/chat,/api/chat-web,/api/tts,/api/quantum/*,/api/ai/status.- Verify runtime health at
/api/ai/status(active provider, env vars, SQL pool, Cosmos status).
- Verify runtime health at
- Local dev:
- Use the VS Code task:
func: host start(depends onpip install (functions)). - Azurite storage emulator databases are present at repo root; Functions work offline.
- Use the VS Code task:
- TTS configuration:
- Azure Speech: set
AZURE_SPEECH_KEYandAZURE_SPEECH_REGION(in env orlocal.settings.json). - Local fallback: set
QAI_ENABLE_LOCAL_TTS=true; server will try Azure → pyttsx3 → gTTS.
- Azure Speech: set
- Chat provider detection (see
shared/chat_providers.py): Azure OpenAI → OpenAI → LoRA → Local.- Azure requires:
AZURE_OPENAI_API_KEY,AZURE_OPENAI_ENDPOINT,AZURE_OPENAI_DEPLOYMENT,AZURE_OPENAI_API_VERSION.
- Azure requires:
- Streaming responses (SSE): emit
data: {json}lines and a finaldata: [DONE]; clients must parse SSE. - Secrets: do not hardcode; prefer
local.settings.jsonfor dev or Azure App Settings in prod. - Observability: Application Insights via
shared/telemetry.py; failures are non-blocking. - Optional Cosmos persistence: feature-flagged in
shared/cosmos_client.py.- Recommended keys:
QAI_ENABLE_COSMOS,COSMOS_ENDPOINT,COSMOS_KEY,COSMOS_DATABASE,COSMOS_CONTAINER. - Partition key:
/session_id; enable TTL for ephemeral messages.
- Recommended keys:
- Testing: prefer
python .\\scripts\\test_runner.py --all; markersnot slow and not azurefor local.