mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-04-28 11:49:51 +00:00
Add Native Precision Tutorial, update worker strategy and README.md (#1807)
This commit is contained in:
parent
8652346e69
commit
bf4c8a690b
5 changed files with 308 additions and 2 deletions
|
|
@ -270,6 +270,7 @@ def _stream_response(
|
|||
) -> str:
|
||||
"""Generate streaming response and display in real-time."""
|
||||
response_content = ""
|
||||
reasoning_content = ""
|
||||
|
||||
try:
|
||||
stream = client.chat.completions.create(
|
||||
|
|
@ -281,8 +282,13 @@ def _stream_response(
|
|||
)
|
||||
|
||||
for chunk in stream:
|
||||
if chunk.choices[0].delta.content:
|
||||
content = chunk.choices[0].delta.content
|
||||
delta = chunk.choices[0].delta
|
||||
reasoning_delta = getattr(delta, "reasoning_content", None)
|
||||
if reasoning_delta:
|
||||
reasoning_content += reasoning_delta
|
||||
console.print(reasoning_delta, end="", style="dim")
|
||||
if delta.content:
|
||||
content = delta.content
|
||||
response_content += content
|
||||
console.print(content, end="")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue