Update app/main.py
Browse files- app/main.py +14 -1
app/main.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import os, io, json, re, requests
|
| 2 |
from fastapi import FastAPI, Request, HTTPException, Body, Depends
|
| 3 |
from fastapi.responses import StreamingResponse, RedirectResponse
|
| 4 |
from fastapi.templating import Jinja2Templates
|
|
@@ -51,6 +51,19 @@ def calculate_life_path(date_str: str) -> int:
|
|
| 51 |
async def index(request: Request):
|
| 52 |
return templates.TemplateResponse("dashboard.html", {"request": request})
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
@app.post("/v1/analyze/clinical")
|
| 55 |
async def clinical_analysis(data: BirthDataInput):
|
| 56 |
coords = get_coordinates(data.city, data.state)
|
|
|
|
| 1 |
+
import os, io, json, re, requests, httpx
|
| 2 |
from fastapi import FastAPI, Request, HTTPException, Body, Depends
|
| 3 |
from fastapi.responses import StreamingResponse, RedirectResponse
|
| 4 |
from fastapi.templating import Jinja2Templates
|
|
|
|
| 51 |
async def index(request: Request):
|
| 52 |
return templates.TemplateResponse("dashboard.html", {"request": request})
|
| 53 |
|
| 54 |
+
@app.get("/api/get-signed-url")
|
| 55 |
+
async def get_signed_url():
|
| 56 |
+
ELEVENLABS_API_KEY = os.environ.get("ELEVENLABS_API_KEY")
|
| 57 |
+
AGENT_ID = "agent_4101kfyny563e168da90yze4vva4"
|
| 58 |
+
async with httpx.AsyncClient() as client:
|
| 59 |
+
response = await client.get(
|
| 60 |
+
f"https://api.elevenlabs.io/v1/convai/conversation/get_signed_url?agent_id={AGENT_ID}",
|
| 61 |
+
headers={"xi-api-key": ELEVENLABS_API_KEY}
|
| 62 |
+
)
|
| 63 |
+
if response.status_code != 200:
|
| 64 |
+
raise HTTPException(status_code=500, detail="Failed to get signed URL")
|
| 65 |
+
return response.json()
|
| 66 |
+
|
| 67 |
@app.post("/v1/analyze/clinical")
|
| 68 |
async def clinical_analysis(data: BirthDataInput):
|
| 69 |
coords = get_coordinates(data.city, data.state)
|