Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,25 +6,18 @@ 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
|
10 |
result = client.predict(
|
11 |
message=message,
|
|
|
12 |
max_tokens=2048,
|
13 |
temperature=0.7,
|
14 |
top_p=0.95,
|
15 |
api_name="/chat"
|
16 |
)
|
17 |
|
18 |
-
#
|
19 |
-
|
20 |
-
history = []
|
21 |
-
|
22 |
-
# Append the current message and response to history as dicts
|
23 |
-
history.append({"role": "user", "message": message})
|
24 |
-
history.append({"role": "assistant", "message": result})
|
25 |
-
|
26 |
-
# Return the response and updated history in the correct format
|
27 |
-
return result, history
|
28 |
|
29 |
# Set up Gradio chat interface
|
30 |
demo = gr.ChatInterface(
|
@@ -35,7 +28,7 @@ demo = gr.ChatInterface(
|
|
35 |
show_progress="full",
|
36 |
flagging_mode="manual",
|
37 |
editable=True,
|
38 |
-
theme="TejAndrewsACC/
|
39 |
)
|
40 |
|
41 |
if __name__ == "__main__":
|
|
|
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 as a dictionary
|
20 |
+
return {"text": result, "history": history + [(message, result)]}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
# Set up Gradio chat interface
|
23 |
demo = gr.ChatInterface(
|
|
|
28 |
show_progress="full",
|
29 |
flagging_mode="manual",
|
30 |
editable=True,
|
31 |
+
theme="TejAndrewsACC/zetaofficalthemeacc"
|
32 |
)
|
33 |
|
34 |
if __name__ == "__main__":
|