AEUPH commited on
Commit
85d50eb
·
verified ·
1 Parent(s): 7bd421d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -0
app.py CHANGED
@@ -60,6 +60,39 @@ def chatbot_api(input_text):
60
  filtered_response = filter_non_alphanumeric(full_content)
61
  send_to_corrade(filtered_response)
62
  return filtered_response
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  # Example usage with Gradio
64
  iface = gr.Interface(fn=chatbot_api, inputs="text", outputs="text")
65
  iface.launch()
 
60
  filtered_response = filter_non_alphanumeric(full_content)
61
  send_to_corrade(filtered_response)
62
  return filtered_response
63
+ def process_menu_selection(data):
64
+ """
65
+ Process the menu selection and return the next set of menu options.
66
+ data: JSON string containing the user's selection and any additional context.
67
+ """
68
+ # Parse the incoming JSON data
69
+ selection_info = json.loads(data)
70
+
71
+ # Example processing logic based on the user's choice
72
+ user_choice = selection_info.get("user_choice", "")
73
+ current_menu = selection_info.get("current_menu", "")
74
+
75
+ # Dynamically generate the next menu based on the user's choice
76
+ if user_choice == "Creativity":
77
+ next_menu = ["Painting", "Writing", "Music"]
78
+ elif user_choice == "Technology":
79
+ next_menu = ["Blockchain", "AI", "VR"]
80
+ else:
81
+ next_menu = ["Back to main menu"]
82
+
83
+ # Optionally, update the current menu context based on the choice
84
+ new_current_menu = user_choice
85
+
86
+ # Package the response as JSON
87
+ response = json.dumps({"nextMenu": next_menu, "currentMenu": new_current_menu})
88
+ return response
89
+
90
+ # Create a Gradio interface for the app
91
+ iface = gr.Interface(fn=process_menu_selection,
92
+ inputs="text",
93
+ outputs="text",
94
+ description="Process menu selections and return the next set of options.")
95
+
96
  # Example usage with Gradio
97
  iface = gr.Interface(fn=chatbot_api, inputs="text", outputs="text")
98
  iface.launch()