forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathagents.py
More file actions
24 lines (18 loc) · 1.07 KB
/
Copy pathagents.py
File metadata and controls
24 lines (18 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from fastapi import APIRouter
from fastapi import Request, HTTPException
from models import shared
from models import task
from utils.conversations.process_conversation import process_user_expression_measurement_callback
from utils.other import hume
router = APIRouter()
@router.post('/v1/agents/hume/callback', response_model=shared.EmptyResponse, tags=['agent', 'hume', 'callback'])
def hume_expression_measurement_callback(request: Request, data: dict):
# body untyped: external Hume AI webhook payload, forwarded wholesale to HumeJobCallbackModel.from_dict
# which defensively parses an arbitrarily-nested prosody predictions structure. Modeling it would
# duplicate Hume's API schema with no validation benefit since from_dict is the real parser.
job_callback = hume.HumeJobCallbackModel.from_dict("prosody", data)
if job_callback is None:
raise HTTPException(status_code=400, detail="Job callback is invalid")
process_user_expression_measurement_callback(task.TaskActionProvider.HUME, job_callback.job_id, job_callback)
# Empty response
return {}