Spaces:
Sleeping
Sleeping
Update app.py
Browse filesTry adding field for chat bot id.
app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
-
def send_message_with_secret(message, history, api_secret):
|
5 |
if not api_secret.strip():
|
6 |
return "Please enter your API secret in the field above."
|
7 |
|
@@ -11,10 +11,8 @@ def send_message_with_secret(message, history, api_secret):
|
|
11 |
"Content-Type": "application/json"
|
12 |
}
|
13 |
|
14 |
-
Isabel = "DvuPjXPhNGpdor2JCm8r"
|
15 |
-
|
16 |
payload = {
|
17 |
-
"ai_id":
|
18 |
"message": message
|
19 |
}
|
20 |
|
@@ -26,7 +24,7 @@ def send_message_with_secret(message, history, api_secret):
|
|
26 |
return f"An error occurred: {e}"
|
27 |
|
28 |
with gr.Blocks() as app:
|
29 |
-
gr.Markdown("##
|
30 |
|
31 |
api_secret = gr.Textbox(
|
32 |
label="API Secret",
|
@@ -34,6 +32,12 @@ with gr.Blocks() as app:
|
|
34 |
type="password",
|
35 |
show_label=True
|
36 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
chatbot = gr.Chatbot(
|
39 |
value=[],
|
@@ -51,14 +55,14 @@ with gr.Blocks() as app:
|
|
51 |
if not message:
|
52 |
return chat_history, ""
|
53 |
|
54 |
-
bot_response = send_message_with_secret(message, chat_history, api_secret)
|
55 |
chat_history.append({"role": "user", "content": message})
|
56 |
chat_history.append({"role": "assistant", "content": bot_response})
|
57 |
return chat_history, ""
|
58 |
|
59 |
msg.submit(
|
60 |
respond,
|
61 |
-
inputs=[msg, chatbot, api_secret],
|
62 |
outputs=[chatbot, msg]
|
63 |
)
|
64 |
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
+
def send_message_with_secret(message, history, api_secret, bot_id):
|
5 |
if not api_secret.strip():
|
6 |
return "Please enter your API secret in the field above."
|
7 |
|
|
|
11 |
"Content-Type": "application/json"
|
12 |
}
|
13 |
|
|
|
|
|
14 |
payload = {
|
15 |
+
"ai_id": bot_id,
|
16 |
"message": message
|
17 |
}
|
18 |
|
|
|
24 |
return f"An error occurred: {e}"
|
25 |
|
26 |
with gr.Blocks() as app:
|
27 |
+
gr.Markdown("## Chat with your Kin")
|
28 |
|
29 |
api_secret = gr.Textbox(
|
30 |
label="API Secret",
|
|
|
32 |
type="password",
|
33 |
show_label=True
|
34 |
)
|
35 |
+
|
36 |
+
bot_id = gr.Textbox(
|
37 |
+
label="Bot ID",
|
38 |
+
placeholder="Enter your BotID...",
|
39 |
+
show_label=True
|
40 |
+
)
|
41 |
|
42 |
chatbot = gr.Chatbot(
|
43 |
value=[],
|
|
|
55 |
if not message:
|
56 |
return chat_history, ""
|
57 |
|
58 |
+
bot_response = send_message_with_secret(message, chat_history, api_secret, bot_id)
|
59 |
chat_history.append({"role": "user", "content": message})
|
60 |
chat_history.append({"role": "assistant", "content": bot_response})
|
61 |
return chat_history, ""
|
62 |
|
63 |
msg.submit(
|
64 |
respond,
|
65 |
+
inputs=[msg, chatbot, api_secret, bot_id],
|
66 |
outputs=[chatbot, msg]
|
67 |
)
|
68 |
|