Spaces:
Build error
Build error
Update app.py
Browse files
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 |
-
|
|
|
|
| 108 |
feedback_result = gr.Textbox(label="System Response", interactive=False)
|
| 109 |
refresh_button = gr.Button("Refresh Page")
|
| 110 |
|
| 111 |
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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__":
|