File size: 726 Bytes
6e1a53e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from fastapi import APIRouter, Query, responses
from fastapi.responses import StreamingResponse

from utils.embedchain import send_message

router = APIRouter()


@router.get("/api/v1/chat")
async def handle_chat(query: str, session_id: str = Query(None), number_documents: int = 1, citations: bool = True, stream: bool = True, model: str = "mistralai/Mixtral-8x7B-Instruct-v0.1"):
    """
    Handles a chat request to the Embedchain app.
    Accepts 'query' and 'session_id' as query parameters.
    """
    generator = send_message(query, session_id, number_documents, citations, stream, model)
    return StreamingResponse(generator)


@router.get("/")
async def root():
    return responses.RedirectResponse(url="/docs")