mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2026-08-26 15:15:16 +02:00
fixed a bug in chat completions think handling
This commit is contained in:
+12
-10
@@ -4567,16 +4567,18 @@ class KcppServerRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
delta = {'role': 'assistant'}
|
||||
if genparams.get('encapsulate_thinking', True):
|
||||
if encap_in_thinking:
|
||||
# We are already inside a thinking block. thinkpairs has already been reduced to [pair], so we just check the active one.
|
||||
active_pair = thinkpairs[0]
|
||||
if active_pair["end"] in tokenStr:
|
||||
encap_in_thinking = False
|
||||
out1, out2 = tokenStr.split(active_pair["end"], 1)
|
||||
if out1:
|
||||
delta['reasoning_content'] = out1
|
||||
if out2:
|
||||
delta['content'] = out2
|
||||
else:
|
||||
foundend = False
|
||||
for pair in thinkpairs:
|
||||
if pair["end"] in tokenStr:
|
||||
encap_in_thinking = False
|
||||
foundend = True
|
||||
out1, out2 = tokenStr.split(pair["end"], 1)
|
||||
if out1:
|
||||
delta['reasoning_content'] = out1
|
||||
if out2:
|
||||
delta['content'] = out2
|
||||
break
|
||||
if not foundend:
|
||||
# Still thinking
|
||||
delta['reasoning_content'] = tokenStr
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user