Rahatara commited on
Commit
0e47631
Β·
verified Β·
1 Parent(s): bf4276d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -28,7 +28,7 @@ predefined_prompts = [
28
  "Damaged railway platform"
29
  ]
30
 
31
- def ask_rail_defect_question(question, model_name='gpt-3.5-turbo'):
32
  response = openai.ChatCompletion.create(
33
  model=model_name,
34
  messages=[
@@ -104,12 +104,21 @@ with gr.Blocks() as app:
104
  )
105
 
106
  feedback_input = gr.Textbox(label="Enter your feedback", placeholder="Write your feedback here...")
107
- feedback_button = gr.Button("Submit Feedback")
 
108
  feedback_result = gr.Textbox(label="System Response", interactive=False)
109
  refresh_button = gr.Button("Refresh Page")
110
 
111
 
112
- feedback_button.click(lambda x: ask_rail_defect_question(x), inputs=feedback_input, outputs=feedback_result)
 
 
 
 
 
 
 
 
113
  refresh_button.click(lambda: gr.update(reload_browser=True))
114
 
115
  if __name__ == "__main__":
 
28
  "Damaged railway platform"
29
  ]
30
 
31
+ def ask_rail_defect_question(question, model_name='ft:gpt-3.5-turbo-0125:personal::99NsSAeQ'):
32
  response = openai.ChatCompletion.create(
33
  model=model_name,
34
  messages=[
 
104
  )
105
 
106
  feedback_input = gr.Textbox(label="Enter your feedback", placeholder="Write your feedback here...")
107
+ like_button = gr.Button(value="πŸ‘ Like")
108
+ dislike_button = gr.Button(value="πŸ‘Ž Dislike")
109
  feedback_result = gr.Textbox(label="System Response", interactive=False)
110
  refresh_button = gr.Button("Refresh Page")
111
 
112
 
113
+ def handle_feedback(feedback, sentiment):
114
+ analysis = ask_rail_defect_question(feedback)
115
+ if sentiment == "πŸ‘ Like":
116
+ return f"Thank you for your positive feedback! Your feedback: '{feedback}' was analyzed as: '{analysis}'. We are updating our system based on your feedback."
117
+ else:
118
+ return f"We're sorry to hear that. Your feedback: '{feedback}' was analyzed as: '{analysis}'. We are updating our system based on your feedback."
119
+
120
+ like_button.click(lambda x: handle_feedback(x, "πŸ‘ Like"), inputs=feedback_input, outputs=feedback_result)
121
+ dislike_button.click(lambda x: handle_feedback(x, "πŸ‘Ž Dislike"), inputs=feedback_input, outputs=feedback_result)
122
  refresh_button.click(lambda: gr.update(reload_browser=True))
123
 
124
  if __name__ == "__main__":