Spaces:
Running
Running
Commit
·
1304d8f
1
Parent(s):
73fa05f
added feedback system
Browse files- .gitignore +1 -0
- app.py +18 -0
.gitignore
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
#custom
|
|
|
2 |
.env
|
3 |
*.pdf
|
4 |
app copy.py
|
|
|
1 |
#custom
|
2 |
+
report endpoint for flagging bit response
|
3 |
.env
|
4 |
*.pdf
|
5 |
app copy.py
|
app.py
CHANGED
@@ -46,6 +46,10 @@ class ChatResponse(BaseModel):
|
|
46 |
response: str
|
47 |
conversation: List[Message]
|
48 |
|
|
|
|
|
|
|
|
|
49 |
# Initialize conversation and model
|
50 |
conversation_bot = []
|
51 |
conversation = initialize_conversation()
|
@@ -134,6 +138,20 @@ async def process_voice(audio_file: UploadFile = File(...), dependencies=[Depend
|
|
134 |
|
135 |
except Exception as e:
|
136 |
return {"error": f"Error processing voice input: {str(e)}"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
# Reset conversation endpoint
|
139 |
@app.post("/reset", dependencies=[Depends(verify_api_key)])
|
|
|
46 |
response: str
|
47 |
conversation: List[Message]
|
48 |
|
49 |
+
class Feedback(BaseModel):
|
50 |
+
message: str
|
51 |
+
is_positive: bool
|
52 |
+
|
53 |
# Initialize conversation and model
|
54 |
conversation_bot = []
|
55 |
conversation = initialize_conversation()
|
|
|
138 |
|
139 |
except Exception as e:
|
140 |
return {"error": f"Error processing voice input: {str(e)}"}
|
141 |
+
|
142 |
+
@app.post("/feedback")
|
143 |
+
async def handle_feedback(
|
144 |
+
request: Feedback,
|
145 |
+
dependencies=[Depends(verify_api_key)]
|
146 |
+
):
|
147 |
+
# if x_api_key != VALID_API_KEY:
|
148 |
+
# raise HTTPException(status_code=403, detail="Invalid API key")
|
149 |
+
|
150 |
+
# Here you can store the feedback in your database
|
151 |
+
# For example:
|
152 |
+
# await db.store_feedback(message, is_positive)
|
153 |
+
|
154 |
+
return {"status": "success"}
|
155 |
|
156 |
# Reset conversation endpoint
|
157 |
@app.post("/reset", dependencies=[Depends(verify_api_key)])
|