aimanathar commited on
Commit
431d9f7
·
verified ·
1 Parent(s): 7c8d3c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -1,14 +1,25 @@
1
  import gradio as gr
2
  import requests
3
- from openai import OpenAI
4
 
5
- def feedback_bot(question):
6
- # Example static Llama-like response
7
- return f"💬 AI Feedback: That's a great question! Reflect and keep improving!"
8
 
9
- app = gr.Interface(fn=feedback_bot,
10
- inputs=gr.Textbox(label="Ask about your survey"),
11
- outputs="text",
12
- title="Feedback Chatbot")
 
 
 
 
 
 
13
 
14
- app.launch()
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import requests
 
3
 
4
+ API_URL = "https://your-fastapi-url.onrender.com/auto_feedback" # change to your FastAPI deployment URL
 
 
5
 
6
+ def get_feedback(user_input):
7
+ payload = {"message": user_input}
8
+ try:
9
+ res = requests.post(API_URL, json=payload)
10
+ data = res.json()
11
+ ai_msg = data.get("ai_response", "No response received.")
12
+ pulse_status = data.get("pulse_status", "N/A")
13
+ return f"💬 AI Feedback: {ai_msg}\n📡 Pulse API Status: {pulse_status}"
14
+ except Exception as e:
15
+ return f"⚠️ Error: {e}"
16
 
17
+ iface = gr.Interface(
18
+ fn=get_feedback,
19
+ inputs=gr.Textbox(label="Ask about your survey"),
20
+ outputs="text",
21
+ title="Feedback Chatbot",
22
+ description="Get AI-powered feedback and send it to Pulse Survey API automatically.",
23
+ )
24
+
25
+ iface.launch()