File size: 1,886 Bytes
ca4ed58
 
 
 
 
1def064
ca4ed58
 
c8c351a
6f6fa04
c8c351a
 
ca4ed58
 
c8c351a
 
 
 
 
 
 
 
6f6fa04
ca4ed58
1def064
 
c8c351a
 
 
 
 
 
1def064
 
 
 
 
6f6fa04
ca4ed58
 
 
 
6f6fa04
ca4ed58
 
 
6f6fa04
 
ca4ed58
 
 
 
 
 
 
 
 
 
 
 
6f6fa04
ca4ed58
 
 
 
 
6f6fa04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# app/main.py
import os
from fastapi import FastAPI
from fastapi import Body
from fastapi import UploadFile, File
from fastapi.middleware.cors import CORSMiddleware
from app.core.orchestrator import process_call
from app.core.ibm_sanity import sanity_embeddings, sanity_generation

from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
import os

app = FastAPI(title="ClaimCheck")

# After creating the FastAPI app
if os.path.exists("static"):
    app.mount("/assets", StaticFiles(directory="static/assets"), name="assets")

    @app.get("/")
    async def serve_frontend():
        return FileResponse("static/index.html")


app.add_middleware(
    CORSMiddleware,
    allow_origins=[
        "http://localhost:5173",
        "http://127.0.0.1:5173",
        "https://huggingface.co",
        "*",  # Or be more specific with your Space URL
    ],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)


@app.get("/health")
def health():
    return {"status": "ok", "service": "ClaimCheck"}


@app.get("/health/ibm")
def health_ibm():
    emb = sanity_embeddings()
    claim = sanity_generation(os.getenv("IBM_CLAIM_MODEL_ID", ""), "Say OK")
    verify = sanity_generation(os.getenv("IBM_VERIFIER_MODEL_ID", ""), "Say OK")
    return {"embeddings": emb, "claim_gen": claim, "verify_gen": verify}


@app.post("/process-transcript")
def process_transcript(text: str = Body(..., embed=True)):
    """
    Accepts raw transcript text and returns a CallReport JSON.
    For now, the orchestrator returns a dummy report (no AI).
    """
    report = process_call(transcript=text)
    return report


@app.post("/process-audio")
async def process_audio(file: UploadFile = File(...)):
    path = f"data/audio/{file.filename}"
    with open(path, "wb") as f:
        f.write(await file.read())
    return process_call(audio_path=path)