Niansuh commited on
Commit
7098fc6
·
verified ·
1 Parent(s): 17dfe71

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -38,9 +38,20 @@ def chat_completions():
38
  data = request.get_json()
39
  app.logger.info(f"Received request data: {json.dumps(data, indent=2)}")
40
 
 
 
 
 
 
 
41
  # Prepare the payload for the PizzaGPT API
 
 
 
 
 
42
  payload = {
43
- "question": data['question'] # The user message sent to PizzaGPT
44
  }
45
 
46
  # Send the request to the PizzaGPT API
 
38
  data = request.get_json()
39
  app.logger.info(f"Received request data: {json.dumps(data, indent=2)}")
40
 
41
+ # Extract the 'messages' field from the incoming request
42
+ messages = data.get('messages', [])
43
+
44
+ if not messages:
45
+ raise ValueError("No messages found in the request")
46
+
47
  # Prepare the payload for the PizzaGPT API
48
+ # Assuming the user message is the last item in the 'messages' list
49
+ user_message = messages[-1].get('content', '')
50
+ if not user_message:
51
+ raise ValueError("User message content is empty")
52
+
53
  payload = {
54
+ "question": user_message # Pass the user message as 'question' to PizzaGPT
55
  }
56
 
57
  # Send the request to the PizzaGPT API