Rauhan commited on
Commit
cfd2b5e
·
1 Parent(s): 40d15f0

UPDATE: QDRANT

Browse files
Files changed (1) hide show
  1. app.py +36 -68
app.py CHANGED
@@ -16,29 +16,20 @@ app.add_middleware(
16
 
17
  @app.post("/signup")
18
  async def signup(username: str, password: str):
19
- try:
20
- response = createUser(username = username, password = password)
21
- output = {
22
- "output": response
23
- }
24
- except Exception as e:
25
- output = {
26
- "error": e
27
- }
28
  return output
29
 
30
 
31
  @app.post("/login")
32
  async def login(username: str, password: str):
33
- try:
34
- response = matchPassword(username = username, password = password)
35
- output = {
36
- "output": response
37
- }
38
- except Exception as e:
39
- output = {
40
- "error": e
41
- }
42
  return output
43
 
44
 
@@ -52,20 +43,16 @@ async def newChatbot(chatbotName: str):
52
 
53
  @app.post("/addPDF")
54
  async def addPDFData(vectorstore: str, pdf: UploadFile = File(...)):
55
- try:
56
- pdf = await pdf.read()
57
- reader = PdfReader(io.BytesIO(pdf))
58
- text = ""
59
- for page in reader.pages:
60
- text += page.extract_text()
61
- addDocuments(text = text, vectorstore = vectorstore)
62
- output = {
63
- "output": "SUCCESS"
64
- }
65
- except Exception as e:
66
- output = {
67
- "error": e
68
- }
69
  return output
70
 
71
 
@@ -73,54 +60,35 @@ async def addPDFData(vectorstore: str, pdf: UploadFile = File(...)):
73
  @app.post("/addText")
74
  async def addText(vectorstore: str, text: str):
75
  addDocuments(text = text, vectorstore = vectorstore)
76
- try:
77
- output = {
78
- "output": "SUCCESS"
79
- }
80
- return output
81
- except Exception as e:
82
- output = {
83
- "error": e
84
- }
85
  return output
86
 
87
 
88
  @app.get("/answerQuery")
89
  async def answerQuestion(query: str, vectorstore: str, llmModel: str = "llama3-70b-8192"):
90
- try:
91
- response = answerQuery(query=query, vectorstore=vectorstore, llmModel=llmModel)
92
- output = {
93
- "output": response
94
- }
95
- except Exception as e:
96
- output = {
97
- "error": e
98
- }
99
  return output
100
 
101
  @app.get("/deleteChatbot/{chatbotName}")
102
  async def delete(chatbotName: str):
103
- try:
104
- deleteTable(tableName=chatbotName)
105
- response = {
106
- "output": "SUCCESS"
107
- }
108
- except Exception as e:
109
- response = {
110
- "output": e
111
- }
112
  return response
113
 
114
 
115
  @app.get("/listChatbots/{username}")
116
  async def delete(username: str):
117
- try:
118
- chatbots = listTables(username=username)
119
- response = {
120
- "output": chatbots
121
- }
122
- except Exception as e:
123
- response = {
124
- "output": e
125
- }
126
  return response
 
16
 
17
  @app.post("/signup")
18
  async def signup(username: str, password: str):
19
+ response = createUser(username = username, password = password)
20
+ output = {
21
+ "output": response
22
+ }
23
+
 
 
 
 
24
  return output
25
 
26
 
27
  @app.post("/login")
28
  async def login(username: str, password: str):
29
+ response = matchPassword(username = username, password = password)
30
+ output = {
31
+ "output": response
32
+ }
 
 
 
 
 
33
  return output
34
 
35
 
 
43
 
44
  @app.post("/addPDF")
45
  async def addPDFData(vectorstore: str, pdf: UploadFile = File(...)):
46
+ pdf = await pdf.read()
47
+ reader = PdfReader(io.BytesIO(pdf))
48
+ text = ""
49
+ for page in reader.pages:
50
+ text += page.extract_text()
51
+ addDocuments(text = text, vectorstore = vectorstore)
52
+ output = {
53
+ "output": "SUCCESS"
54
+ }
55
+
 
 
 
 
56
  return output
57
 
58
 
 
60
  @app.post("/addText")
61
  async def addText(vectorstore: str, text: str):
62
  addDocuments(text = text, vectorstore = vectorstore)
63
+ output = {
64
+ "output": "SUCCESS"
65
+ }
 
 
 
 
 
 
66
  return output
67
 
68
 
69
  @app.get("/answerQuery")
70
  async def answerQuestion(query: str, vectorstore: str, llmModel: str = "llama3-70b-8192"):
71
+ response = answerQuery(query=query, vectorstore=vectorstore, llmModel=llmModel)
72
+ output = {
73
+ "output": response
74
+ }
75
+
 
 
 
 
76
  return output
77
 
78
  @app.get("/deleteChatbot/{chatbotName}")
79
  async def delete(chatbotName: str):
80
+ deleteTable(tableName=chatbotName)
81
+ response = {
82
+ "output": "SUCCESS"
83
+ }
 
 
 
 
 
84
  return response
85
 
86
 
87
  @app.get("/listChatbots/{username}")
88
  async def delete(username: str):
89
+ chatbots = listTables(username=username)
90
+ response = {
91
+ "output": chatbots
92
+ }
93
+
 
 
 
 
94
  return response