Skip to content

Commit 90d37b5

Browse files
committed
✨(summary) add multi-tenant support and v2 tasks / API
Add multitenancy support to Summary sub-app. The V1 routes / tasks behave like before, with the default tenant being "meet". V2 routes / tasks support being called frm any tenant, and don't have meet related logic. V2 tasks are created in separate queues to avoid mix / match,i
1 parent 4f2c4bf commit 90d37b5

16 files changed

Lines changed: 697 additions & 91 deletions

File tree

src/helm/env.d/dev-keycloak/values.meet.yaml.gotmpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ summary:
172172
WHISPERX_BASE_URL: https://configure-your-url.com
173173
WHISPERX_ASR_MODEL: large-v2
174174
WHISPERX_DEFAULT_LANGUAGE: fr
175+
AUTHORIZED_TENANTS: '[{"id": "dictaphone", "api_key": "dictaphone_token", "webhook_url": "http://dictaphone-backend.dictaphone.svc.cluster.local/api/v1.0/files/ai-webhook/", "webhook_api_key": "token_summary"}]'
175176
LLM_BASE_URL: https://configure-your-url.com
176177
LLM_API_KEY: your-secret-value
177178
LLM_MODEL: meta-llama/Llama-3.1-8B-Instruct
@@ -209,6 +210,7 @@ celeryTranscribe:
209210
WHISPERX_BASE_URL: https://configure-your-url.com
210211
WHISPERX_ASR_MODEL: large-v2
211212
WHISPERX_DEFAULT_LANGUAGE: fr
213+
AUTHORIZED_TENANTS: '[{"id": "dictaphone", "api_key": "dictaphone_token", "webhook_url": "http://dictaphone-backend.dictaphone.svc.cluster.local/api/v1.0/files/ai-webhook/", "webhook_api_key": "token_summary"}]'
212214
LLM_BASE_URL: https://configure-your-url.com
213215
LLM_API_KEY: your-secret-value
214216
LLM_MODEL: meta-llama/Llama-3.1-8B-Instruct
@@ -231,7 +233,7 @@ celeryTranscribe:
231233
- "--pool=solo"
232234
- "--loglevel=info"
233235
- "-Q"
234-
- "transcribe-queue"
236+
- "transcribe-queue,transcribe-queue-v2"
235237

236238
celerySummarize:
237239
replicas: 1
@@ -247,6 +249,7 @@ celerySummarize:
247249
WHISPERX_BASE_URL: https://configure-your-url.com
248250
WHISPERX_ASR_MODEL: large-v2
249251
WHISPERX_DEFAULT_LANGUAGE: fr
252+
AUTHORIZED_TENANTS: '[{"id": "dictaphone", "api_key": "dictaphone_token", "webhook_url": "http://dictaphone-backend.dictaphone.svc.cluster.local/api/v1.0/files/ai-webhook/", "webhook_api_key": "token_summary"}]'
250253
LLM_BASE_URL: https://configure-your-url.com
251254
LLM_API_KEY: your-secret-value
252255
LLM_MODEL: meta-llama/Llama-3.1-8B-Instruct
@@ -269,7 +272,7 @@ celerySummarize:
269272
- "--pool=solo"
270273
- "--loglevel=info"
271274
- "-Q"
272-
- "summarize-queue"
275+
- "summarize-queue,summarize-queue-v2"
273276

274277
agents:
275278
replicas: 1

src/helm/meet/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ celeryTranscribe:
738738
- "--pool=solo"
739739
- "--loglevel=info"
740740
- "-Q"
741-
- "transcribe-queue"
741+
- "transcribe-queue,transcribe-queue-v2"
742742

743743
## @param celeryTranscribe.args Override the celeryTranscribe container args
744744
args: []
@@ -847,7 +847,7 @@ celerySummarize:
847847
- "--pool=solo"
848848
- "--loglevel=info"
849849
- "-Q"
850-
- "summarize-queue"
850+
- "summarize-queue,summarize-queue-v2"
851851

852852
## @param celerySummarize.args Override the celerySummarize container args
853853
args: []

src/summary/summary/api/main.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
from fastapi import APIRouter, Depends
44

5-
from summary.api.route import tasks
6-
from summary.core.security import verify_token
5+
from summary.api.route import tasks, tasks_v2
6+
from summary.core.security import verify_tenant_api_key
77

8-
api_router = APIRouter(dependencies=[Depends(verify_token)])
9-
api_router.include_router(tasks.router, tags=["tasks"])
8+
api_router_v1 = APIRouter(dependencies=[Depends(verify_tenant_api_key)])
9+
api_router_v1.include_router(tasks.router_tasks_v1, tags=["tasks"])
10+
11+
api_router_v2 = APIRouter(dependencies=[Depends(verify_tenant_api_key)])
12+
api_router_v2.include_router(tasks_v2.router_tasks_v2, tags=["tasks"])

src/summary/summary/api/route/tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def validate_language(cls, v):
4242
return v
4343

4444

45-
router = APIRouter(prefix="/tasks")
45+
router_tasks_v1 = APIRouter(prefix="/tasks")
4646

4747

48-
@router.post("/")
48+
@router_tasks_v1.post("/")
4949
async def create_transcribe_summarize_task(request: TranscribeSummarizeTaskCreation):
5050
"""Create a transcription and summarization task."""
5151
task = process_audio_transcribe_summarize_v2.apply_async(
@@ -68,7 +68,7 @@ async def create_transcribe_summarize_task(request: TranscribeSummarizeTaskCreat
6868
return {"id": task.id, "message": "Task created"}
6969

7070

71-
@router.get("/{task_id}")
71+
@router_tasks_v1.get("/{task_id}")
7272
async def get_task_status(task_id: str):
7373
"""Check task status by ID."""
7474
task = AsyncResult(task_id)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""API routes related to application tasks (V2 / tenant friendly)."""
2+
3+
from celery.result import AsyncResult
4+
from fastapi import APIRouter, Depends, HTTPException
5+
6+
from summary.core.celery_worker import (
7+
process_audio_transcribe_summarize_v2b,
8+
)
9+
from summary.core.config import get_settings
10+
from summary.core.models import TranscribeSummarizeTaskCreationV2Request
11+
from summary.core.security import verify_tenant_api_key
12+
13+
router_tasks_v2 = APIRouter(prefix="/tasks")
14+
settings = get_settings()
15+
16+
17+
@router_tasks_v2.post("/")
18+
async def create_transcribe_summarize_task_v2(
19+
request: TranscribeSummarizeTaskCreationV2Request,
20+
tenant_api_key: str = Depends(verify_tenant_api_key),
21+
):
22+
"""Create a transcription and summarization task."""
23+
request_tenant = settings.get_authorized_tenant(api_key=tenant_api_key)
24+
task = process_audio_transcribe_summarize_v2b.apply_async(
25+
args=[{**request.model_dump(), "tenant_id": request_tenant.id}]
26+
)
27+
28+
return {"id": task.id, "message": "Task created"}
29+
30+
31+
@router_tasks_v2.get("/{task_id}")
32+
async def get_task_status(
33+
task_id: str, tenant_api_key: str = Depends(verify_tenant_api_key)
34+
):
35+
"""Check task status by ID."""
36+
task = AsyncResult(task_id)
37+
38+
request_tenant = settings.get_authorized_tenant(api_key=tenant_api_key)
39+
if isinstance(task.args, list) and len(task.args) > 0:
40+
if task.args[0]["tenant_id"] == request_tenant.id:
41+
return {"id": task_id, "status": task.status}
42+
43+
raise HTTPException(status_code=404, detail="Not found")

0 commit comments

Comments
 (0)