TejAndrewsACC commited on
Commit
e122adc
·
verified ·
1 Parent(s): 1dbfd7d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -12
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, but do not pass history here
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
- # Convert history to Gradio's expected format if not already
19
- if history is None:
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/zetaofficialthemeacc"
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__":