@@ -48,6 +48,7 @@ import { ComputedRef } from 'koishi-plugin-chatluna'
4848let logger : Logger
4949
5050type ParsedResponse = Awaited < ReturnType < typeof parseResponse > >
51+ type RuntimeConfig = Config & ( GuildConfig | PrivateConfig )
5152type StreamedParsedResponseChunk = StreamedModelResponseChunk < ParsedResponse >
5253
5354interface StreamedResponseContentChunk {
@@ -578,7 +579,7 @@ function createReplyTools(
578579 ]
579580}
580581
581- function formatReplyUserPrompt ( session : Session , config : Config ) {
582+ function formatReplyUserPrompt ( session : Session , config : RuntimeConfig ) {
582583 if ( ! config . experimentalToolCallReply || ! config . toolCalling ) {
583584 return ''
584585 }
@@ -911,7 +912,7 @@ function stripInternalTriggerTags(content: string) {
911912async function parseResponseContent (
912913 ctx : Context ,
913914 session : Session ,
914- config : Config ,
915+ config : RuntimeConfig ,
915916 chunk : StreamedResponseContentChunk
916917) : Promise < StreamedParsedResponseChunk > {
917918 let parsedResponse : ParsedResponse
@@ -1033,7 +1034,7 @@ async function* streamAgentResponseContents(
10331034 chain : ChatLunaChain ,
10341035 session : Session ,
10351036 model : ChatLunaChatModel ,
1036- config : Config ,
1037+ config : RuntimeConfig ,
10371038 presetName : string ,
10381039 systemMessage : BaseMessage | undefined ,
10391040 historyMessages : BaseMessage [ ] ,
@@ -1115,7 +1116,7 @@ async function registerResponseTriggers(
11151116 ctx : Context ,
11161117 session : Session ,
11171118 key : string ,
1118- config : Config ,
1119+ config : RuntimeConfig ,
11191120 nextReplyReasons : string [ ] ,
11201121 wakeUpReplies : ReturnType < typeof extractWakeUpReplies >
11211122) {
@@ -1263,18 +1264,25 @@ async function getConfigAndPresetForGuild(
12631264 presetPool : Record < string , PresetTemplate > ,
12641265 key : string ,
12651266 preset : Preset
1266- ) : Promise < { copyOfConfig : Config ; currentPreset : PresetTemplate } > {
1267+ ) : Promise < { copyOfConfig : RuntimeConfig ; currentPreset : PresetTemplate } > {
12671268 const globalConfig = isDirect
12681269 ? config . globalPrivateConfig
12691270 : config . globalGroupConfig
12701271 const currentGuildConfig = isDirect
12711272 ? config . privateConfigs [ guildId ]
12721273 : config . configs [ guildId ]
1273- let copyOfConfig = Object . assign ( { } , config , globalConfig )
1274+ let copyOfConfig = Object . assign ( { } , config , globalConfig , {
1275+ experimentalToolCallReply :
1276+ globalConfig . experimentalToolCallReply === true
1277+ } ) as RuntimeConfig
12741278 let currentPreset = isDirect ? globalPrivatePreset : globalGroupPreset
12751279
12761280 if ( currentGuildConfig ) {
1277- copyOfConfig = Object . assign ( { } , copyOfConfig , currentGuildConfig )
1281+ copyOfConfig = Object . assign (
1282+ { } ,
1283+ copyOfConfig ,
1284+ currentGuildConfig
1285+ ) as RuntimeConfig
12781286 currentPreset =
12791287 presetPool [ key ] ??
12801288 ( await ( async ( ) => {
@@ -1296,7 +1304,7 @@ async function getConfigAndPresetForGuild(
12961304async function prepareMessages (
12971305 ctx : Context ,
12981306 messages : Message [ ] ,
1299- config : Config ,
1307+ config : RuntimeConfig ,
13001308 session : Session ,
13011309 model : ChatLunaChatModel ,
13021310 currentPreset : PresetTemplate ,
@@ -1526,7 +1534,7 @@ async function* streamModelResponse(
15261534 session : Session ,
15271535 model : ChatLunaChatModel ,
15281536 completionMessages : BaseMessage [ ] ,
1529- config : Config ,
1537+ config : RuntimeConfig ,
15301538 presetName : string ,
15311539 chain ?: ChatLunaChain ,
15321540 signal ?: AbortSignal ,
@@ -1648,7 +1656,7 @@ async function handleMessageSending(
16481656 elements : h [ ] ,
16491657 text : string ,
16501658 parsedResponse : Awaited < ReturnType < typeof parseResponse > > ,
1651- config : Config ,
1659+ config : RuntimeConfig ,
16521660 ctx : Context ,
16531661 maxTime : number ,
16541662 emoticonStatement : string ,
@@ -1727,7 +1735,7 @@ async function handleMessageSending(
17271735
17281736async function handleParsedResponseChunk (
17291737 session : Session ,
1730- config : Config ,
1738+ config : RuntimeConfig ,
17311739 ctx : Context ,
17321740 parsedResponse : ParsedResponse
17331741) : Promise < {
0 commit comments