ccm commited on
Commit
04fe4c4
·
verified ·
1 Parent(s): 6dbf6d3

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -6
main.py CHANGED
@@ -151,13 +151,19 @@ def reply(message: str, history: list[str]) -> str:
151
  message, bypass = preprocess(message)
152
 
153
  # This is some handling that is applied to the history variable to put it in a good format
154
- if isinstance(history, list):
155
- if len(history) > 0:
156
- history = history[-1]
157
- print(history)
 
 
 
 
158
  history_transformer_format = [
159
- {"role": "assistant" if idx & 1 else "user", "content": msg}
160
- for idx, msg in enumerate(history)
 
 
161
  ] + [{"role": "user", "content": message}]
162
 
163
  # Stream a response from pipe
 
151
  message, bypass = preprocess(message)
152
 
153
  # This is some handling that is applied to the history variable to put it in a good format
154
+ # if isinstance(history, list):
155
+ # if len(history) > 0:
156
+ # history = history[-1]
157
+ # print(history)
158
+ # history_transformer_format = [
159
+ # {"role": "assistant" if idx & 1 else "user", "content": msg}
160
+ # for idx, msg in enumerate(history)
161
+ # ] + [{"role": "user", "content": message}]
162
  history_transformer_format = [
163
+ {"role": role, "content": message_pair[idx]}
164
+ for message_pair in history
165
+ for idx, role in enumerate(["user", "assistant"])
166
+ if message_pair[idx] is not None
167
  ] + [{"role": "user", "content": message}]
168
 
169
  # Stream a response from pipe