Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,18 +3,31 @@ import gradio as gr
|
|
3 |
from gradio_client import Client
|
4 |
|
5 |
def random_response(message, history):
|
6 |
-
|
7 |
-
client = Client("TejAndrewsACC/Z3taACC-Plus")
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
if __name__ == "__main__":
|
20 |
demo.launch()
|
|
|
3 |
from gradio_client import Client
|
4 |
|
5 |
def random_response(message, history):
|
6 |
+
# Creating a persistent chat session with history for each user chat.
|
7 |
+
client = Client("TejAndrewsACC/Z3taACC-Plus")
|
8 |
+
|
9 |
+
# Make API call to chat with message and previous history
|
10 |
+
result = client.predict(
|
11 |
+
message=message,
|
12 |
+
history=history,
|
13 |
+
max_tokens=2048,
|
14 |
+
temperature=0.7,
|
15 |
+
top_p=0.95,
|
16 |
+
api_name="/chat"
|
17 |
+
)
|
18 |
+
|
19 |
+
# Return the response and updated history
|
20 |
+
return result, history + [(message, result)] # Append the current message and response to history
|
21 |
|
22 |
+
# Set up Gradio chat interface
|
23 |
+
demo = gr.ChatInterface(
|
24 |
+
fn=random_response,
|
25 |
+
type="messages",
|
26 |
+
autofocus=False,
|
27 |
+
save_history=True,
|
28 |
+
show_progress="full",
|
29 |
+
theme="TejAndrewsACC/zetaofficialthemeacc"
|
30 |
+
)
|
31 |
|
32 |
if __name__ == "__main__":
|
33 |
demo.launch()
|