@@ -14,6 +14,7 @@ export class QwenChatWrapper extends ChatWrapper {
1414
1515 public readonly keepOnlyLastThought : boolean ;
1616 public readonly thoughts : "auto" | "discourage" ;
17+ /** @internal */ private readonly _flatFunctionResultString : boolean ;
1718
1819 public override readonly settings : ChatWrapperSettings ;
1920
@@ -35,18 +36,23 @@ export class QwenChatWrapper extends ChatWrapper {
3536 thoughts ?: "auto" | "discourage" ,
3637
3738 /** @internal */
38- _lineBreakBeforeFunctionCallPrefix ?: boolean
39+ _lineBreakBeforeFunctionCallPrefix ?: boolean ,
40+
41+ /** @internal */
42+ _flatFunctionResultString ?: boolean
3943 } = { } ) {
4044 super ( ) ;
4145
4246 const {
4347 keepOnlyLastThought = true ,
4448 thoughts = "auto" ,
45- _lineBreakBeforeFunctionCallPrefix = false
49+ _lineBreakBeforeFunctionCallPrefix = false ,
50+ _flatFunctionResultString = false
4651 } = options ;
4752
4853 this . keepOnlyLastThought = keepOnlyLastThought ;
4954 this . thoughts = thoughts ;
55+ this . _flatFunctionResultString = _flatFunctionResultString ;
5056
5157 this . settings = {
5258 supportsSystemMessages : true ,
@@ -205,6 +211,13 @@ export class QwenChatWrapper extends ChatWrapper {
205211 } ;
206212 }
207213
214+ public override generateFunctionCallResult ( functionName : string , functionParams : any , result : any ) {
215+ if ( this . _flatFunctionResultString && typeof result === "string" )
216+ return super . _generateFunctionCallResult ( functionName , functionParams , result ) ;
217+
218+ return super . generateFunctionCallResult ( functionName , functionParams , result ) ;
219+ }
220+
208221 public override generateAvailableFunctionsSystemText ( availableFunctions : ChatModelFunctions , { documentParams = true } : {
209222 documentParams ?: boolean
210223 } ) {
@@ -251,7 +264,20 @@ export class QwenChatWrapper extends ChatWrapper {
251264 [ { } , { } , { _requireFunctionCallSettingsExtraction : true } ] ,
252265 [ { _lineBreakBeforeFunctionCallPrefix : true } , { } , { _requireFunctionCallSettingsExtraction : true } ] ,
253266 [ { thoughts : "discourage" } , { } , { _requireFunctionCallSettingsExtraction : true } ] ,
254- [ { thoughts : "discourage" , _lineBreakBeforeFunctionCallPrefix : true } , { } , { _requireFunctionCallSettingsExtraction : true } ]
267+ [ { thoughts : "discourage" , _lineBreakBeforeFunctionCallPrefix : true } , { } , { _requireFunctionCallSettingsExtraction : true } ] ,
268+
269+ [ { _flatFunctionResultString : true } , { } , { _requireFunctionCallSettingsExtraction : true } ] ,
270+ [
271+ { _flatFunctionResultString : true , _lineBreakBeforeFunctionCallPrefix : true } ,
272+ { } ,
273+ { _requireFunctionCallSettingsExtraction : true }
274+ ] ,
275+ [ { _flatFunctionResultString : true , thoughts : "discourage" } , { } , { _requireFunctionCallSettingsExtraction : true } ] ,
276+ [
277+ { _flatFunctionResultString : true , thoughts : "discourage" , _lineBreakBeforeFunctionCallPrefix : true } ,
278+ { } ,
279+ { _requireFunctionCallSettingsExtraction : true }
280+ ]
255281 ] ;
256282 }
257283}
0 commit comments