Spaces:
Sleeping
Sleeping
refactor setup_chatbot_select_button
Browse files
app.py
CHANGED
|
@@ -3093,47 +3093,63 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
| 3093 |
ai_chatbot_ai_type,
|
| 3094 |
ai_chatbot_thread_id
|
| 3095 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3096 |
|
| 3097 |
-
chatbot_open_ai_select_btn.click(
|
| 3098 |
-
chatbot_select,
|
| 3099 |
-
inputs=[chatbot_open_ai_name],
|
| 3100 |
-
outputs=chatbot_select_outputs
|
| 3101 |
-
).then(
|
| 3102 |
-
update_avatar_images,
|
| 3103 |
-
inputs=[vaitor_chatbot_avatar_images, vaitor_chatbot_description_value],
|
| 3104 |
-
outputs=[ai_chatbot],
|
| 3105 |
-
scroll_to_output=True
|
| 3106 |
-
)
|
| 3107 |
-
foxcat_chatbot_select_btn.click(
|
| 3108 |
-
chatbot_select,
|
| 3109 |
-
inputs=[foxcat_chatbot_name],
|
| 3110 |
-
outputs=chatbot_select_outputs
|
| 3111 |
-
).then(
|
| 3112 |
-
update_avatar_images,
|
| 3113 |
-
inputs=[foxcat_avatar_images, foxcat_chatbot_description_value],
|
| 3114 |
-
outputs=[ai_chatbot],
|
| 3115 |
-
scroll_to_output=True
|
| 3116 |
-
)
|
| 3117 |
-
lili_chatbot_select_btn.click(
|
| 3118 |
-
chatbot_select,
|
| 3119 |
-
inputs=[lili_chatbot_name],
|
| 3120 |
-
outputs=chatbot_select_outputs
|
| 3121 |
-
).then(
|
| 3122 |
-
update_avatar_images,
|
| 3123 |
-
inputs=[lili_avatar_images, lili_chatbot_description_value],
|
| 3124 |
-
outputs=[ai_chatbot],
|
| 3125 |
-
scroll_to_output=True
|
| 3126 |
-
)
|
| 3127 |
-
maimai_chatbot_select_btn.click(
|
| 3128 |
-
chatbot_select,
|
| 3129 |
-
inputs=[maimai_chatbot_name],
|
| 3130 |
-
outputs=chatbot_select_outputs
|
| 3131 |
-
).then(
|
| 3132 |
-
update_avatar_images,
|
| 3133 |
-
inputs=[maimai_avatar_images, maimai_chatbot_description_value],
|
| 3134 |
-
outputs=[ai_chatbot],
|
| 3135 |
-
scroll_to_output=True
|
| 3136 |
-
)
|
| 3137 |
# STREAMING CHATBOT SELECT
|
| 3138 |
chatbot_open_ai_streaming_select_btn.click(
|
| 3139 |
chatbot_select,
|
|
@@ -3191,16 +3207,12 @@ with gr.Blocks(theme=gr.themes.Base(primary_hue=gr.themes.colors.orange, seconda
|
|
| 3191 |
inputs=[password, df_string_output],
|
| 3192 |
outputs=question_buttons
|
| 3193 |
)
|
| 3194 |
-
|
| 3195 |
ai_chatbot_audio_input.change(
|
| 3196 |
process_open_ai_audio_to_chatbot,
|
| 3197 |
inputs=[password, ai_chatbot_audio_input],
|
| 3198 |
outputs=[ai_msg]
|
| 3199 |
)
|
| 3200 |
|
| 3201 |
-
# file_upload.change(process_file, inputs=file_upload, outputs=df_string_output)
|
| 3202 |
-
# file_upload.change(process_file, inputs=file_upload, outputs=[btn_1, btn_2, btn_3, df_summarise, df_string_output])
|
| 3203 |
-
|
| 3204 |
# 当输入 YouTube 链接时触发
|
| 3205 |
process_youtube_link_inputs = [password, youtube_link]
|
| 3206 |
process_youtube_link_outputs = [
|
|
|
|
| 3093 |
ai_chatbot_ai_type,
|
| 3094 |
ai_chatbot_thread_id
|
| 3095 |
]
|
| 3096 |
+
# 聊天机器人的配置数据
|
| 3097 |
+
chatbots = [
|
| 3098 |
+
{
|
| 3099 |
+
"button": chatbot_open_ai_select_btn,
|
| 3100 |
+
"name_state": chatbot_open_ai_name,
|
| 3101 |
+
"avatar_images": vaitor_chatbot_avatar_images,
|
| 3102 |
+
"description_value": vaitor_chatbot_description_value,
|
| 3103 |
+
"chatbot_select_outputs": chatbot_select_outputs,
|
| 3104 |
+
"chatbot_output": ai_chatbot
|
| 3105 |
+
},
|
| 3106 |
+
{
|
| 3107 |
+
"button": foxcat_chatbot_select_btn,
|
| 3108 |
+
"name_state": foxcat_chatbot_name,
|
| 3109 |
+
"avatar_images": foxcat_avatar_images,
|
| 3110 |
+
"description_value": foxcat_chatbot_description_value,
|
| 3111 |
+
"chatbot_select_outputs": chatbot_select_outputs,
|
| 3112 |
+
"chatbot_output": ai_chatbot
|
| 3113 |
+
},
|
| 3114 |
+
{
|
| 3115 |
+
"button": lili_chatbot_select_btn,
|
| 3116 |
+
"name_state": lili_chatbot_name,
|
| 3117 |
+
"avatar_images": lili_avatar_images,
|
| 3118 |
+
"description_value": lili_chatbot_description_value,
|
| 3119 |
+
"chatbot_select_outputs": chatbot_select_outputs,
|
| 3120 |
+
"chatbot_output": ai_chatbot
|
| 3121 |
+
},
|
| 3122 |
+
{
|
| 3123 |
+
"button": maimai_chatbot_select_btn,
|
| 3124 |
+
"name_state": maimai_chatbot_name,
|
| 3125 |
+
"avatar_images": maimai_avatar_images,
|
| 3126 |
+
"description_value": maimai_chatbot_description_value,
|
| 3127 |
+
"chatbot_select_outputs": chatbot_select_outputs,
|
| 3128 |
+
"chatbot_output": ai_chatbot
|
| 3129 |
+
}
|
| 3130 |
+
]
|
| 3131 |
+
|
| 3132 |
+
def setup_chatbot_select_button(chatbot_dict):
|
| 3133 |
+
button = chatbot_dict["button"]
|
| 3134 |
+
chatbot_name_state = chatbot_dict["name_state"]
|
| 3135 |
+
avatar_images = chatbot_dict["avatar_images"]
|
| 3136 |
+
description_value = chatbot_dict["description_value"]
|
| 3137 |
+
chatbot_select_outputs = chatbot_dict["chatbot_select_outputs"]
|
| 3138 |
+
chatbot_output = chatbot_dict["chatbot_output"]
|
| 3139 |
+
button.click(
|
| 3140 |
+
chatbot_select, # 你可能需要修改这个函数以适应当前的逻辑
|
| 3141 |
+
inputs=[chatbot_name_state],
|
| 3142 |
+
outputs=chatbot_select_outputs
|
| 3143 |
+
).then(
|
| 3144 |
+
update_avatar_images,
|
| 3145 |
+
inputs=[avatar_images, description_value],
|
| 3146 |
+
outputs=[chatbot_output],
|
| 3147 |
+
scroll_to_output=True
|
| 3148 |
+
)
|
| 3149 |
+
|
| 3150 |
+
for chatbot_dict in chatbots:
|
| 3151 |
+
setup_chatbot_select_button(chatbot_dict)
|
| 3152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3153 |
# STREAMING CHATBOT SELECT
|
| 3154 |
chatbot_open_ai_streaming_select_btn.click(
|
| 3155 |
chatbot_select,
|
|
|
|
| 3207 |
inputs=[password, df_string_output],
|
| 3208 |
outputs=question_buttons
|
| 3209 |
)
|
|
|
|
| 3210 |
ai_chatbot_audio_input.change(
|
| 3211 |
process_open_ai_audio_to_chatbot,
|
| 3212 |
inputs=[password, ai_chatbot_audio_input],
|
| 3213 |
outputs=[ai_msg]
|
| 3214 |
)
|
| 3215 |
|
|
|
|
|
|
|
|
|
|
| 3216 |
# 当输入 YouTube 链接时触发
|
| 3217 |
process_youtube_link_inputs = [password, youtube_link]
|
| 3218 |
process_youtube_link_outputs = [
|