TejAndrewsACC commited on
Commit
95c63c6
·
verified ·
1 Parent(s): 7e8e8de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -11
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
- result = client.predict(
9
- message="messages",
10
- max_tokens=2048,
11
- temperature=0.7,
12
- top_p=0.95,
13
- api_name="/chat"
14
- )
15
- print(result)
 
 
 
 
 
16
 
17
- demo = gr.ChatInterface(random_response, type="messages", autofocus=False, save_history=True, show_progress="full")
 
 
 
 
 
 
 
 
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()