File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed
Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ export async function callDeepSeekApi(
9595 let maxAttempts = 5 ;
9696 let attempts = 0 ;
9797
98+
9899 vscode . window . showInformationMessage ( '开始上传DeepSeek API' ) ;
99100
100101 while ( attempts < maxAttempts ) {
@@ -106,6 +107,7 @@ export async function callDeepSeekApi(
106107 max_tokens : 8192 ,
107108 temperature : 0
108109 } ) ;
110+ let thinking = false ;
109111
110112 vscode . window . showInformationMessage ( 'DeepSeek API 正在处理...' ) ;
111113
@@ -118,10 +120,28 @@ export async function callDeepSeekApi(
118120 throw new Error ( userStopException ) ;
119121 }
120122 const content = chunk . choices [ 0 ] ?. delta ?. content || '' ;
123+ const delta = chunk . choices [ 0 ] ?. delta ;
124+ const think = ( 'reasoning_content' in delta ! && delta . reasoning_content ) as string || "" ;
125+
126+ if ( ! thinking && chunkResponse . length === 0 && think . length > 0 ) {
127+ if ( outputChannel ) {
128+ outputChannel . append ( "<think>" ) ;
129+ }
130+ thinking = true ;
131+ }
132+
121133 chunkResponse += content ;
122134 if ( outputChannel ) {
123- outputChannel . append ( content ) ;
135+ outputChannel . append ( content + think ) ;
124136 }
137+
138+ if ( thinking && content . length > 0 ) {
139+ thinking = false ;
140+ if ( outputChannel ) {
141+ outputChannel . append ( "</think>" ) ;
142+ }
143+ }
144+
125145 finishReason = chunk . choices [ 0 ] ?. finish_reason || null ;
126146 }
127147 } else {
You can’t perform that action at this time.
0 commit comments