-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
53 lines (40 loc) · 1.02 KB
/
main.py
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
# Fastapi
from fastapi import FastAPI
from assistant import Assistant
from pydantic import BaseModel
from fastapi.middleware.cors import CORSMiddleware
import datetime
app = FastAPI(
title="Sayvai-Assistant",
description="A simple assistant to help you with your daily tasks",
version="0.0.1",
)
origins = [
"http://localhost:3000",
"localhost:3000",
"http://localhost:8000",
"localhost:8000",
"http://localhost:8080",
"localhost:8080",
"http://localhost:5000",
"localhost:5000",
]
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
assistant = Assistant()
# print(assistant.initialize_vectordb())
assistant.initialize()
class Item(BaseModel):
query : str
@app.get("/")
def read_root():
return {"Hello": "Welcome to Sayvai-Assistant"}
@app.post("/get_answer")
def get_answer(item: Item):
return {"answer": assistant.get_answer(item.query)}
# uvicorn main:app --reload --port 8000