Skip to content

Commit c4bf8e7

Browse files
committed
update readme
1 parent 54406c7 commit c4bf8e7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ Chat UI界面:
245245
| Qwen-1.5 (0.5B--72B) | qwen ||||||
246246
| Qwen-2 | qwen ||||||
247247
| Qwen-2.5 | qwen ||||||
248-
| Qwen-3 | qwen | × | × || × | × |
248+
| Qwen-3 | qwen | | || | |
249249
| Yi-34B | yi ||||||
250250
| Internlm-1.0 | internlm ||||||
251251
| Internlm-2.0 | internlm ||||||

gpt_server/model_backend/hf_backend.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,15 @@ async def stream_chat(self, params: Dict[str, Any]):
128128
with context_manager:
129129
thread = Thread(target=self.model.generate, kwargs=generation_kwargs)
130130
thread.start()
131-
generated_text = ""
132131
prompt_tokens = len(input_ids.tolist()[0])
133132
completion_tokens = 0
134133
stop_flag = False
135134
try:
135+
current_text = ""
136+
previous_text = ""
137+
previous_token_ids = []
138+
current_token_ids = []
139+
delta_token_ids = []
136140
for new_text in streamer:
137141
for stop_word in stop:
138142
if stop_word in new_text:
@@ -147,15 +151,15 @@ async def stream_chat(self, params: Dict[str, Any]):
147151
)
148152
new_text = new_text[:idx]
149153
break
154+
current_text = current_text + new_text
150155
completion_tokens += 1
151-
generated_text += new_text
152156
usage = {
153157
"prompt_tokens": prompt_tokens,
154158
"completion_tokens": completion_tokens,
155159
"total_tokens": prompt_tokens + completion_tokens,
156160
}
157161
ret = {
158-
"text": generated_text,
162+
"text": new_text,
159163
"error_code": 0,
160164
"usage": usage,
161165
}
@@ -164,6 +168,6 @@ async def stream_chat(self, params: Dict[str, Any]):
164168
break
165169
# 用来解决输出卡顿的问题
166170
await asyncio.sleep(0.02)
167-
logger.info(generated_text)
171+
logger.info(current_text)
168172
except asyncio.CancelledError as e:
169173
stop_specific_token_criteria.stop = True

0 commit comments

Comments
 (0)