Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -64,29 +64,25 @@ def stream_chat(
|
|
64 |
print(f'message: {message}')
|
65 |
print(f'history: {history}')
|
66 |
|
67 |
-
conversation = [
|
68 |
-
{"role": "system", "content": system_prompt}
|
69 |
-
]
|
70 |
for prompt, answer in history:
|
71 |
-
conversation.
|
72 |
-
|
73 |
-
{"role": "assistant", "content": answer},
|
74 |
-
])
|
75 |
|
76 |
-
conversation.append(
|
77 |
|
78 |
-
input_ids = tokenizer
|
79 |
|
80 |
streamer = TextIteratorStreamer(tokenizer, timeout=60.0, skip_prompt=True, skip_special_tokens=True)
|
81 |
|
82 |
generate_kwargs = dict(
|
83 |
input_ids=input_ids,
|
84 |
-
max_new_tokens
|
85 |
-
do_sample
|
86 |
-
top_p
|
87 |
-
top_k
|
88 |
-
temperature
|
89 |
-
eos_token_id=[128001,128008,128009],
|
90 |
streamer=streamer,
|
91 |
)
|
92 |
|
|
|
64 |
print(f'message: {message}')
|
65 |
print(f'history: {history}')
|
66 |
|
67 |
+
conversation = [system_prompt]
|
|
|
|
|
68 |
for prompt, answer in history:
|
69 |
+
conversation.append(prompt)
|
70 |
+
conversation.append(answer)
|
|
|
|
|
71 |
|
72 |
+
conversation.append(message)
|
73 |
|
74 |
+
input_ids = tokenizer(conversation, return_tensors="pt").input_ids.to(model.device)
|
75 |
|
76 |
streamer = TextIteratorStreamer(tokenizer, timeout=60.0, skip_prompt=True, skip_special_tokens=True)
|
77 |
|
78 |
generate_kwargs = dict(
|
79 |
input_ids=input_ids,
|
80 |
+
max_new_tokens=max_new_tokens,
|
81 |
+
do_sample=False if temperature == 0 else True,
|
82 |
+
top_p=top_p,
|
83 |
+
top_k=top_k,
|
84 |
+
temperature=temperature,
|
85 |
+
eos_token_id=[128001, 128008, 128009],
|
86 |
streamer=streamer,
|
87 |
)
|
88 |
|