mirror of
https://github.com/JasonYANG170/CodeGeeX4.git
synced 2024-11-23 12:16:33 +00:00
Update codegeex.py
This commit is contained in:
parent
38342ab02b
commit
7c3cbf6b33
|
@ -39,11 +39,14 @@ class CodegeexChatModel:
|
||||||
"max_new_tokens": request.max_tokens,
|
"max_new_tokens": request.max_tokens,
|
||||||
"temperature": request.temperature,
|
"temperature": request.temperature,
|
||||||
"top_p": request.top_p,
|
"top_p": request.top_p,
|
||||||
"repetition_penalty": request.presence_penalty
|
"repetition_penalty": request.presence_penalty,
|
||||||
|
"do_sample": True if request.temperature else request.temperature,
|
||||||
}
|
}
|
||||||
length = 0
|
length = 0
|
||||||
for i, outputs in enumerate(self.model.stream_generate(**inputs, **gen_configs)):
|
for i, outputs in enumerate(self.model.stream_generate(**inputs, **gen_configs)):
|
||||||
response = self.tokenizer.decode(outputs.tolist()[0][len(inputs["input_ids"][0]):-1])
|
response = self.tokenizer.decode(outputs.tolist()[0][len(inputs["input_ids"][0]):-1])
|
||||||
|
if not response or response[-1] == "<EFBFBD>":
|
||||||
|
continue
|
||||||
resp = ChatCompletionStreamResponse()
|
resp = ChatCompletionStreamResponse()
|
||||||
resp.choices[0].index = i
|
resp.choices[0].index = i
|
||||||
resp.choices[0].delta.content = response[length:]
|
resp.choices[0].delta.content = response[length:]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user