expandme commited on
Commit
561eefd
1 Parent(s): 5d478c9

Updating from Tuplets to Messages to remove wrning ? - What wind.surf will do ?

Browse files
Files changed (1) hide show
  1. app.py +15 -6
app.py CHANGED
@@ -37,7 +37,7 @@ current_model = load_model(list(MODELS.keys())[0])
37
 
38
  def respond(
39
  message,
40
- history: list[tuple[str, str]],
41
  model_name,
42
  system_message,
43
  max_tokens,
@@ -52,11 +52,15 @@ def respond(
52
 
53
  messages = [{"role": "system", "content": system_message}]
54
 
55
- for val in history:
56
- if val[0]:
57
- messages.append({"role": "user", "content": val[0]})
58
- if val[1]:
59
- messages.append({"role": "assistant", "content": val[1]})
 
 
 
 
60
 
61
  messages.append({"role": "user", "content": message})
62
 
@@ -103,6 +107,11 @@ demo = gr.ChatInterface(
103
  label="Top-p (nucleus sampling)",
104
  ),
105
  ],
 
 
 
 
 
106
  theme=gr.themes.Soft(
107
  primary_hue="blue",
108
  secondary_hue="purple",
 
37
 
38
  def respond(
39
  message,
40
+ history,
41
  model_name,
42
  system_message,
43
  max_tokens,
 
52
 
53
  messages = [{"role": "system", "content": system_message}]
54
 
55
+ # Convert history to messages format
56
+ for msg in history:
57
+ if isinstance(msg, tuple):
58
+ if msg[0]:
59
+ messages.append({"role": "user", "content": msg[0]})
60
+ if msg[1]:
61
+ messages.append({"role": "assistant", "content": msg[1]})
62
+ else:
63
+ messages.append(msg)
64
 
65
  messages.append({"role": "user", "content": message})
66
 
 
107
  label="Top-p (nucleus sampling)",
108
  ),
109
  ],
110
+ chatbot=gr.Chatbot(
111
+ value=[],
112
+ type="messages",
113
+ label="Chat Messages"
114
+ ),
115
  theme=gr.themes.Soft(
116
  primary_hue="blue",
117
  secondary_hue="purple",