redfernstech commited on
Commit
8a42a65
·
verified ·
1 Parent(s): ca916a6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -32
app.py CHANGED
@@ -150,38 +150,7 @@ async def load_chat(request: Request, id: str):
150
  async def load_chat(request: Request, id: str):
151
  return templates.TemplateResponse("voice.html", {"request": request, "user_id": id})
152
 
153
- # Route to save chat history
154
- @app.post("/hist/")
155
- async def save_chat_history(history: dict):
156
- # Check if 'userId' is present in the incoming dictionary
157
- user_id = history.get('userId')
158
- print(user_id)
159
-
160
- # Ensure user_id is defined before proceeding
161
- if user_id is None:
162
- return {"error": "userId is required"}, 400
163
-
164
- # Construct the chat history string
165
- hist = ''.join([f"'{entry['sender']}: {entry['message']}'\n" for entry in history['history']])
166
- hist = "You are a Redfernstech summarize model. Your aim is to use this conversation to identify user interests solely based on that conversation: " + hist
167
- print(hist)
168
-
169
- # Get the summarized result from the client model
170
- result = hist
171
-
172
- return {"summary": result, "message": "Chat history saved"}
173
-
174
- @app.post("/webhook")
175
- async def receive_form_data(request: Request):
176
- form_data = await request.json()
177
- # Generate a unique ID (for tracking user)
178
- unique_id = str(uuid.uuid4())
179
-
180
- # Here you can do something with form_data like saving it to a database
181
- print("Received form data:", form_data)
182
-
183
- # Send back the unique id to the frontend
184
- return JSONResponse({"id": unique_id})
185
 
186
  @app.post("/chat/")
187
  async def chat(request: MessageRequest):
 
150
  async def load_chat(request: Request, id: str):
151
  return templates.TemplateResponse("voice.html", {"request": request, "user_id": id})
152
 
153
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
  @app.post("/chat/")
156
  async def chat(request: MessageRequest):