@agentica/chat 0.16.6 → 0.16.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{VendorConfigurationMovie-BmSWtiom.js → VendorConfigurationMovie-fM6ylLiv.js} +5 -5
- package/dist/assets/bbs/{index-DmTo8qNq.js → index-CATTYv-V.js} +1 -1
- package/dist/assets/shopping/{index.html-DZ0R32fZ.js → index.html-DDJlXIXd.js} +1 -1
- package/dist/assets/uploader/{index.html-BgNMtg3M.js → index.html-YJql3SE6.js} +1 -1
- package/dist/bbs/index.html +2 -2
- package/dist/shopping/index.html +2 -2
- package/dist/uploader/index.html +2 -2
- package/package.json +2 -2
package/dist/assets/{VendorConfigurationMovie-BmSWtiom.js → VendorConfigurationMovie-fM6ylLiv.js}
RENAMED
|
@@ -86,7 +86,7 @@ Use the supplied tools to select some functions of \`getApiFunctions()\` returne
|
|
|
86
86
|
|
|
87
87
|
When selecting functions to call, pay attention to the relationship between functions. In particular, check the prerequisites between each function.
|
|
88
88
|
|
|
89
|
-
If you can't find any proper function to select, just type your own message. By the way, when typing your own message, please consider the user's language locale code. If your message is different with the user's language, please translate it to the user's.`};var OMn={};const NMn=new ejt(()=>{const o=h=>typeof h=="object"&&h!==null;return typeof global=="object"&&o(global)&&o(global.process)&&o(global.process.versions)&&typeof global.process.versions.node<"u"}),PMn=new ejt(()=>{var o;return NMn.get()?((o=OMn.LANG)==null?void 0:o.split(".")[0])??"en-US":navigator.language}),LMn=new ejt(()=>Intl.DateTimeFormat().resolvedOptions().timeZone);function MMn(o){var k;if(((k=o==null?void 0:o.systemPrompt)==null?void 0:k.common)!==void 0)return o.systemPrompt.common(o);const h=(o==null?void 0:o.locale)??PMn.get(),m=(o==null?void 0:o.timezone)??LMn.get();return eP.COMMON.replace("${locale}",h).replace("${timezone}",m).replace("${datetime}",new Date().toISOString())}const Gj={write:MMn};function DMn(o){return typeof o.initialize=="function"}function qj(o){return{operation:o.operation,reason:o.reason,toJSON:()=>({operation:o.operation.toJSON(),reason:o.reason})}}var njt={};Object.defineProperty(njt,"__esModule",{value:!0});var nP=njt._validateReport=void 0;const RMn=o=>{const h=m=>{if(o.length===0)return!0;const k=o[o.length-1].path;return m.length>k.length||k.substring(0,m.length)!==m};return(m,k)=>(m&&h(k.path)&&o.push(k),!1)};nP=njt._validateReport=RMn;var lBt;(o=>{function h(m){return new TextDecoder().decode(m)}o.toUtf8=h})(lBt||(lBt={}));function S7e(o,h){return{accepted_prediction_tokens:(o.accepted_prediction_tokens??0)+(h.accepted_prediction_tokens??0),reasoning_tokens:(o.reasoning_tokens??0)+(h.reasoning_tokens??0),rejected_prediction_tokens:(o.rejected_prediction_tokens??0)+(h.rejected_prediction_tokens??0)}}function I7e(o,h){return{audio_tokens:(o.audio_tokens??0)+(h.audio_tokens??0),cached_tokens:(o.cached_tokens??0)+(h.cached_tokens??0)}}function BMn(o,h){return{prompt_tokens:(o.prompt_tokens??0)+(h.prompt_tokens??0),completion_tokens:(o.completion_tokens??0)+(h.completion_tokens??0),total_tokens:(o.total_tokens??0)+(h.total_tokens??0),completion_tokens_details:S7e(o.completion_tokens_details??{accepted_prediction_tokens:0,reasoning_tokens:0,rejected_prediction_tokens:0},h.completion_tokens_details??{accepted_prediction_tokens:0,reasoning_tokens:0,rejected_prediction_tokens:0}),prompt_tokens_details:I7e(o.prompt_tokens_details??{audio_tokens:0,cached_tokens:0},h.prompt_tokens_details??{audio_tokens:0,cached_tokens:0})}}const jMn={sum:BMn,sumCompletionTokenDetail:S7e,sumPromptTokenDetail:I7e};function FMn(o){const h=o instanceof Uint8Array?lBt.toUtf8(o):o,m=JSON.parse(h),k=(()=>{const O=Vt=>typeof Vt.id=="string"&&Array.isArray(Vt.choices)&&Vt.choices.every(Ye=>typeof Ye=="object"&&Ye!==null&&P(Ye))&&typeof Vt.created=="number"&&typeof Vt.model=="string"&&Vt.object==="chat.completion.chunk"&&(Vt.service_tier===null||Vt.service_tier===void 0||Vt.service_tier==="scale"||Vt.service_tier==="default")&&(Vt.system_fingerprint===void 0||typeof Vt.system_fingerprint=="string")&&(Vt.usage===null||Vt.usage===void 0||typeof Vt.usage=="object"&&Vt.usage!==null&&st(Vt.usage)),P=Vt=>typeof Vt.delta=="object"&&Vt.delta!==null&&Array.isArray(Vt.delta)===!1&&B(Vt.delta)&&(Vt.finish_reason===null||Vt.finish_reason==="stop"||Vt.finish_reason==="length"||Vt.finish_reason==="tool_calls"||Vt.finish_reason==="content_filter"||Vt.finish_reason==="function_call")&&typeof Vt.index=="number"&&(Vt.logprobs===null||Vt.logprobs===void 0||typeof Vt.logprobs=="object"&&Vt.logprobs!==null&&nt(Vt.logprobs)),B=Vt=>(Vt.content===null||Vt.content===void 0||typeof Vt.content=="string")&&(Vt.function_call===void 0||typeof Vt.function_call=="object"&&Vt.function_call!==null&&Array.isArray(Vt.function_call)===!1&&G(Vt.function_call))&&(Vt.refusal===null||Vt.refusal===void 0||typeof Vt.refusal=="string")&&(Vt.role===void 0||Vt.role==="developer"||Vt.role==="system"||Vt.role==="user"||Vt.role==="assistant"||Vt.role==="tool")&&(Vt.tool_calls===void 0||Array.isArray(Vt.tool_calls)&&Vt.tool_calls.every(Ye=>typeof Ye=="object"&&Ye!==null&&J(Ye))),G=Vt=>(Vt.arguments===void 0||typeof Vt.arguments=="string")&&(Vt.name===void 0||typeof Vt.name=="string"),J=Vt=>typeof Vt.index=="number"&&(Vt.id===void 0||typeof Vt.id=="string")&&(Vt.function===void 0||typeof Vt.function=="object"&&Vt.function!==null&&Array.isArray(Vt.function)===!1&&U(Vt.function))&&(Vt.type===void 0||Vt.type==="function"),U=Vt=>(Vt.arguments===void 0||typeof Vt.arguments=="string")&&(Vt.name===void 0||typeof Vt.name=="string"),nt=Vt=>(Vt.content===null||Array.isArray(Vt.content)&&Vt.content.every(Ye=>typeof Ye=="object"&&Ye!==null&&at(Ye)))&&(Vt.refusal===null||Array.isArray(Vt.refusal)&&Vt.refusal.every(Ye=>typeof Ye=="object"&&Ye!==null&&at(Ye))),at=Vt=>typeof Vt.token=="string"&&(Vt.bytes===null||Array.isArray(Vt.bytes)&&Vt.bytes.every(Ye=>typeof Ye=="number"))&&typeof Vt.logprob=="number"&&Array.isArray(Vt.top_logprobs)&&Vt.top_logprobs.every(Ye=>typeof Ye=="object"&&Ye!==null&&it(Ye)),it=Vt=>typeof Vt.token=="string"&&(Vt.bytes===null||Array.isArray(Vt.bytes)&&Vt.bytes.every(Ye=>typeof Ye=="number"))&&typeof Vt.logprob=="number",st=Vt=>typeof Vt.completion_tokens=="number"&&typeof Vt.prompt_tokens=="number"&&typeof Vt.total_tokens=="number"&&(Vt.completion_tokens_details===void 0||typeof Vt.completion_tokens_details=="object"&&Vt.completion_tokens_details!==null&&Array.isArray(Vt.completion_tokens_details)===!1&&tt(Vt.completion_tokens_details))&&(Vt.prompt_tokens_details===void 0||typeof Vt.prompt_tokens_details=="object"&&Vt.prompt_tokens_details!==null&&Array.isArray(Vt.prompt_tokens_details)===!1&&Et(Vt.prompt_tokens_details)),tt=Vt=>(Vt.accepted_prediction_tokens===void 0||typeof Vt.accepted_prediction_tokens=="number")&&(Vt.audio_tokens===void 0||typeof Vt.audio_tokens=="number")&&(Vt.reasoning_tokens===void 0||typeof Vt.reasoning_tokens=="number")&&(Vt.rejected_prediction_tokens===void 0||typeof Vt.rejected_prediction_tokens=="number"),Et=Vt=>(Vt.audio_tokens===void 0||typeof Vt.audio_tokens=="number")&&(Vt.cached_tokens===void 0||typeof Vt.cached_tokens=="number"),Lt=(Vt,Ye,jn=!0)=>[typeof Vt.id=="string"||$n(jn,{path:Ye+".id",expected:"string",value:Vt.id}),(Array.isArray(Vt.choices)||$n(jn,{path:Ye+".choices",expected:"Array<ChatCompletionChunk.Choice>",value:Vt.choices}))&&Vt.choices.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".choices["+rr+"]",expected:"ChatCompletionChunk.Choice",value:er}))&&Dt(er,Ye+".choices["+rr+"]",jn)||$n(jn,{path:Ye+".choices["+rr+"]",expected:"ChatCompletionChunk.Choice",value:er})).every(er=>er)||$n(jn,{path:Ye+".choices",expected:"Array<ChatCompletionChunk.Choice>",value:Vt.choices}),typeof Vt.created=="number"||$n(jn,{path:Ye+".created",expected:"number",value:Vt.created}),typeof Vt.model=="string"||$n(jn,{path:Ye+".model",expected:"string",value:Vt.model}),Vt.object==="chat.completion.chunk"||$n(jn,{path:Ye+".object",expected:'"chat.completion.chunk"',value:Vt.object}),Vt.service_tier===null||Vt.service_tier===void 0||Vt.service_tier==="scale"||Vt.service_tier==="default"||$n(jn,{path:Ye+".service_tier",expected:'("default" | "scale" | null | undefined)',value:Vt.service_tier}),Vt.system_fingerprint===void 0||typeof Vt.system_fingerprint=="string"||$n(jn,{path:Ye+".system_fingerprint",expected:"(string | undefined)",value:Vt.system_fingerprint}),Vt.usage===null||Vt.usage===void 0||(typeof Vt.usage=="object"&&Vt.usage!==null||$n(jn,{path:Ye+".usage",expected:"(CompletionUsage | null | undefined)",value:Vt.usage}))&&cr(Vt.usage,Ye+".usage",jn)||$n(jn,{path:Ye+".usage",expected:"(CompletionUsage | null | undefined)",value:Vt.usage})].every(er=>er),Dt=(Vt,Ye,jn=!0)=>[(typeof Vt.delta=="object"&&Vt.delta!==null&&Array.isArray(Vt.delta)===!1||$n(jn,{path:Ye+".delta",expected:"ChatCompletionChunk.Choice.Delta",value:Vt.delta}))&&ae(Vt.delta,Ye+".delta",jn)||$n(jn,{path:Ye+".delta",expected:"ChatCompletionChunk.Choice.Delta",value:Vt.delta}),Vt.finish_reason===null||Vt.finish_reason==="stop"||Vt.finish_reason==="length"||Vt.finish_reason==="tool_calls"||Vt.finish_reason==="content_filter"||Vt.finish_reason==="function_call"||$n(jn,{path:Ye+".finish_reason",expected:'("content_filter" | "function_call" | "length" | "stop" | "tool_calls" | null)',value:Vt.finish_reason}),typeof Vt.index=="number"||$n(jn,{path:Ye+".index",expected:"number",value:Vt.index}),Vt.logprobs===null||Vt.logprobs===void 0||(typeof Vt.logprobs=="object"&&Vt.logprobs!==null||$n(jn,{path:Ye+".logprobs",expected:"(ChatCompletionChunk.Choice.Logprobs | null | undefined)",value:Vt.logprobs}))&&ge(Vt.logprobs,Ye+".logprobs",jn)||$n(jn,{path:Ye+".logprobs",expected:"(ChatCompletionChunk.Choice.Logprobs | null | undefined)",value:Vt.logprobs})].every(er=>er),ae=(Vt,Ye,jn=!0)=>[Vt.content===null||Vt.content===void 0||typeof Vt.content=="string"||$n(jn,{path:Ye+".content",expected:"(null | string | undefined)",value:Vt.content}),Vt.function_call===void 0||(typeof Vt.function_call=="object"&&Vt.function_call!==null&&Array.isArray(Vt.function_call)===!1||$n(jn,{path:Ye+".function_call",expected:"(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",value:Vt.function_call}))&&qt(Vt.function_call,Ye+".function_call",jn)||$n(jn,{path:Ye+".function_call",expected:"(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",value:Vt.function_call}),Vt.refusal===null||Vt.refusal===void 0||typeof Vt.refusal=="string"||$n(jn,{path:Ye+".refusal",expected:"(null | string | undefined)",value:Vt.refusal}),Vt.role===void 0||Vt.role==="developer"||Vt.role==="system"||Vt.role==="user"||Vt.role==="assistant"||Vt.role==="tool"||$n(jn,{path:Ye+".role",expected:'("assistant" | "developer" | "system" | "tool" | "user" | undefined)',value:Vt.role}),Vt.tool_calls===void 0||(Array.isArray(Vt.tool_calls)||$n(jn,{path:Ye+".tool_calls",expected:"(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",value:Vt.tool_calls}))&&Vt.tool_calls.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".tool_calls["+rr+"]",expected:"ChatCompletionChunk.Choice.Delta.ToolCall",value:er}))&&_e(er,Ye+".tool_calls["+rr+"]",jn)||$n(jn,{path:Ye+".tool_calls["+rr+"]",expected:"ChatCompletionChunk.Choice.Delta.ToolCall",value:er})).every(er=>er)||$n(jn,{path:Ye+".tool_calls",expected:"(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",value:Vt.tool_calls})].every(er=>er),qt=(Vt,Ye,jn=!0)=>[Vt.arguments===void 0||typeof Vt.arguments=="string"||$n(jn,{path:Ye+".arguments",expected:"(string | undefined)",value:Vt.arguments}),Vt.name===void 0||typeof Vt.name=="string"||$n(jn,{path:Ye+".name",expected:"(string | undefined)",value:Vt.name})].every(er=>er),_e=(Vt,Ye,jn=!0)=>[typeof Vt.index=="number"||$n(jn,{path:Ye+".index",expected:"number",value:Vt.index}),Vt.id===void 0||typeof Vt.id=="string"||$n(jn,{path:Ye+".id",expected:"(string | undefined)",value:Vt.id}),Vt.function===void 0||(typeof Vt.function=="object"&&Vt.function!==null&&Array.isArray(Vt.function)===!1||$n(jn,{path:Ye+'["function"]',expected:"(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",value:Vt.function}))&&gn(Vt.function,Ye+'["function"]',jn)||$n(jn,{path:Ye+'["function"]',expected:"(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",value:Vt.function}),Vt.type===void 0||Vt.type==="function"||$n(jn,{path:Ye+".type",expected:'("function" | undefined)',value:Vt.type})].every(er=>er),gn=(Vt,Ye,jn=!0)=>[Vt.arguments===void 0||typeof Vt.arguments=="string"||$n(jn,{path:Ye+".arguments",expected:"(string | undefined)",value:Vt.arguments}),Vt.name===void 0||typeof Vt.name=="string"||$n(jn,{path:Ye+".name",expected:"(string | undefined)",value:Vt.name})].every(er=>er),ge=(Vt,Ye,jn=!0)=>[Vt.content===null||(Array.isArray(Vt.content)||$n(jn,{path:Ye+".content",expected:"(Array<ChatCompletionTokenLogprob> | null)",value:Vt.content}))&&Vt.content.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".content["+rr+"]",expected:"ChatCompletionTokenLogprob",value:er}))&&Mn(er,Ye+".content["+rr+"]",jn)||$n(jn,{path:Ye+".content["+rr+"]",expected:"ChatCompletionTokenLogprob",value:er})).every(er=>er)||$n(jn,{path:Ye+".content",expected:"(Array<ChatCompletionTokenLogprob> | null)",value:Vt.content}),Vt.refusal===null||(Array.isArray(Vt.refusal)||$n(jn,{path:Ye+".refusal",expected:"(Array<ChatCompletionTokenLogprob> | null)",value:Vt.refusal}))&&Vt.refusal.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".refusal["+rr+"]",expected:"ChatCompletionTokenLogprob",value:er}))&&Mn(er,Ye+".refusal["+rr+"]",jn)||$n(jn,{path:Ye+".refusal["+rr+"]",expected:"ChatCompletionTokenLogprob",value:er})).every(er=>er)||$n(jn,{path:Ye+".refusal",expected:"(Array<ChatCompletionTokenLogprob> | null)",value:Vt.refusal})].every(er=>er),Mn=(Vt,Ye,jn=!0)=>[typeof Vt.token=="string"||$n(jn,{path:Ye+".token",expected:"string",value:Vt.token}),Vt.bytes===null||(Array.isArray(Vt.bytes)||$n(jn,{path:Ye+".bytes",expected:"(Array<number> | null)",value:Vt.bytes}))&&Vt.bytes.map((er,rr)=>typeof er=="number"||$n(jn,{path:Ye+".bytes["+rr+"]",expected:"number",value:er})).every(er=>er)||$n(jn,{path:Ye+".bytes",expected:"(Array<number> | null)",value:Vt.bytes}),typeof Vt.logprob=="number"||$n(jn,{path:Ye+".logprob",expected:"number",value:Vt.logprob}),(Array.isArray(Vt.top_logprobs)||$n(jn,{path:Ye+".top_logprobs",expected:"Array<ChatCompletionTokenLogprob.TopLogprob>",value:Vt.top_logprobs}))&&Vt.top_logprobs.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".top_logprobs["+rr+"]",expected:"ChatCompletionTokenLogprob.TopLogprob",value:er}))&&Wn(er,Ye+".top_logprobs["+rr+"]",jn)||$n(jn,{path:Ye+".top_logprobs["+rr+"]",expected:"ChatCompletionTokenLogprob.TopLogprob",value:er})).every(er=>er)||$n(jn,{path:Ye+".top_logprobs",expected:"Array<ChatCompletionTokenLogprob.TopLogprob>",value:Vt.top_logprobs})].every(er=>er),Wn=(Vt,Ye,jn=!0)=>[typeof Vt.token=="string"||$n(jn,{path:Ye+".token",expected:"string",value:Vt.token}),Vt.bytes===null||(Array.isArray(Vt.bytes)||$n(jn,{path:Ye+".bytes",expected:"(Array<number> | null)",value:Vt.bytes}))&&Vt.bytes.map((er,rr)=>typeof er=="number"||$n(jn,{path:Ye+".bytes["+rr+"]",expected:"number",value:er})).every(er=>er)||$n(jn,{path:Ye+".bytes",expected:"(Array<number> | null)",value:Vt.bytes}),typeof Vt.logprob=="number"||$n(jn,{path:Ye+".logprob",expected:"number",value:Vt.logprob})].every(er=>er),cr=(Vt,Ye,jn=!0)=>[typeof Vt.completion_tokens=="number"||$n(jn,{path:Ye+".completion_tokens",expected:"number",value:Vt.completion_tokens}),typeof Vt.prompt_tokens=="number"||$n(jn,{path:Ye+".prompt_tokens",expected:"number",value:Vt.prompt_tokens}),typeof Vt.total_tokens=="number"||$n(jn,{path:Ye+".total_tokens",expected:"number",value:Vt.total_tokens}),Vt.completion_tokens_details===void 0||(typeof Vt.completion_tokens_details=="object"&&Vt.completion_tokens_details!==null&&Array.isArray(Vt.completion_tokens_details)===!1||$n(jn,{path:Ye+".completion_tokens_details",expected:"(CompletionUsage.CompletionTokensDetails | undefined)",value:Vt.completion_tokens_details}))&&ar(Vt.completion_tokens_details,Ye+".completion_tokens_details",jn)||$n(jn,{path:Ye+".completion_tokens_details",expected:"(CompletionUsage.CompletionTokensDetails | undefined)",value:Vt.completion_tokens_details}),Vt.prompt_tokens_details===void 0||(typeof Vt.prompt_tokens_details=="object"&&Vt.prompt_tokens_details!==null&&Array.isArray(Vt.prompt_tokens_details)===!1||$n(jn,{path:Ye+".prompt_tokens_details",expected:"(CompletionUsage.PromptTokensDetails | undefined)",value:Vt.prompt_tokens_details}))&&mn(Vt.prompt_tokens_details,Ye+".prompt_tokens_details",jn)||$n(jn,{path:Ye+".prompt_tokens_details",expected:"(CompletionUsage.PromptTokensDetails | undefined)",value:Vt.prompt_tokens_details})].every(er=>er),ar=(Vt,Ye,jn=!0)=>[Vt.accepted_prediction_tokens===void 0||typeof Vt.accepted_prediction_tokens=="number"||$n(jn,{path:Ye+".accepted_prediction_tokens",expected:"(number | undefined)",value:Vt.accepted_prediction_tokens}),Vt.audio_tokens===void 0||typeof Vt.audio_tokens=="number"||$n(jn,{path:Ye+".audio_tokens",expected:"(number | undefined)",value:Vt.audio_tokens}),Vt.reasoning_tokens===void 0||typeof Vt.reasoning_tokens=="number"||$n(jn,{path:Ye+".reasoning_tokens",expected:"(number | undefined)",value:Vt.reasoning_tokens}),Vt.rejected_prediction_tokens===void 0||typeof Vt.rejected_prediction_tokens=="number"||$n(jn,{path:Ye+".rejected_prediction_tokens",expected:"(number | undefined)",value:Vt.rejected_prediction_tokens})].every(er=>er),mn=(Vt,Ye,jn=!0)=>[Vt.audio_tokens===void 0||typeof Vt.audio_tokens=="number"||$n(jn,{path:Ye+".audio_tokens",expected:"(number | undefined)",value:Vt.audio_tokens}),Vt.cached_tokens===void 0||typeof Vt.cached_tokens=="number"||$n(jn,{path:Ye+".cached_tokens",expected:"(number | undefined)",value:Vt.cached_tokens})].every(er=>er),Vn=Vt=>typeof Vt=="object"&&Vt!==null&&O(Vt);let hi,$n;return Vt=>{if(Vn(Vt)===!1){hi=[],$n=nP(hi),((jn,er,rr=!0)=>(typeof jn=="object"&&jn!==null||$n(!0,{path:er+"",expected:"ChatCompletionChunk",value:jn}))&&Lt(jn,er+"",!0)||$n(!0,{path:er+"",expected:"ChatCompletionChunk",value:jn}))(Vt,"$input",!0);const Ye=hi.length===0;return Ye?{success:Ye,data:Vt}:{success:Ye,errors:hi,data:Vt}}return{success:!0,data:Vt}}})()(m);return k.success===!1&&console.error("Invalid ChatCompletionChunk",k.errors),m}function C7e(o,h){const m=o.choices;h.choices.forEach(O=>{const P=m[O.index];if(P!=null){m[O.index]=A7e(P,O);return}m[O.index]={index:O.index,finish_reason:O.finish_reason??null,logprobs:O.logprobs??null,message:{tool_calls:O.delta.tool_calls!==void 0?O.delta.tool_calls.reduce((B,G)=>{var J,U;return B[G.index]={id:G.id??"",type:"function",function:{name:((J=G.function)==null?void 0:J.name)??"",arguments:((U=G.function)==null?void 0:U.arguments)??""}},B},[]):void 0,content:O.delta.content??null,refusal:O.delta.refusal??null,role:"assistant"}}});const k=h.usage==null?o.usage:o.usage==null?h.usage:jMn.sum(o.usage,h.usage);return{...o,choices:m,usage:k}}function $Mn(o){const h=o[0];if(h===void 0)throw new Error("No chunks received");return o.reduce(C7e,{id:h.id,choices:[],created:h.created,model:h.model,object:"chat.completion",usage:void 0,service_tier:h.service_tier,system_fingerprint:h.system_fingerprint})}function A7e(o,h){var m;if(o.finish_reason==null&&h.finish_reason!=null&&(o.finish_reason=h.finish_reason),o.logprobs==null&&h.logprobs!=null&&(o.logprobs=h.logprobs),h.delta.content!=null&&(o.message.content==null?o.message.content=h.delta.content:o.message.content+=h.delta.content),h.delta.refusal!=null&&(o.message.refusal==null?o.message.refusal=h.delta.refusal:o.message.refusal+=h.delta.refusal),h.delta.tool_calls!=null){(m=o.message).tool_calls??(m.tool_calls=[]);const k=o.message.tool_calls;h.delta.tool_calls.forEach(O=>{var B,G;const P=k[O.index];if(P!=null){k[O.index]=O7e(P,O);return}k[O.index]={id:O.id??"",type:"function",function:{name:((B=O.function)==null?void 0:B.name)??"",arguments:((G=O.function)==null?void 0:G.arguments)??""}}})}return o}function O7e(o,h){return h.function!=null&&(o.function.arguments+=h.function.arguments??"",o.function.name+=h.function.name??""),o.id+=h.id??"",o}const g6={transformCompletionChunk:FMn,accumulate:C7e,merge:$Mn,mergeChoice:A7e,mergeToolCalls:O7e};async function HMn(o){const h=o.getReader(),m=[];for(;;){const{done:k,value:O}=await h.read();if(k)break;m.push(O)}return m}async function zMn(o,h,m){const k=o.getReader();let O=m??null;for(;;){const{done:P,value:B}=await k.read();if(P)break;if(O===null){O=B;continue}O=h(O,B)}return O}function UMn(o){return new ReadableStream({start:m=>{m.enqueue(o),m.close()}})}function GMn(o,h){const m=o.getReader();return new ReadableStream({pull:async k=>{const{done:O,value:P}=await m.read();O?k.close():k.enqueue(h(P))}})}const q5={readAll:HMn,reduce:zMn,to:UMn,transform:GMn};function rjt(o,h){const m=o.stack.findIndex(O=>O.operation.name===h.name);if(m===-1)return null;const k=o.stack[m];return o.stack.splice(m,1),o.dispatch(bLn({selection:qj({operation:k.operation,reason:h.reason})})).catch(()=>{}),k}async function qMn(o,h){var B,G,J,U,nt;const m=await o.request("call",{messages:[{role:"system",content:Gj.write(o.config)},...o.histories.map(Uj).flat(),{role:"user",content:o.prompt.text},...((G=(B=o.config)==null?void 0:B.systemPrompt)==null?void 0:G.execute)===null?[]:[{role:"system",content:((nt=(U=(J=o.config)==null?void 0:J.systemPrompt)==null?void 0:U.execute)==null?void 0:nt.call(U,o.histories))??eP.EXECUTE}]],tools:h.map(at=>({type:"function",function:{name:at.name,description:at.function.description,parameters:at.function.separated!==void 0?at.function.separated.llm??{type:"object",properties:{},required:[],additionalProperties:!1,$defs:{}}:at.function.parameters}})),tool_choice:"auto",parallel_tool_calls:!1}),k=[],O=await q5.readAll(m),P=g6.merge(O);for(const at of P.choices){for(const it of at.message.tool_calls??[])if(it.type==="function"){const st=o.operations.flat.get(it.function.name);if(st===void 0)continue;k.push(async()=>{const tt=T7e({id:it.id,operation:st,arguments:JSON.parse(it.function.arguments)});tt.operation.protocol==="http"&&VMn({operation:tt.operation,arguments:tt.arguments}),await o.dispatch(tt);const Et=await N7e(o,tt,0);return o.dispatch(mLn({id:tt.id,operation:tt.operation,arguments:Et.arguments,value:Et.value})).catch(()=>{}),DMn(o)?(rjt(o,{name:tt.operation.name,reason:"completed"}),[Et,smt({id:tt.id,selections:[qj({operation:tt.operation,reason:"complete"})]})]):[Et]})}at.message.role==="assistant"&&at.message.content!==null&&at.message.content.length>0&&k.push(async()=>{const it=PX({role:"assistant",text:at.message.content});return o.dispatch(cmt({role:"assistant",get:()=>it.text,done:()=>!0,stream:q5.to(it.text),join:async()=>Promise.resolve(it.text)})).catch(()=>{}),[it]})}return(await Promise.all(k.map(async at=>at()))).flat()}async function N7e(o,h,m){var k,O,P;if(h.operation.protocol==="http"){const B=h.operation.function.validate(h.arguments);if(B.success===!1&&(o.dispatch(z8e({id:h.id,operation:h.operation,result:B})).catch(()=>{}),m++<(((k=o.config)==null?void 0:k.retry)??nT.RETRY))){const G=await nRt(o,h,m,B.errors);if(G!==null)return G}try{const G=await WMn(h.operation,h.arguments);return(((G.status===400||G.status===404||G.status===422)&&m++<(((O=o.config)==null?void 0:O.retry)??nT.RETRY)&&typeof G.body)===!1===!1?await nRt(o,h,m,G.body):null)??$N({operation:h.operation,id:h.id,arguments:h.arguments,value:G})}catch(G){return $N({operation:h.operation,id:h.id,arguments:h.arguments,value:{status:500,headers:{},body:G instanceof Error?{...G,name:G.name,message:G.message}:G}})}}else{const B=h.operation.function.validate(h.arguments);if(B.success===!1)return o.dispatch(z8e({id:h.id,operation:h.operation,result:B})).catch(()=>{}),(m++<(((P=o.config)==null?void 0:P.retry)??nT.RETRY)?await nRt(o,h,m,B.errors):null)??$N({id:h.id,operation:h.operation,arguments:h.arguments,value:{name:"TypeGuardError",message:"Invalid arguments.",errors:B.errors}});try{const G=await KMn(h.operation,h.arguments);return $N({id:h.id,operation:h.operation,arguments:h.arguments,value:G})}catch(G){return $N({id:h.id,operation:h.operation,arguments:h.arguments,value:G instanceof Error?{...G,name:G.name,message:G.message}:G})}}}async function WMn(o,h){const m={connection:o.controller.connection,application:o.controller.application,function:o.function};return o.controller.execute!==void 0?o.controller.execute({...m,arguments:h}):uBt.propagate({...m,input:h})}async function KMn(o,h){const m=o.controller.execute;return typeof m=="function"?await m({application:o.controller.application,function:o.function,arguments:h}):m[o.function.name](h)}async function nRt(o,h,m,k){var J,U,nt,at,it,st,tt;const O=await o.request("call",{messages:[{role:"system",content:Gj.write(o.config)},...o.histories.map(Uj).flat(),{role:"user",content:o.prompt.text},...((U=(J=o.config)==null?void 0:J.systemPrompt)==null?void 0:U.execute)===null?[]:[{role:"system",content:((it=(at=(nt=o.config)==null?void 0:nt.systemPrompt)==null?void 0:at.execute)==null?void 0:it.call(at,o.histories))??eP.EXECUTE}],{role:"assistant",tool_calls:[{type:"function",id:h.id,function:{name:h.operation.name,arguments:JSON.stringify(h.arguments)}}]},{role:"tool",content:typeof k=="string"?k:JSON.stringify(k),tool_call_id:h.id},{role:"system",content:["You A.I. assistant has composed wrong arguments.","","Correct it at the next function calling."].join(`
|
|
89
|
+
If you can't find any proper function to select, just type your own message. By the way, when typing your own message, please consider the user's language locale code. If your message is different with the user's language, please translate it to the user's.`};var OMn={};const NMn=new ejt(()=>{const o=h=>typeof h=="object"&&h!==null;return typeof global=="object"&&o(global)&&o(global.process)&&o(global.process.versions)&&typeof global.process.versions.node<"u"}),PMn=new ejt(()=>{var o;return NMn.get()?((o=OMn.LANG)==null?void 0:o.split(".")[0])??"en-US":navigator.language}),LMn=new ejt(()=>Intl.DateTimeFormat().resolvedOptions().timeZone);function MMn(o){var k;if(((k=o==null?void 0:o.systemPrompt)==null?void 0:k.common)!==void 0)return o.systemPrompt.common(o);const h=(o==null?void 0:o.locale)??PMn.get(),m=(o==null?void 0:o.timezone)??LMn.get();return eP.COMMON.replace("${locale}",h).replace("${timezone}",m).replace("${datetime}",new Date().toISOString())}const Gj={write:MMn};function DMn(o){return typeof o.initialize=="function"}function qj(o){return{operation:o.operation,reason:o.reason,toJSON:()=>({operation:o.operation.toJSON(),reason:o.reason})}}var njt={};Object.defineProperty(njt,"__esModule",{value:!0});var nP=njt._validateReport=void 0;const RMn=o=>{const h=m=>{if(o.length===0)return!0;const k=o[o.length-1].path;return m.length>k.length||k.substring(0,m.length)!==m};return(m,k)=>(m&&h(k.path)&&o.push(k),!1)};nP=njt._validateReport=RMn;var lBt;(o=>{function h(m){return new TextDecoder().decode(m)}o.toUtf8=h})(lBt||(lBt={}));function S7e(o,h){return{accepted_prediction_tokens:(o.accepted_prediction_tokens??0)+(h.accepted_prediction_tokens??0),reasoning_tokens:(o.reasoning_tokens??0)+(h.reasoning_tokens??0),rejected_prediction_tokens:(o.rejected_prediction_tokens??0)+(h.rejected_prediction_tokens??0)}}function I7e(o,h){return{audio_tokens:(o.audio_tokens??0)+(h.audio_tokens??0),cached_tokens:(o.cached_tokens??0)+(h.cached_tokens??0)}}function BMn(o,h){return{prompt_tokens:(o.prompt_tokens??0)+(h.prompt_tokens??0),completion_tokens:(o.completion_tokens??0)+(h.completion_tokens??0),total_tokens:(o.total_tokens??0)+(h.total_tokens??0),completion_tokens_details:S7e(o.completion_tokens_details??{accepted_prediction_tokens:0,reasoning_tokens:0,rejected_prediction_tokens:0},h.completion_tokens_details??{accepted_prediction_tokens:0,reasoning_tokens:0,rejected_prediction_tokens:0}),prompt_tokens_details:I7e(o.prompt_tokens_details??{audio_tokens:0,cached_tokens:0},h.prompt_tokens_details??{audio_tokens:0,cached_tokens:0})}}const jMn={sum:BMn,sumCompletionTokenDetail:S7e,sumPromptTokenDetail:I7e};function FMn(o){const h=o instanceof Uint8Array?lBt.toUtf8(o):o,m=JSON.parse(h),k=(()=>{const O=Vt=>typeof Vt.id=="string"&&Array.isArray(Vt.choices)&&Vt.choices.every(Ye=>typeof Ye=="object"&&Ye!==null&&P(Ye))&&typeof Vt.created=="number"&&typeof Vt.model=="string"&&Vt.object==="chat.completion.chunk"&&(Vt.service_tier===null||Vt.service_tier===void 0||Vt.service_tier==="scale"||Vt.service_tier==="default")&&(Vt.system_fingerprint===void 0||typeof Vt.system_fingerprint=="string")&&(Vt.usage===null||Vt.usage===void 0||typeof Vt.usage=="object"&&Vt.usage!==null&&st(Vt.usage)),P=Vt=>typeof Vt.delta=="object"&&Vt.delta!==null&&Array.isArray(Vt.delta)===!1&&B(Vt.delta)&&(Vt.finish_reason===null||Vt.finish_reason==="stop"||Vt.finish_reason==="length"||Vt.finish_reason==="tool_calls"||Vt.finish_reason==="content_filter"||Vt.finish_reason==="function_call")&&typeof Vt.index=="number"&&(Vt.logprobs===null||Vt.logprobs===void 0||typeof Vt.logprobs=="object"&&Vt.logprobs!==null&&nt(Vt.logprobs)),B=Vt=>(Vt.content===null||Vt.content===void 0||typeof Vt.content=="string")&&(Vt.function_call===void 0||typeof Vt.function_call=="object"&&Vt.function_call!==null&&Array.isArray(Vt.function_call)===!1&&G(Vt.function_call))&&(Vt.refusal===null||Vt.refusal===void 0||typeof Vt.refusal=="string")&&(Vt.role===void 0||Vt.role==="developer"||Vt.role==="system"||Vt.role==="user"||Vt.role==="assistant"||Vt.role==="tool")&&(Vt.tool_calls===void 0||Array.isArray(Vt.tool_calls)&&Vt.tool_calls.every(Ye=>typeof Ye=="object"&&Ye!==null&&J(Ye))),G=Vt=>(Vt.arguments===void 0||typeof Vt.arguments=="string")&&(Vt.name===void 0||typeof Vt.name=="string"),J=Vt=>typeof Vt.index=="number"&&(Vt.id===void 0||typeof Vt.id=="string")&&(Vt.function===void 0||typeof Vt.function=="object"&&Vt.function!==null&&Array.isArray(Vt.function)===!1&&U(Vt.function))&&(Vt.type===void 0||Vt.type==="function"),U=Vt=>(Vt.arguments===void 0||typeof Vt.arguments=="string")&&(Vt.name===void 0||typeof Vt.name=="string"),nt=Vt=>(Vt.content===null||Array.isArray(Vt.content)&&Vt.content.every(Ye=>typeof Ye=="object"&&Ye!==null&&at(Ye)))&&(Vt.refusal===null||Array.isArray(Vt.refusal)&&Vt.refusal.every(Ye=>typeof Ye=="object"&&Ye!==null&&at(Ye))),at=Vt=>typeof Vt.token=="string"&&(Vt.bytes===null||Array.isArray(Vt.bytes)&&Vt.bytes.every(Ye=>typeof Ye=="number"))&&typeof Vt.logprob=="number"&&Array.isArray(Vt.top_logprobs)&&Vt.top_logprobs.every(Ye=>typeof Ye=="object"&&Ye!==null&&it(Ye)),it=Vt=>typeof Vt.token=="string"&&(Vt.bytes===null||Array.isArray(Vt.bytes)&&Vt.bytes.every(Ye=>typeof Ye=="number"))&&typeof Vt.logprob=="number",st=Vt=>typeof Vt.completion_tokens=="number"&&typeof Vt.prompt_tokens=="number"&&typeof Vt.total_tokens=="number"&&(Vt.completion_tokens_details===void 0||typeof Vt.completion_tokens_details=="object"&&Vt.completion_tokens_details!==null&&Array.isArray(Vt.completion_tokens_details)===!1&&tt(Vt.completion_tokens_details))&&(Vt.prompt_tokens_details===void 0||typeof Vt.prompt_tokens_details=="object"&&Vt.prompt_tokens_details!==null&&Array.isArray(Vt.prompt_tokens_details)===!1&&Et(Vt.prompt_tokens_details)),tt=Vt=>(Vt.accepted_prediction_tokens===void 0||typeof Vt.accepted_prediction_tokens=="number")&&(Vt.audio_tokens===void 0||typeof Vt.audio_tokens=="number")&&(Vt.reasoning_tokens===void 0||typeof Vt.reasoning_tokens=="number")&&(Vt.rejected_prediction_tokens===void 0||typeof Vt.rejected_prediction_tokens=="number"),Et=Vt=>(Vt.audio_tokens===void 0||typeof Vt.audio_tokens=="number")&&(Vt.cached_tokens===void 0||typeof Vt.cached_tokens=="number"),Lt=(Vt,Ye,jn=!0)=>[typeof Vt.id=="string"||$n(jn,{path:Ye+".id",expected:"string",value:Vt.id}),(Array.isArray(Vt.choices)||$n(jn,{path:Ye+".choices",expected:"Array<ChatCompletionChunk.Choice>",value:Vt.choices}))&&Vt.choices.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".choices["+rr+"]",expected:"ChatCompletionChunk.Choice",value:er}))&&Dt(er,Ye+".choices["+rr+"]",jn)||$n(jn,{path:Ye+".choices["+rr+"]",expected:"ChatCompletionChunk.Choice",value:er})).every(er=>er)||$n(jn,{path:Ye+".choices",expected:"Array<ChatCompletionChunk.Choice>",value:Vt.choices}),typeof Vt.created=="number"||$n(jn,{path:Ye+".created",expected:"number",value:Vt.created}),typeof Vt.model=="string"||$n(jn,{path:Ye+".model",expected:"string",value:Vt.model}),Vt.object==="chat.completion.chunk"||$n(jn,{path:Ye+".object",expected:'"chat.completion.chunk"',value:Vt.object}),Vt.service_tier===null||Vt.service_tier===void 0||Vt.service_tier==="scale"||Vt.service_tier==="default"||$n(jn,{path:Ye+".service_tier",expected:'("default" | "scale" | null | undefined)',value:Vt.service_tier}),Vt.system_fingerprint===void 0||typeof Vt.system_fingerprint=="string"||$n(jn,{path:Ye+".system_fingerprint",expected:"(string | undefined)",value:Vt.system_fingerprint}),Vt.usage===null||Vt.usage===void 0||(typeof Vt.usage=="object"&&Vt.usage!==null||$n(jn,{path:Ye+".usage",expected:"(CompletionUsage | null | undefined)",value:Vt.usage}))&&cr(Vt.usage,Ye+".usage",jn)||$n(jn,{path:Ye+".usage",expected:"(CompletionUsage | null | undefined)",value:Vt.usage})].every(er=>er),Dt=(Vt,Ye,jn=!0)=>[(typeof Vt.delta=="object"&&Vt.delta!==null&&Array.isArray(Vt.delta)===!1||$n(jn,{path:Ye+".delta",expected:"ChatCompletionChunk.Choice.Delta",value:Vt.delta}))&&ae(Vt.delta,Ye+".delta",jn)||$n(jn,{path:Ye+".delta",expected:"ChatCompletionChunk.Choice.Delta",value:Vt.delta}),Vt.finish_reason===null||Vt.finish_reason==="stop"||Vt.finish_reason==="length"||Vt.finish_reason==="tool_calls"||Vt.finish_reason==="content_filter"||Vt.finish_reason==="function_call"||$n(jn,{path:Ye+".finish_reason",expected:'("content_filter" | "function_call" | "length" | "stop" | "tool_calls" | null)',value:Vt.finish_reason}),typeof Vt.index=="number"||$n(jn,{path:Ye+".index",expected:"number",value:Vt.index}),Vt.logprobs===null||Vt.logprobs===void 0||(typeof Vt.logprobs=="object"&&Vt.logprobs!==null||$n(jn,{path:Ye+".logprobs",expected:"(ChatCompletionChunk.Choice.Logprobs | null | undefined)",value:Vt.logprobs}))&&ge(Vt.logprobs,Ye+".logprobs",jn)||$n(jn,{path:Ye+".logprobs",expected:"(ChatCompletionChunk.Choice.Logprobs | null | undefined)",value:Vt.logprobs})].every(er=>er),ae=(Vt,Ye,jn=!0)=>[Vt.content===null||Vt.content===void 0||typeof Vt.content=="string"||$n(jn,{path:Ye+".content",expected:"(null | string | undefined)",value:Vt.content}),Vt.function_call===void 0||(typeof Vt.function_call=="object"&&Vt.function_call!==null&&Array.isArray(Vt.function_call)===!1||$n(jn,{path:Ye+".function_call",expected:"(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",value:Vt.function_call}))&&qt(Vt.function_call,Ye+".function_call",jn)||$n(jn,{path:Ye+".function_call",expected:"(ChatCompletionChunk.Choice.Delta.FunctionCall | undefined)",value:Vt.function_call}),Vt.refusal===null||Vt.refusal===void 0||typeof Vt.refusal=="string"||$n(jn,{path:Ye+".refusal",expected:"(null | string | undefined)",value:Vt.refusal}),Vt.role===void 0||Vt.role==="developer"||Vt.role==="system"||Vt.role==="user"||Vt.role==="assistant"||Vt.role==="tool"||$n(jn,{path:Ye+".role",expected:'("assistant" | "developer" | "system" | "tool" | "user" | undefined)',value:Vt.role}),Vt.tool_calls===void 0||(Array.isArray(Vt.tool_calls)||$n(jn,{path:Ye+".tool_calls",expected:"(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",value:Vt.tool_calls}))&&Vt.tool_calls.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".tool_calls["+rr+"]",expected:"ChatCompletionChunk.Choice.Delta.ToolCall",value:er}))&&_e(er,Ye+".tool_calls["+rr+"]",jn)||$n(jn,{path:Ye+".tool_calls["+rr+"]",expected:"ChatCompletionChunk.Choice.Delta.ToolCall",value:er})).every(er=>er)||$n(jn,{path:Ye+".tool_calls",expected:"(Array<ChatCompletionChunk.Choice.Delta.ToolCall> | undefined)",value:Vt.tool_calls})].every(er=>er),qt=(Vt,Ye,jn=!0)=>[Vt.arguments===void 0||typeof Vt.arguments=="string"||$n(jn,{path:Ye+".arguments",expected:"(string | undefined)",value:Vt.arguments}),Vt.name===void 0||typeof Vt.name=="string"||$n(jn,{path:Ye+".name",expected:"(string | undefined)",value:Vt.name})].every(er=>er),_e=(Vt,Ye,jn=!0)=>[typeof Vt.index=="number"||$n(jn,{path:Ye+".index",expected:"number",value:Vt.index}),Vt.id===void 0||typeof Vt.id=="string"||$n(jn,{path:Ye+".id",expected:"(string | undefined)",value:Vt.id}),Vt.function===void 0||(typeof Vt.function=="object"&&Vt.function!==null&&Array.isArray(Vt.function)===!1||$n(jn,{path:Ye+'["function"]',expected:"(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",value:Vt.function}))&&gn(Vt.function,Ye+'["function"]',jn)||$n(jn,{path:Ye+'["function"]',expected:"(ChatCompletionChunk.Choice.Delta.ToolCall.Function | undefined)",value:Vt.function}),Vt.type===void 0||Vt.type==="function"||$n(jn,{path:Ye+".type",expected:'("function" | undefined)',value:Vt.type})].every(er=>er),gn=(Vt,Ye,jn=!0)=>[Vt.arguments===void 0||typeof Vt.arguments=="string"||$n(jn,{path:Ye+".arguments",expected:"(string | undefined)",value:Vt.arguments}),Vt.name===void 0||typeof Vt.name=="string"||$n(jn,{path:Ye+".name",expected:"(string | undefined)",value:Vt.name})].every(er=>er),ge=(Vt,Ye,jn=!0)=>[Vt.content===null||(Array.isArray(Vt.content)||$n(jn,{path:Ye+".content",expected:"(Array<ChatCompletionTokenLogprob> | null)",value:Vt.content}))&&Vt.content.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".content["+rr+"]",expected:"ChatCompletionTokenLogprob",value:er}))&&Mn(er,Ye+".content["+rr+"]",jn)||$n(jn,{path:Ye+".content["+rr+"]",expected:"ChatCompletionTokenLogprob",value:er})).every(er=>er)||$n(jn,{path:Ye+".content",expected:"(Array<ChatCompletionTokenLogprob> | null)",value:Vt.content}),Vt.refusal===null||(Array.isArray(Vt.refusal)||$n(jn,{path:Ye+".refusal",expected:"(Array<ChatCompletionTokenLogprob> | null)",value:Vt.refusal}))&&Vt.refusal.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".refusal["+rr+"]",expected:"ChatCompletionTokenLogprob",value:er}))&&Mn(er,Ye+".refusal["+rr+"]",jn)||$n(jn,{path:Ye+".refusal["+rr+"]",expected:"ChatCompletionTokenLogprob",value:er})).every(er=>er)||$n(jn,{path:Ye+".refusal",expected:"(Array<ChatCompletionTokenLogprob> | null)",value:Vt.refusal})].every(er=>er),Mn=(Vt,Ye,jn=!0)=>[typeof Vt.token=="string"||$n(jn,{path:Ye+".token",expected:"string",value:Vt.token}),Vt.bytes===null||(Array.isArray(Vt.bytes)||$n(jn,{path:Ye+".bytes",expected:"(Array<number> | null)",value:Vt.bytes}))&&Vt.bytes.map((er,rr)=>typeof er=="number"||$n(jn,{path:Ye+".bytes["+rr+"]",expected:"number",value:er})).every(er=>er)||$n(jn,{path:Ye+".bytes",expected:"(Array<number> | null)",value:Vt.bytes}),typeof Vt.logprob=="number"||$n(jn,{path:Ye+".logprob",expected:"number",value:Vt.logprob}),(Array.isArray(Vt.top_logprobs)||$n(jn,{path:Ye+".top_logprobs",expected:"Array<ChatCompletionTokenLogprob.TopLogprob>",value:Vt.top_logprobs}))&&Vt.top_logprobs.map((er,rr)=>(typeof er=="object"&&er!==null||$n(jn,{path:Ye+".top_logprobs["+rr+"]",expected:"ChatCompletionTokenLogprob.TopLogprob",value:er}))&&Wn(er,Ye+".top_logprobs["+rr+"]",jn)||$n(jn,{path:Ye+".top_logprobs["+rr+"]",expected:"ChatCompletionTokenLogprob.TopLogprob",value:er})).every(er=>er)||$n(jn,{path:Ye+".top_logprobs",expected:"Array<ChatCompletionTokenLogprob.TopLogprob>",value:Vt.top_logprobs})].every(er=>er),Wn=(Vt,Ye,jn=!0)=>[typeof Vt.token=="string"||$n(jn,{path:Ye+".token",expected:"string",value:Vt.token}),Vt.bytes===null||(Array.isArray(Vt.bytes)||$n(jn,{path:Ye+".bytes",expected:"(Array<number> | null)",value:Vt.bytes}))&&Vt.bytes.map((er,rr)=>typeof er=="number"||$n(jn,{path:Ye+".bytes["+rr+"]",expected:"number",value:er})).every(er=>er)||$n(jn,{path:Ye+".bytes",expected:"(Array<number> | null)",value:Vt.bytes}),typeof Vt.logprob=="number"||$n(jn,{path:Ye+".logprob",expected:"number",value:Vt.logprob})].every(er=>er),cr=(Vt,Ye,jn=!0)=>[typeof Vt.completion_tokens=="number"||$n(jn,{path:Ye+".completion_tokens",expected:"number",value:Vt.completion_tokens}),typeof Vt.prompt_tokens=="number"||$n(jn,{path:Ye+".prompt_tokens",expected:"number",value:Vt.prompt_tokens}),typeof Vt.total_tokens=="number"||$n(jn,{path:Ye+".total_tokens",expected:"number",value:Vt.total_tokens}),Vt.completion_tokens_details===void 0||(typeof Vt.completion_tokens_details=="object"&&Vt.completion_tokens_details!==null&&Array.isArray(Vt.completion_tokens_details)===!1||$n(jn,{path:Ye+".completion_tokens_details",expected:"(CompletionUsage.CompletionTokensDetails | undefined)",value:Vt.completion_tokens_details}))&&ar(Vt.completion_tokens_details,Ye+".completion_tokens_details",jn)||$n(jn,{path:Ye+".completion_tokens_details",expected:"(CompletionUsage.CompletionTokensDetails | undefined)",value:Vt.completion_tokens_details}),Vt.prompt_tokens_details===void 0||(typeof Vt.prompt_tokens_details=="object"&&Vt.prompt_tokens_details!==null&&Array.isArray(Vt.prompt_tokens_details)===!1||$n(jn,{path:Ye+".prompt_tokens_details",expected:"(CompletionUsage.PromptTokensDetails | undefined)",value:Vt.prompt_tokens_details}))&&mn(Vt.prompt_tokens_details,Ye+".prompt_tokens_details",jn)||$n(jn,{path:Ye+".prompt_tokens_details",expected:"(CompletionUsage.PromptTokensDetails | undefined)",value:Vt.prompt_tokens_details})].every(er=>er),ar=(Vt,Ye,jn=!0)=>[Vt.accepted_prediction_tokens===void 0||typeof Vt.accepted_prediction_tokens=="number"||$n(jn,{path:Ye+".accepted_prediction_tokens",expected:"(number | undefined)",value:Vt.accepted_prediction_tokens}),Vt.audio_tokens===void 0||typeof Vt.audio_tokens=="number"||$n(jn,{path:Ye+".audio_tokens",expected:"(number | undefined)",value:Vt.audio_tokens}),Vt.reasoning_tokens===void 0||typeof Vt.reasoning_tokens=="number"||$n(jn,{path:Ye+".reasoning_tokens",expected:"(number | undefined)",value:Vt.reasoning_tokens}),Vt.rejected_prediction_tokens===void 0||typeof Vt.rejected_prediction_tokens=="number"||$n(jn,{path:Ye+".rejected_prediction_tokens",expected:"(number | undefined)",value:Vt.rejected_prediction_tokens})].every(er=>er),mn=(Vt,Ye,jn=!0)=>[Vt.audio_tokens===void 0||typeof Vt.audio_tokens=="number"||$n(jn,{path:Ye+".audio_tokens",expected:"(number | undefined)",value:Vt.audio_tokens}),Vt.cached_tokens===void 0||typeof Vt.cached_tokens=="number"||$n(jn,{path:Ye+".cached_tokens",expected:"(number | undefined)",value:Vt.cached_tokens})].every(er=>er),Vn=Vt=>typeof Vt=="object"&&Vt!==null&&O(Vt);let hi,$n;return Vt=>{if(Vn(Vt)===!1){hi=[],$n=nP(hi),((jn,er,rr=!0)=>(typeof jn=="object"&&jn!==null||$n(!0,{path:er+"",expected:"ChatCompletionChunk",value:jn}))&&Lt(jn,er+"",!0)||$n(!0,{path:er+"",expected:"ChatCompletionChunk",value:jn}))(Vt,"$input",!0);const Ye=hi.length===0;return Ye?{success:Ye,data:Vt}:{success:Ye,errors:hi,data:Vt}}return{success:!0,data:Vt}}})()(m);return k.success===!1&&console.error("Invalid ChatCompletionChunk",k.errors),m}function C7e(o,h){const m=o.choices;h.choices.forEach(O=>{const P=m[O.index];if(P!=null){m[O.index]=A7e(P,O);return}m[O.index]={index:O.index,finish_reason:O.finish_reason??null,logprobs:O.logprobs??null,message:{tool_calls:O.delta.tool_calls!==void 0?O.delta.tool_calls.reduce((B,G)=>{var J,U;return B[G.index]={id:G.id??"",type:"function",function:{name:((J=G.function)==null?void 0:J.name)??"",arguments:((U=G.function)==null?void 0:U.arguments)??""}},B},[]):void 0,content:O.delta.content??null,refusal:O.delta.refusal??null,role:"assistant"}}});const k=h.usage==null?o.usage:o.usage==null?h.usage:jMn.sum(o.usage,h.usage);return{...o,choices:m,usage:k}}function $Mn(o){const h=o[0];if(h===void 0)throw new Error("No chunks received");return o.reduce(C7e,{id:h.id,choices:[],created:h.created,model:h.model,object:"chat.completion",usage:void 0,service_tier:h.service_tier,system_fingerprint:h.system_fingerprint})}function A7e(o,h){var m;if(o.finish_reason==null&&h.finish_reason!=null&&(o.finish_reason=h.finish_reason),o.logprobs==null&&h.logprobs!=null&&(o.logprobs=h.logprobs),h.delta.content!=null&&(o.message.content==null?o.message.content=h.delta.content:o.message.content+=h.delta.content),h.delta.refusal!=null&&(o.message.refusal==null?o.message.refusal=h.delta.refusal:o.message.refusal+=h.delta.refusal),h.delta.tool_calls!=null){(m=o.message).tool_calls??(m.tool_calls=[]);const k=o.message.tool_calls;h.delta.tool_calls.forEach(O=>{var B,G;const P=k[O.index];if(P!=null){k[O.index]=O7e(P,O);return}k[O.index]={id:O.id??"",type:"function",function:{name:((B=O.function)==null?void 0:B.name)??"",arguments:((G=O.function)==null?void 0:G.arguments)??""}}})}return o}function O7e(o,h){return h.function!=null&&(o.function.arguments+=h.function.arguments??"",o.function.name+=h.function.name??""),o.id+=h.id??"",o}const g6={transformCompletionChunk:FMn,accumulate:C7e,merge:$Mn,mergeChoice:A7e,mergeToolCalls:O7e};async function HMn(o){const h=o.getReader(),m=[];for(;;){const{done:k,value:O}=await h.read();if(k)break;m.push(O)}return m}async function zMn(o,h,m){const k=o.getReader();let O=m??null;for(;;){const{done:P,value:B}=await k.read();if(P)break;if(O===null){O=B;continue}O=h(O,B)}return O}function UMn(o){return new ReadableStream({start:m=>{m.enqueue(o),m.close()}})}function GMn(o,h){const m=o.getReader();return new ReadableStream({pull:async k=>{const{done:O,value:P}=await m.read();O?k.close():k.enqueue(h(P))}})}const q5={readAll:HMn,reduce:zMn,to:UMn,transform:GMn};function rjt(o,h){const m=o.stack.findIndex(O=>O.operation.name===h.name);if(m===-1)return null;const k=o.stack[m];return o.stack.splice(m,1),o.dispatch(bLn({selection:qj({operation:k.operation,reason:h.reason})})).catch(()=>{}),k}async function qMn(o,h){var B,G,J,U,nt;const m=await o.request("call",{messages:[{role:"system",content:Gj.write(o.config)},...o.histories.map(Uj).flat(),{role:"user",content:o.prompt.text},...((G=(B=o.config)==null?void 0:B.systemPrompt)==null?void 0:G.execute)===null?[]:[{role:"system",content:((nt=(U=(J=o.config)==null?void 0:J.systemPrompt)==null?void 0:U.execute)==null?void 0:nt.call(U,o.histories))??eP.EXECUTE}]],tools:h.map(at=>({type:"function",function:{name:at.name,description:at.function.description,parameters:at.function.separated!==void 0?at.function.separated.llm??{type:"object",properties:{},required:[],additionalProperties:!1,$defs:{}}:at.function.parameters}})),tool_choice:"auto",parallel_tool_calls:!1}),k=[],O=await q5.readAll(m),P=g6.merge(O);for(const at of P.choices){for(const it of at.message.tool_calls??[])if(it.type==="function"){const st=o.operations.flat.get(it.function.name);if(st===void 0)continue;k.push(async()=>{const tt=T7e({id:it.id,operation:st,arguments:JSON.parse(it.function.arguments)});tt.operation.protocol==="http"&&VMn({operation:tt.operation,arguments:tt.arguments}),await o.dispatch(tt);const Et=await N7e(o,tt,0);return o.dispatch(mLn({id:tt.id,operation:tt.operation,arguments:Et.arguments,value:Et.value})).catch(()=>{}),DMn(o)?(rjt(o,{name:tt.operation.name,reason:"completed"}),[Et,smt({id:tt.id,selections:[qj({operation:tt.operation,reason:"complete"})]})]):[Et]})}at.message.role==="assistant"&&at.message.content!=null&&at.message.content.length!==0&&k.push(async()=>{const it=PX({role:"assistant",text:at.message.content});return o.dispatch(cmt({role:"assistant",get:()=>it.text,done:()=>!0,stream:q5.to(it.text),join:async()=>Promise.resolve(it.text)})).catch(()=>{}),[it]})}return(await Promise.all(k.map(async at=>at()))).flat()}async function N7e(o,h,m){var k,O,P;if(h.operation.protocol==="http"){const B=h.operation.function.validate(h.arguments);if(B.success===!1&&(o.dispatch(z8e({id:h.id,operation:h.operation,result:B})).catch(()=>{}),m++<(((k=o.config)==null?void 0:k.retry)??nT.RETRY))){const G=await nRt(o,h,m,B.errors);if(G!==null)return G}try{const G=await WMn(h.operation,h.arguments);return(((G.status===400||G.status===404||G.status===422)&&m++<(((O=o.config)==null?void 0:O.retry)??nT.RETRY)&&typeof G.body)===!1===!1?await nRt(o,h,m,G.body):null)??$N({operation:h.operation,id:h.id,arguments:h.arguments,value:G})}catch(G){return $N({operation:h.operation,id:h.id,arguments:h.arguments,value:{status:500,headers:{},body:G instanceof Error?{...G,name:G.name,message:G.message}:G}})}}else{const B=h.operation.function.validate(h.arguments);if(B.success===!1)return o.dispatch(z8e({id:h.id,operation:h.operation,result:B})).catch(()=>{}),(m++<(((P=o.config)==null?void 0:P.retry)??nT.RETRY)?await nRt(o,h,m,B.errors):null)??$N({id:h.id,operation:h.operation,arguments:h.arguments,value:{name:"TypeGuardError",message:"Invalid arguments.",errors:B.errors}});try{const G=await KMn(h.operation,h.arguments);return $N({id:h.id,operation:h.operation,arguments:h.arguments,value:G})}catch(G){return $N({id:h.id,operation:h.operation,arguments:h.arguments,value:G instanceof Error?{...G,name:G.name,message:G.message}:G})}}}async function WMn(o,h){const m={connection:o.controller.connection,application:o.controller.application,function:o.function};return o.controller.execute!==void 0?o.controller.execute({...m,arguments:h}):uBt.propagate({...m,input:h})}async function KMn(o,h){const m=o.controller.execute;return typeof m=="function"?await m({application:o.controller.application,function:o.function,arguments:h}):m[o.function.name](h)}async function nRt(o,h,m,k){var J,U,nt,at,it,st,tt;const O=await o.request("call",{messages:[{role:"system",content:Gj.write(o.config)},...o.histories.map(Uj).flat(),{role:"user",content:o.prompt.text},...((U=(J=o.config)==null?void 0:J.systemPrompt)==null?void 0:U.execute)===null?[]:[{role:"system",content:((it=(at=(nt=o.config)==null?void 0:nt.systemPrompt)==null?void 0:at.execute)==null?void 0:it.call(at,o.histories))??eP.EXECUTE}],{role:"assistant",tool_calls:[{type:"function",id:h.id,function:{name:h.operation.name,arguments:JSON.stringify(h.arguments)}}]},{role:"tool",content:typeof k=="string"?k:JSON.stringify(k),tool_call_id:h.id},{role:"system",content:["You A.I. assistant has composed wrong arguments.","","Correct it at the next function calling."].join(`
|
|
90
90
|
`)}],tools:[{type:"function",function:{name:h.operation.name,description:h.operation.function.description,parameters:h.operation.function.separated!==void 0?((st=h.operation.function.separated)==null?void 0:st.llm)??{$defs:{},type:"object",properties:{},additionalProperties:!1,required:[]}:h.operation.function.parameters}}],tool_choice:"auto",parallel_tool_calls:!1}),P=await q5.readAll(O),G=(((tt=g6.merge(P).choices[0])==null?void 0:tt.message.tool_calls)??[]).find(Et=>Et.type==="function"&&Et.function.name===h.operation.name);return G===void 0?null:N7e(o,T7e({id:G.id,operation:h.operation,arguments:JSON.parse(G.function.arguments)}),m)}function VMn(o){var m;if(o.operation.protocol!=="http")return;const h=o.operation.function.route();h.body!==null&&((m=h.operation().requestBody)==null?void 0:m.required)===!0&&"body"in o.arguments&&_bt(o.operation.function.parameters.$defs,o.operation.function.parameters.properties.body)&&(o.arguments.body={}),h.query!==null&&"query"in o.arguments&&o.arguments.query===void 0&&(o.arguments.query={})}function _bt(o,h){return S1.isObject(h)||S1.isReference(h)&&_bt(o,o[h.$ref.split("/").at(-1)])||S1.isAnyOf(h)&&h.anyOf.every(m=>_bt(o,m))||I1.isOneOf(h)&&h.oneOf.every(m=>_bt(o,m))}const YMn={functions:[{name:"cancelFunctions",parameters:{description:` Properties of the function
|
|
91
91
|
|
|
92
92
|
------------------------------
|
|
@@ -106,7 +106,7 @@ agent selects multiple candidate functions because the A.I. agent can't specify
|
|
|
106
106
|
only one thing due to lack of specificity or homogeneity of candidate functions.
|
|
107
107
|
|
|
108
108
|
Additionally, if you A.I. agent wants to cancel same function multiply, you can
|
|
109
|
-
do it by assigning the same function name multiply in the \`functions\` property.`,validate:(()=>{const o=G=>Array.isArray(G.functions)&&G.functions.every(J=>typeof J=="object"&&J!==null&&h(J)),h=G=>typeof G.reason=="string"&&typeof G.name=="string",m=(G,J,U=!0)=>[(Array.isArray(G.functions)||B(U,{path:J+".functions",expected:"Array<___IChatFunctionReference>",value:G.functions}))&&G.functions.map((nt,at)=>(typeof nt=="object"&&nt!==null||B(U,{path:J+".functions["+at+"]",expected:"___IChatFunctionReference",value:nt}))&&k(nt,J+".functions["+at+"]",U)||B(U,{path:J+".functions["+at+"]",expected:"___IChatFunctionReference",value:nt})).every(nt=>nt)||B(U,{path:J+".functions",expected:"Array<___IChatFunctionReference>",value:G.functions})].every(nt=>nt),k=(G,J,U=!0)=>[typeof G.reason=="string"||B(U,{path:J+".reason",expected:"string",value:G.reason}),typeof G.name=="string"||B(U,{path:J+".name",expected:"string",value:G.name})].every(nt=>nt),O=G=>typeof G=="object"&&G!==null&&o(G);let P,B;return G=>{if(O(G)===!1){P=[],B=nP(P),((U,nt,at=!0)=>(typeof U=="object"&&U!==null||B(!0,{path:nt+"",expected:"__IChatFunctionReference.IProps",value:U}))&&m(U,nt+"",!0)||B(!0,{path:nt+"",expected:"__IChatFunctionReference.IProps",value:U}))(G,"$input",!0);const J=P.length===0;return J?{success:J,data:G}:{success:J,errors:P,data:G}}return{success:!0,data:G}}})()}]};async function JMn(o){var P;if(
|
|
109
|
+
do it by assigning the same function name multiply in the \`functions\` property.`,validate:(()=>{const o=G=>Array.isArray(G.functions)&&G.functions.every(J=>typeof J=="object"&&J!==null&&h(J)),h=G=>typeof G.reason=="string"&&typeof G.name=="string",m=(G,J,U=!0)=>[(Array.isArray(G.functions)||B(U,{path:J+".functions",expected:"Array<___IChatFunctionReference>",value:G.functions}))&&G.functions.map((nt,at)=>(typeof nt=="object"&&nt!==null||B(U,{path:J+".functions["+at+"]",expected:"___IChatFunctionReference",value:nt}))&&k(nt,J+".functions["+at+"]",U)||B(U,{path:J+".functions["+at+"]",expected:"___IChatFunctionReference",value:nt})).every(nt=>nt)||B(U,{path:J+".functions",expected:"Array<___IChatFunctionReference>",value:G.functions})].every(nt=>nt),k=(G,J,U=!0)=>[typeof G.reason=="string"||B(U,{path:J+".reason",expected:"string",value:G.reason}),typeof G.name=="string"||B(U,{path:J+".name",expected:"string",value:G.name})].every(nt=>nt),O=G=>typeof G=="object"&&G!==null&&o(G);let P,B;return G=>{if(O(G)===!1){P=[],B=nP(P),((U,nt,at=!0)=>(typeof U=="object"&&U!==null||B(!0,{path:nt+"",expected:"__IChatFunctionReference.IProps",value:U}))&&m(U,nt+"",!0)||B(!0,{path:nt+"",expected:"__IChatFunctionReference.IProps",value:U}))(G,"$input",!0);const J=P.length===0;return J?{success:J,data:G}:{success:J,errors:P,data:G}}return{success:!0,data:G}}})()}]};async function JMn(o){var P;if(o.operations.divided===void 0)return Ebt(o,o.operations.array,0);const h=o.operations.divided.map(()=>[]),m=[],k=await Promise.all(o.operations.divided.map(async(B,G)=>Ebt({...o,stack:h[G],dispatch:async J=>{m.push(J)}},B,0)));if(h.every(B=>B.length===0))return k[0];if((((P=o.config)==null?void 0:P.eliticism)??nT.ELITICISM)===!0)return Ebt(o,h.flat().map(B=>o.operations.group.get(B.operation.controller.name).get(B.operation.function.name)),0);const O=smt({id:tjt(),selections:[]});for(const B of m)B.type==="select"&&(O.selections.push(B.selection),rjt(o,{name:B.selection.operation.name,reason:B.selection.reason}));return[O]}async function Ebt(o,h,m,k){var J,U,nt,at;const O=await o.request("cancel",{messages:[{role:"system",content:Gj.write(o.config)},{role:"assistant",tool_calls:[{type:"function",id:"getApiFunctions",function:{name:"getApiFunctions",arguments:JSON.stringify({})}}]},{role:"tool",tool_call_id:"getApiFunctions",content:JSON.stringify(h.map(it=>({name:it.name,description:it.function.description,...it.protocol==="http"?{method:it.function.method,path:it.function.path,tags:it.function.tags}:{}})))},...o.histories.map(Uj).flat(),{role:"user",content:o.prompt.text},{role:"system",content:((nt=(U=(J=o.config)==null?void 0:J.systemPrompt)==null?void 0:U.cancel)==null?void 0:nt.call(U,o.histories))??eP.CANCEL},...XMn(k??[])],tools:YMn.functions.map(it=>({type:"function",function:{name:it.name,description:it.description,parameters:it.parameters}})),tool_choice:"auto",parallel_tool_calls:!0}),P=await q5.readAll(O),B=g6.merge(P);if(m++<(((at=o.config)==null?void 0:at.retry)??nT.RETRY)){const it=[];for(const st of B.choices)for(const tt of st.message.tool_calls??[]){if(tt.function.name!=="cancelFunctions")continue;const Et=JSON.parse(tt.function.arguments),Lt=(()=>{const Dt=Wn=>Array.isArray(Wn.functions)&&Wn.functions.every(cr=>typeof cr=="object"&&cr!==null&&ae(cr)),ae=Wn=>typeof Wn.reason=="string"&&typeof Wn.name=="string",qt=(Wn,cr,ar=!0)=>[(Array.isArray(Wn.functions)||Mn(ar,{path:cr+".functions",expected:"Array<___IChatFunctionReference>",value:Wn.functions}))&&Wn.functions.map((mn,Vn)=>(typeof mn=="object"&&mn!==null||Mn(ar,{path:cr+".functions["+Vn+"]",expected:"___IChatFunctionReference",value:mn}))&&_e(mn,cr+".functions["+Vn+"]",ar)||Mn(ar,{path:cr+".functions["+Vn+"]",expected:"___IChatFunctionReference",value:mn})).every(mn=>mn)||Mn(ar,{path:cr+".functions",expected:"Array<___IChatFunctionReference>",value:Wn.functions})].every(mn=>mn),_e=(Wn,cr,ar=!0)=>[typeof Wn.reason=="string"||Mn(ar,{path:cr+".reason",expected:"string",value:Wn.reason}),typeof Wn.name=="string"||Mn(ar,{path:cr+".name",expected:"string",value:Wn.name})].every(mn=>mn),gn=Wn=>typeof Wn=="object"&&Wn!==null&&Dt(Wn);let ge,Mn;return Wn=>{if(gn(Wn)===!1){ge=[],Mn=nP(ge),((ar,mn,Vn=!0)=>(typeof ar=="object"&&ar!==null||Mn(!0,{path:mn+"",expected:"__IChatFunctionReference.IProps",value:ar}))&&qt(ar,mn+"",!0)||Mn(!0,{path:mn+"",expected:"__IChatFunctionReference.IProps",value:ar}))(Wn,"$input",!0);const cr=ge.length===0;return cr?{success:cr,data:Wn}:{success:cr,errors:ge,data:Wn}}return{success:!0,data:Wn}}})()(Et);Lt.success===!1&&it.push({id:tt.id,name:tt.function.name,validation:Lt})}if(it.length>0)return Ebt(o,h,m,it)}const G=[];for(const it of B.choices)if(it.message.tool_calls!=null)for(const st of it.message.tool_calls){if(st.type!=="function"||st.function.name!=="cancelFunctions")continue;const tt=(()=>{const Lt=qt=>Array.isArray(qt.functions)&&qt.functions.every(_e=>typeof _e=="object"&&_e!==null&&Dt(_e)),Dt=qt=>typeof qt.reason=="string"&&typeof qt.name=="string",ae=qt=>typeof qt=="object"&&qt!==null&&Lt(qt);return qt=>(qt=JSON.parse(qt),ae(qt)?qt:null)})()(st.function.arguments);if(tt===null)continue;const Et=smt({id:st.id,selections:[]});for(const Lt of tt.functions){const Dt=rjt(o,Lt);Dt!==null&&Et.selections.push(Dt)}Et.selections.length!==0&&G.push(Et)}return G}function XMn(o){return o.map(h=>[{role:"assistant",tool_calls:[{type:"function",id:h.id,function:{name:h.name,arguments:JSON.stringify(h.validation.data)}}]},{role:"tool",content:JSON.stringify(h.validation.errors),tool_call_id:h.id},{role:"system",content:["You A.I. assistant has composed wrong typed arguments.","","Correct it at the next function calling."].join(`
|
|
110
110
|
`)}]).flat()}class QMn{constructor(){this.queue=[],this.resolvers=[],this.closeResolvers=[],this.emptyResolvers=[],this.closed=!1}enqueue(h){var m;this.queue.push(h),this.resolvers.length>0&&((m=this.resolvers.shift())==null||m({value:this.queue.shift(),done:!1}))}async dequeue(){return this.queue.length>0?{value:this.queue.shift(),done:!1}:this.closed?(this.emptyResolvers.length>0&&(this.emptyResolvers.forEach(h=>h()),this.emptyResolvers=[]),{value:void 0,done:!0}):new Promise(h=>this.resolvers.push(h))}isEmpty(){return this.queue.length===0}isClosed(){return this.closed}done(){return this.isClosed()&&this.isEmpty()}close(){var h;for(this.closed=!0;this.resolvers.length>0;)(h=this.resolvers.shift())==null||h({value:void 0,done:!0});this.closeResolvers.forEach(m=>m())}async waitUntilEmpty(){return this.isEmpty()?Promise.resolve():new Promise(h=>{this.emptyResolvers.push(h)})}async waitClosed(){return this.isClosed()?Promise.resolve():new Promise(h=>{this.closeResolvers.push(h)})}}class P7e{constructor(){this.queue=new QMn,this.consumer=new ReadableStream({pull:async h=>{const{value:m,done:k}=await this.queue.dequeue();if(k===!0){h.close();return}h.enqueue(m)}})}produce(h){this.queue.enqueue(h)}close(){this.queue.close()}done(){return this.queue.done()}async waitClosed(){await this.queue.waitClosed()}async waitUntilEmpty(){await this.queue.waitUntilEmpty()}}async function ZMn(o,h){var B,G,J;if(h.length===0)return[];const m=await o.request("describe",{messages:[{role:"system",content:Gj.write(o.config)},...h.map(Uj).flat(),{role:"system",content:((J=(G=(B=o.config)==null?void 0:B.systemPrompt)==null?void 0:G.describe)==null?void 0:J.call(G,h))??eP.DESCRIBE}]}),k=[],O=await q5.reduce(m,async(U,nt)=>{const at=await U,it=st=>{for(const tt of st){if(tt.finish_reason!=null){k[tt.index].mpsc.close();continue}if(tt.delta.content==null)continue;if(k[tt.index]!=null){k[tt.index].content+=tt.delta.content,k[tt.index].mpsc.produce(tt.delta.content);continue}const Et=new P7e;k[tt.index]={content:tt.delta.content,mpsc:Et},Et.produce(tt.delta.content),o.dispatch(yLn({executes:h,stream:Et.consumer,done:()=>Et.done(),get:()=>{var Lt;return((Lt=k[tt.index])==null?void 0:Lt.content)??""},join:async()=>(await Et.waitClosed(),k[tt.index].content)})).catch(()=>{})}};return at.object==="chat.completion.chunk"?(it([at,nt].flatMap(st=>st.choices)),g6.merge([at,nt])):(it(nt.choices),g6.accumulate(at,nt))});if(O==null)throw new Error("No completion received");return O.choices.map(U=>U.message.role==="assistant"?U.message.content:null).filter(U=>U!==null).map(U=>E7e({executes:h,text:U}))}const sbt=[{name:"getApiFunctions",parameters:{description:"Current Type: {@link object}",type:"object",properties:{},required:[],additionalProperties:!1,$defs:{RecordstringIChatGptSchema:{description:"Construct a type with a set of properties K of type T",type:"object",properties:{},required:[],additionalProperties:{$ref:"#/$defs/IChatGptSchema"}},IChatGptSchema:{title:"Type schema info of the ChatGPT",description:`Type schema info of the ChatGPT.
|
|
111
111
|
|
|
112
112
|
\`IChatGptSchema\` is a type schema info of the ChatGPT function calling.
|
|
@@ -3175,7 +3175,7 @@ call this \`getApiFunctions()\` to get the list of candidate API functions
|
|
|
3175
3175
|
provided from this application.
|
|
3176
3176
|
|
|
3177
3177
|
Also, user just wants to list up every remote API functions that can be
|
|
3178
|
-
called from the backend server, utilize this function too.`,validate:(()=>{const o=P=>!0,h=(P,B,G=!0)=>!0,m=P=>typeof P=="object"&&P!==null&&Array.isArray(P)===!1&&o();let k,O;return P=>{if(m(P)===!1){k=[],O=nP(k),((G,J,U=!0)=>(typeof G=="object"&&G!==null&&Array.isArray(G)===!1||O(!0,{path:J+"",expected:"object",value:G}))&&h(G,J+"",!0)||O(!0,{path:J+"",expected:"object",value:G}))(P,"$input",!0);const B=k.length===0;return B?{success:B,data:P}:{success:B,errors:k,data:P}}return{success:!0,data:P}}})()}][0];async function tDn(o){var P,B,G;const h=await o.request("initialize",{messages:[{role:"system",content:Gj.write(o.config)},...o.histories.map(Uj).flat(),{role:"user",content:o.prompt.text},{role:"system",content:((G=(B=(P=o.config)==null?void 0:P.systemPrompt)==null?void 0:B.initialize)==null?void 0:G.call(B,o.histories))??eP.INITIALIZE}],tools:[{type:"function",function:{name:sbt.name,description:sbt.description,parameters:sbt.parameters}}],tool_choice:"auto",parallel_tool_calls:!1}),m=[],k=await q5.reduce(h,async(J,U)=>{const nt=await J,at=it=>{var st;for(const tt of it){if(tt.finish_reason!=null){(st=m[tt.index])==null||st.mpsc.close();continue}if(tt.delta.content==null)continue;if(m[tt.index]!=null){m[tt.index].content+=tt.delta.content,m[tt.index].mpsc.produce(tt.delta.content);continue}const Et=new P7e;m[tt.index]={content:tt.delta.content,mpsc:Et},Et.produce(tt.delta.content),o.dispatch(cmt({role:"assistant",stream:Et.consumer,done:()=>Et.done(),get:()=>m[tt.index].content,join:async()=>(await Et.waitClosed(),m[tt.index].content)})).catch(()=>{})}};return nt.object==="chat.completion.chunk"?(at([nt,U].flatMap(it=>it.choices)),g6.merge([nt,U])):(at(U.choices),g6.accumulate(nt,U))});if(k===null)throw new Error("No completion received");const O=[];for(const J of k.choices)J.message.role==="assistant"&&J.message.content!=null&&O.push(PX({role:"assistant",text:J.message.content}));return k.choices.some(J=>J.message.tool_calls!=null&&J.message.tool_calls.some(U=>U.type==="function"&&U.function.name===sbt.name))&&await o.initialize(),O}async function L7e(o,h){const m=o.operations.flat.get(h.name);if(m===void 0)return null;const k=qj({operation:m,reason:h.reason});return o.stack.push(k),o.dispatch(gLn({selection:k})).catch(()=>{}),m}const eDn={functions:[{name:"selectFunctions",parameters:{description:` Properties of the function
|
|
3178
|
+
called from the backend server, utilize this function too.`,validate:(()=>{const o=P=>!0,h=(P,B,G=!0)=>!0,m=P=>typeof P=="object"&&P!==null&&Array.isArray(P)===!1&&o();let k,O;return P=>{if(m(P)===!1){k=[],O=nP(k),((G,J,U=!0)=>(typeof G=="object"&&G!==null&&Array.isArray(G)===!1||O(!0,{path:J+"",expected:"object",value:G}))&&h(G,J+"",!0)||O(!0,{path:J+"",expected:"object",value:G}))(P,"$input",!0);const B=k.length===0;return B?{success:B,data:P}:{success:B,errors:k,data:P}}return{success:!0,data:P}}})()}][0];async function tDn(o){var P,B,G;const h=await o.request("initialize",{messages:[{role:"system",content:Gj.write(o.config)},...o.histories.map(Uj).flat(),{role:"user",content:o.prompt.text},{role:"system",content:((G=(B=(P=o.config)==null?void 0:P.systemPrompt)==null?void 0:B.initialize)==null?void 0:G.call(B,o.histories))??eP.INITIALIZE}],tools:[{type:"function",function:{name:sbt.name,description:sbt.description,parameters:sbt.parameters}}],tool_choice:"auto",parallel_tool_calls:!1}),m=[],k=await q5.reduce(h,async(J,U)=>{const nt=await J,at=it=>{var st;for(const tt of it){if(tt.finish_reason!=null){(st=m[tt.index])==null||st.mpsc.close();continue}if(tt.delta.content==null||tt.delta.content.length===0)continue;if(m[tt.index]!=null){m[tt.index].content+=tt.delta.content,m[tt.index].mpsc.produce(tt.delta.content);continue}const Et=new P7e;m[tt.index]={content:tt.delta.content,mpsc:Et},Et.produce(tt.delta.content),o.dispatch(cmt({role:"assistant",stream:Et.consumer,done:()=>Et.done(),get:()=>m[tt.index].content,join:async()=>(await Et.waitClosed(),m[tt.index].content)})).catch(()=>{})}};return nt.object==="chat.completion.chunk"?(at([nt,U].flatMap(it=>it.choices)),g6.merge([nt,U])):(at(U.choices),g6.accumulate(nt,U))});if(k===null)throw new Error("No completion received");const O=[];for(const J of k.choices)J.message.role==="assistant"&&J.message.content!=null&&J.message.content.length!==0&&O.push(PX({role:"assistant",text:J.message.content}));return k.choices.some(J=>J.message.tool_calls!=null&&J.message.tool_calls.some(U=>U.type==="function"&&U.function.name===sbt.name))&&await o.initialize(),O}async function L7e(o,h){const m=o.operations.flat.get(h.name);if(m===void 0)return null;const k=qj({operation:m,reason:h.reason});return o.stack.push(k),o.dispatch(gLn({selection:k})).catch(()=>{}),m}const eDn={functions:[{name:"selectFunctions",parameters:{description:` Properties of the function
|
|
3179
3179
|
|
|
3180
3180
|
------------------------------
|
|
3181
3181
|
|
|
@@ -3195,8 +3195,8 @@ them all into the \`functions\` property.
|
|
|
3195
3195
|
Also, if you A.I. agent can't specify a specific function to call due to lack
|
|
3196
3196
|
of specificity or homogeneity of candidate functions, just assign all of them
|
|
3197
3197
|
by in the\` functions\` property\` too. Instead, when you A.I. agent can specify
|
|
3198
|
-
a specific function to call, the others would be eliminated.`,validate:(()=>{const o=G=>Array.isArray(G.functions)&&G.functions.every(J=>typeof J=="object"&&J!==null&&h(J)),h=G=>typeof G.reason=="string"&&typeof G.name=="string",m=(G,J,U=!0)=>[(Array.isArray(G.functions)||B(U,{path:J+".functions",expected:"Array<___IChatFunctionReference>",value:G.functions}))&&G.functions.map((nt,at)=>(typeof nt=="object"&&nt!==null||B(U,{path:J+".functions["+at+"]",expected:"___IChatFunctionReference",value:nt}))&&k(nt,J+".functions["+at+"]",U)||B(U,{path:J+".functions["+at+"]",expected:"___IChatFunctionReference",value:nt})).every(nt=>nt)||B(U,{path:J+".functions",expected:"Array<___IChatFunctionReference>",value:G.functions})].every(nt=>nt),k=(G,J,U=!0)=>[typeof G.reason=="string"||B(U,{path:J+".reason",expected:"string",value:G.reason}),typeof G.name=="string"||B(U,{path:J+".name",expected:"string",value:G.name})].every(nt=>nt),O=G=>typeof G=="object"&&G!==null&&o(G);let P,B;return G=>{if(O(G)===!1){P=[],B=nP(P),((U,nt,at=!0)=>(typeof U=="object"&&U!==null||B(!0,{path:nt+"",expected:"__IChatFunctionReference.IProps",value:U}))&&m(U,nt+"",!0)||B(!0,{path:nt+"",expected:"__IChatFunctionReference.IProps",value:U}))(G,"$input",!0);const J=P.length===0;return J?{success:J,data:G}:{success:J,errors:P,data:G}}return{success:!0,data:G}}})()}]};async function nDn(o){var P;if(o.operations.divided===void 0)return Tbt(o,o.operations.array,0);const h=o.operations.divided.map(()=>[]),m=[],k=await Promise.all(o.operations.divided.map(async(B,G)=>Tbt({...o,stack:h[G],dispatch:async J=>{m.push(J)}},B,0)));if(h.every(B=>B.length===0))return k[0];if((((P=o.config)==null?void 0:P.eliticism)??nT.ELITICISM)===!0)return Tbt(o,h.flat().map(B=>o.operations.group.get(B.operation.controller.name).get(B.operation.function.name)),0);const O=omt({id:tjt(),selections:[]});for(const B of m)B.type==="select"&&(O.selections.push(B.selection),await L7e(o,{name:B.selection.operation.name,reason:B.selection.reason}));return[O]}async function Tbt(o,h,m,k){var J,U,nt,at;const O=await o.request("select",{messages:[{role:"system",content:Gj.write(o.config)},{role:"assistant",tool_calls:[{type:"function",id:"getApiFunctions",function:{name:"getApiFunctions",arguments:JSON.stringify({})}}]},{role:"tool",tool_call_id:"getApiFunctions",content:JSON.stringify(h.map(it=>({name:it.name,description:it.function.description,...it.protocol==="http"?{method:it.function.method,path:it.function.path,tags:it.function.tags}:{}})))},...o.histories.map(Uj).flat(),{role:"user",content:o.prompt.text},{role:"system",content:((nt=(U=(J=o.config)==null?void 0:J.systemPrompt)==null?void 0:U.select)==null?void 0:nt.call(U,o.histories))??eP.SELECT},...rDn(k??[])],tools:eDn.functions.map(it=>({type:"function",function:{name:it.name,description:it.description,parameters:it.parameters}})),tool_choice:"auto",parallel_tool_calls:!1}),P=await q5.readAll(O),B=g6.merge(P);if(m++<(((at=o.config)==null?void 0:at.retry)??nT.RETRY)){const it=[];for(const st of B.choices)for(const tt of st.message.tool_calls??[]){if(tt.function.name!=="selectFunctions")continue;const Et=JSON.parse(tt.function.arguments),Lt=(()=>{const Dt=Wn=>Array.isArray(Wn.functions)&&Wn.functions.every(cr=>typeof cr=="object"&&cr!==null&&ae(cr)),ae=Wn=>typeof Wn.reason=="string"&&typeof Wn.name=="string",qt=(Wn,cr,ar=!0)=>[(Array.isArray(Wn.functions)||Mn(ar,{path:cr+".functions",expected:"Array<___IChatFunctionReference>",value:Wn.functions}))&&Wn.functions.map((mn,Vn)=>(typeof mn=="object"&&mn!==null||Mn(ar,{path:cr+".functions["+Vn+"]",expected:"___IChatFunctionReference",value:mn}))&&_e(mn,cr+".functions["+Vn+"]",ar)||Mn(ar,{path:cr+".functions["+Vn+"]",expected:"___IChatFunctionReference",value:mn})).every(mn=>mn)||Mn(ar,{path:cr+".functions",expected:"Array<___IChatFunctionReference>",value:Wn.functions})].every(mn=>mn),_e=(Wn,cr,ar=!0)=>[typeof Wn.reason=="string"||Mn(ar,{path:cr+".reason",expected:"string",value:Wn.reason}),typeof Wn.name=="string"||Mn(ar,{path:cr+".name",expected:"string",value:Wn.name})].every(mn=>mn),gn=Wn=>typeof Wn=="object"&&Wn!==null&&Dt(Wn);let ge,Mn;return Wn=>{if(gn(Wn)===!1){ge=[],Mn=nP(ge),((ar,mn,Vn=!0)=>(typeof ar=="object"&&ar!==null||Mn(!0,{path:mn+"",expected:"__IChatFunctionReference.IProps",value:ar}))&&qt(ar,mn+"",!0)||Mn(!0,{path:mn+"",expected:"__IChatFunctionReference.IProps",value:ar}))(Wn,"$input",!0);const cr=ge.length===0;return cr?{success:cr,data:Wn}:{success:cr,errors:ge,data:Wn}}return{success:!0,data:Wn}}})()(Et);Lt.success===!1&&it.push({id:tt.id,name:tt.function.name,validation:Lt})}if(it.length>0)return Tbt(o,h,m,it)}const G=[];for(const it of B.choices){if(it.message.tool_calls!=null)for(const st of it.message.tool_calls){if(st.type!=="function"||st.function.name!=="selectFunctions")continue;const tt=(()=>{const Lt=qt=>Array.isArray(qt.functions)&&qt.functions.every(_e=>typeof _e=="object"&&_e!==null&&Dt(_e)),Dt=qt=>typeof qt.reason=="string"&&typeof qt.name=="string",ae=qt=>typeof qt=="object"&&qt!==null&&Lt(qt);return qt=>(qt=JSON.parse(qt),ae(qt)?qt:null)})()(st.function.arguments);if(tt===null)continue;const Et=omt({id:st.id,selections:[]});for(const Lt of tt.functions){const Dt=await L7e(o,Lt);Dt!==null&&Et.selections.push(qj({operation:Dt,reason:Lt.reason}))}Et.selections.length!==0&&G.push(Et)}if(it.message.role==="assistant"&&it.message.content!=null){const st=PX({role:"assistant",text:it.message.content});G.push(st),
|
|
3199
|
-
`)}]).flat()}function iDn(o){return async h=>{const m=[];if(h.ready()===!1){if((o==null?void 0:o.initialize)===null)await h.initialize();else if(m.push(...await((o==null?void 0:o.initialize)??tDn)(h)),h.ready()===!1)return m}if(h.stack.length!==0&&m.push(...await((o==null?void 0:o.cancel)??JMn)(h)),m.push(...await((o==null?void 0:o.select)??nDn)(h)),h.stack.length===0)return m;for(;;){const k=await((o==null?void 0:o.call)??qMn)(h,h.stack.map(P=>P.operation));m.push(...k);const O=k.filter(P=>P.type==="execute");if(m.push(...await((o==null?void 0:o.describe)??ZMn)(h,O)),O.length===0||h.stack.length===0)break}return m}}function aDn(o){if(o.history.type==="text")return M7e({history:o.history});if(o.history.type==="select")return D7e({operations:o.operations,history:o.history});if(o.history.type==="cancel")return R7e({operations:o.operations,history:o.history});if(o.history.type==="execute")return ijt({operations:o.operations,history:o.history});if(o.history.type==="describe")return B7e({operations:o.operations,history:o.history});throw new Error("Invalid prompt type.")}function M7e(o){return PX(o.history)}function D7e(o){return omt({id:o.history.id,selections:o.history.selections.map(h=>qj({operation:ajt({operations:o.operations,input:h.operation}),reason:h.reason}))})}function R7e(o){return smt({id:o.history.id,selections:o.history.selections.map(h=>qj({operation:ajt({operations:o.operations,input:h.operation}),reason:h.reason}))})}function ijt(o){return $N({id:o.history.id,operation:ajt({operations:o.operations,input:o.history.operation}),arguments:o.history.arguments,value:o.history.value})}function B7e(o){return E7e({text:o.history.text,executes:o.history.executes.map(h=>ijt({operations:o.operations,history:h}))})}function ajt(o){var m;const h=(m=o.operations.get(o.input.controller))==null?void 0:m.get(o.input.function);if(h===void 0)throw new Error(`No operation found: (controller: ${o.input.controller}, function: ${o.input.function})`);return h}const oDn={transform:aDn,transformText:M7e,transformSelect:D7e,transformCancel:R7e,transformExecute:ijt,transformDescribe:B7e};class j7e{constructor(h){var m,k;this.props=h,this.operations_=sLn.compose({controllers:h.controllers,config:h.config}),this.stack_=[],this.listeners_=new Map,this.histories_=(h.histories??[]).map(O=>oDn.transform({operations:this.operations_.group,history:O})),this.token_usage_=lX.zero(),this.ready_=!1,this.executor_=typeof((m=h.config)==null?void 0:m.executor)=="function"?h.config.executor:iDn(((k=h.config)==null?void 0:k.executor)??null)}clone(){var h;return new j7e({...this.props,histories:(h=this.props.histories)==null?void 0:h.slice()})}async conversate(h){const m=PX({role:"user",text:h});await this.dispatch(cmt({role:"user",stream:q5.to(h),done:()=>!0,get:()=>h,join:async()=>Promise.resolve(h)}));const k=await this.executor_(this.getContext({prompt:m,usage:this.token_usage_}));return this.histories_.push(m,...k),[m,...k]}getConfig(){return this.props.config}getVendor(){return this.props.vendor}getControllers(){return this.props.controllers}getOperations(){return this.operations_.array}getHistories(){return this.histories_}getTokenUsage(){return this.token_usage_}getContext(h){const m=async k=>this.dispatch(k);return{operations:this.operations_,config:this.props.config,histories:this.histories_,stack:this.stack_,ready:()=>this.ready_,prompt:h.prompt,dispatch:async k=>this.dispatch(k),request:async(k,O)=>{const P=wLn({source:k,body:{...O,model:this.props.vendor.model,stream:!0,stream_options:{include_usage:!0}},options:this.props.vendor.options});await m(P);const B=await this.props.vendor.api.chat.completions.create(P.body,P.options),[G,J]=q5.transform(B.toReadableStream(),st=>g6.transformCompletionChunk(st)).tee(),[U,nt]=J.tee();(async()=>{const st=U.getReader();for(;;){const tt=await st.read();if(tt.done)break;tt.value.usage!=null&&uLn.aggregate({kind:k,completionUsage:tt.value.usage,usage:h.usage})}})().catch(()=>{});const[at,it]=G.tee();return await m({type:"response",source:k,stream:at,body:P.body,options:P.options,join:async()=>{const st=await q5.readAll(it);return g6.merge(st)}}),nt},initialize:async()=>{this.ready_=!0,await m(pLn())}}}on(h,m){return _7e(this.listeners_,h,()=>new Set).add(m),this}off(h,m){const k=this.listeners_.get(h);return k!==void 0&&(k.delete(m),k.size===0&&this.listeners_.delete(h)),this}async dispatch(h){const m=this.listeners_.get(h.type);m!==void 0&&await Promise.all(Array.from(m).map(async k=>{try{await k(h)}catch{}}))}}const hBt="RFC3986",fBt={RFC1738:o=>String(o).replace(/%20/g,"+"),RFC3986:o=>String(o)},sDn="RFC1738",cDn=Array.isArray,s6=(()=>{const o=[];for(let h=0;h<256;++h)o.push("%"+((h<16?"0":"")+h.toString(16)).toUpperCase());return o})(),rRt=1024,uDn=(o,h,m,k,O)=>{if(o.length===0)return o;let P=o;if(typeof o=="symbol"?P=Symbol.prototype.toString.call(o):typeof o!="string"&&(P=String(o)),m==="iso-8859-1")return escape(P).replace(/%u[0-9a-f]{4}/gi,function(G){return"%26%23"+parseInt(G.slice(2),16)+"%3B"});let B="";for(let G=0;G<P.length;G+=rRt){const J=P.length>=rRt?P.slice(G,G+rRt):P,U=[];for(let nt=0;nt<J.length;++nt){let at=J.charCodeAt(nt);if(at===45||at===46||at===95||at===126||at>=48&&at<=57||at>=65&&at<=90||at>=97&&at<=122||O===sDn&&(at===40||at===41)){U[U.length]=J.charAt(nt);continue}if(at<128){U[U.length]=s6[at];continue}if(at<2048){U[U.length]=s6[192|at>>6]+s6[128|at&63];continue}if(at<55296||at>=57344){U[U.length]=s6[224|at>>12]+s6[128|at>>6&63]+s6[128|at&63];continue}nt+=1,at=65536+((at&1023)<<10|J.charCodeAt(nt)&1023),U[U.length]=s6[240|at>>18]+s6[128|at>>12&63]+s6[128|at>>6&63]+s6[128|at&63]}B+=U.join("")}return B};function lDn(o){return!o||typeof o!="object"?!1:!!(o.constructor&&o.constructor.isBuffer&&o.constructor.isBuffer(o))}function Y8e(o,h){if(cDn(o)){const m=[];for(let k=0;k<o.length;k+=1)m.push(h(o[k]));return m}return h(o)}const hDn=Object.prototype.hasOwnProperty,F7e={brackets(o){return String(o)+"[]"},comma:"comma",indices(o,h){return String(o)+"["+h+"]"},repeat(o){return String(o)}},u6=Array.isArray,fDn=Array.prototype.push,$7e=function(o,h){fDn.apply(o,u6(h)?h:[h])},dDn=Date.prototype.toISOString,Jp={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:uDn,encodeValuesOnly:!1,format:hBt,formatter:fBt[hBt],indices:!1,serializeDate(o){return dDn.call(o)},skipNulls:!1,strictNullHandling:!1};function pDn(o){return typeof o=="string"||typeof o=="number"||typeof o=="boolean"||typeof o=="symbol"||typeof o=="bigint"}const iRt={};function H7e(o,h,m,k,O,P,B,G,J,U,nt,at,it,st,tt,Et,Lt,Dt){let ae=o,qt=Dt,_e=0,gn=!1;for(;(qt=qt.get(iRt))!==void 0&&!gn;){const ar=qt.get(o);if(_e+=1,typeof ar<"u"){if(ar===_e)throw new RangeError("Cyclic object value");gn=!0}typeof qt.get(iRt)>"u"&&(_e=0)}if(typeof U=="function"?ae=U(h,ae):ae instanceof Date?ae=it==null?void 0:it(ae):m==="comma"&&u6(ae)&&(ae=Y8e(ae,function(ar){return ar instanceof Date?it==null?void 0:it(ar):ar})),ae===null){if(P)return J&&!Et?J(h,Jp.encoder,Lt,"key",st):h;ae=""}if(pDn(ae)||lDn(ae)){if(J){const ar=Et?h:J(h,Jp.encoder,Lt,"key",st);return[(tt==null?void 0:tt(ar))+"="+(tt==null?void 0:tt(J(ae,Jp.encoder,Lt,"value",st)))]}return[(tt==null?void 0:tt(h))+"="+(tt==null?void 0:tt(String(ae)))]}const ge=[];if(typeof ae>"u")return ge;let Mn;if(m==="comma"&&u6(ae))Et&&J&&(ae=Y8e(ae,J)),Mn=[{value:ae.length>0?ae.join(",")||null:void 0}];else if(u6(U))Mn=U;else{const ar=Object.keys(ae);Mn=nt?ar.sort(nt):ar}const Wn=G?String(h).replace(/\./g,"%2E"):String(h),cr=k&&u6(ae)&&ae.length===1?Wn+"[]":Wn;if(O&&u6(ae)&&ae.length===0)return cr+"[]";for(let ar=0;ar<Mn.length;++ar){const mn=Mn[ar],Vn=typeof mn=="object"&&typeof mn.value<"u"?mn.value:ae[mn];if(B&&Vn===null)continue;const hi=at&&G?mn.replace(/\./g,"%2E"):mn,$n=u6(ae)?typeof m=="function"?m(cr,hi):cr:cr+(at?"."+hi:"["+hi+"]");Dt.set(o,_e);const Vt=new WeakMap;Vt.set(iRt,Dt),$7e(ge,H7e(Vn,$n,m,k,O,P,B,G,m==="comma"&&Et&&u6(ae)?null:J,U,nt,at,it,st,tt,Et,Lt,Vt))}return ge}function gDn(o=Jp){if(typeof o.allowEmptyArrays<"u"&&typeof o.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof o.encodeDotInKeys<"u"&&typeof o.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(o.encoder!==null&&typeof o.encoder<"u"&&typeof o.encoder!="function")throw new TypeError("Encoder has to be a function.");const h=o.charset||Jp.charset;if(typeof o.charset<"u"&&o.charset!=="utf-8"&&o.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let m=hBt;if(typeof o.format<"u"){if(!hDn.call(fBt,o.format))throw new TypeError("Unknown format option provided.");m=o.format}const k=fBt[m];let O=Jp.filter;(typeof o.filter=="function"||u6(o.filter))&&(O=o.filter);let P;if(o.arrayFormat&&o.arrayFormat in F7e?P=o.arrayFormat:"indices"in o?P=o.indices?"indices":"repeat":P=Jp.arrayFormat,"commaRoundTrip"in o&&typeof o.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const B=typeof o.allowDots>"u"?o.encodeDotInKeys?!0:Jp.allowDots:!!o.allowDots;return{addQueryPrefix:typeof o.addQueryPrefix=="boolean"?o.addQueryPrefix:Jp.addQueryPrefix,allowDots:B,allowEmptyArrays:typeof o.allowEmptyArrays=="boolean"?!!o.allowEmptyArrays:Jp.allowEmptyArrays,arrayFormat:P,charset:h,charsetSentinel:typeof o.charsetSentinel=="boolean"?o.charsetSentinel:Jp.charsetSentinel,commaRoundTrip:!!o.commaRoundTrip,delimiter:typeof o.delimiter>"u"?Jp.delimiter:o.delimiter,encode:typeof o.encode=="boolean"?o.encode:Jp.encode,encodeDotInKeys:typeof o.encodeDotInKeys=="boolean"?o.encodeDotInKeys:Jp.encodeDotInKeys,encoder:typeof o.encoder=="function"?o.encoder:Jp.encoder,encodeValuesOnly:typeof o.encodeValuesOnly=="boolean"?o.encodeValuesOnly:Jp.encodeValuesOnly,filter:O,format:m,formatter:k,serializeDate:typeof o.serializeDate=="function"?o.serializeDate:Jp.serializeDate,skipNulls:typeof o.skipNulls=="boolean"?o.skipNulls:Jp.skipNulls,sort:typeof o.sort=="function"?o.sort:null,strictNullHandling:typeof o.strictNullHandling=="boolean"?o.strictNullHandling:Jp.strictNullHandling}}function bDn(o,h={}){let m=o;const k=gDn(h);let O,P;typeof k.filter=="function"?(P=k.filter,m=P("",m)):u6(k.filter)&&(P=k.filter,O=P);const B=[];if(typeof m!="object"||m===null)return"";const G=F7e[k.arrayFormat],J=G==="comma"&&k.commaRoundTrip;O||(O=Object.keys(m)),k.sort&&O.sort(k.sort);const U=new WeakMap;for(let it=0;it<O.length;++it){const st=O[it];k.skipNulls&&m[st]===null||$7e(B,H7e(m[st],st,G,J,k.allowEmptyArrays,k.strictNullHandling,k.skipNulls,k.encodeDotInKeys,k.encode?k.encoder:null,k.filter,k.sort,k.allowDots,k.serializeDate,k.format,k.formatter,k.encodeValuesOnly,k.charset,U))}const nt=B.join(k.delimiter);let at=k.addQueryPrefix===!0?"?":"";return k.charsetSentinel&&(k.charset==="iso-8859-1"?at+="utf8=%26%2310003%3B&":at+="utf8=%E2%9C%93&"),nt.length>0?at+nt:""}const xj="4.91.1";let J8e=!1,hX,z7e,U7e,dBt,G7e,q7e,W7e,K7e,V7e;function mDn(o,h={auto:!1}){if(J8e)throw new Error(`you must \`import 'openai/shims/${o.kind}'\` before importing anything else from openai`);if(hX)throw new Error(`can't \`import 'openai/shims/${o.kind}'\` after \`import 'openai/shims/${hX}'\``);J8e=h.auto,hX=o.kind,z7e=o.fetch,U7e=o.FormData,dBt=o.File,G7e=o.ReadableStream,q7e=o.getMultipartRequestOptions,W7e=o.getDefaultAgent,K7e=o.fileFromPath,V7e=o.isFsReadStream}class yDn{constructor(h){this.body=h}get[Symbol.toStringTag](){return"MultipartBody"}}function wDn({manuallyImported:o}={}){const h=o?"You may need to use polyfills":"Add one of these imports before your first `import … from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n";let m,k,O,P;try{m=fetch,k=Request,O=Response,P=Headers}catch(B){throw new Error(`this environment is missing the following Web Fetch API type: ${B.message}. ${h}`)}return{kind:"web",fetch:m,Request:k,Response:O,Headers:P,FormData:typeof FormData<"u"?FormData:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${h}`)}},Blob:typeof Blob<"u"?Blob:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${h}`)}},File:typeof File<"u"?File:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${h}`)}},ReadableStream:typeof ReadableStream<"u"?ReadableStream:class{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${h}`)}},getMultipartRequestOptions:async(B,G)=>({...G,body:new yDn(B)}),getDefaultAgent:B=>{},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:B=>!1}}const Y7e=()=>{hX||mDn(wDn(),{auto:!0})};Y7e();class Cs extends Error{}class Ig extends Cs{constructor(h,m,k,O){super(`${Ig.makeMessage(h,m,k)}`),this.status=h,this.headers=O,this.request_id=O==null?void 0:O["x-request-id"],this.error=m;const P=m;this.code=P==null?void 0:P.code,this.param=P==null?void 0:P.param,this.type=P==null?void 0:P.type}static makeMessage(h,m,k){const O=m!=null&&m.message?typeof m.message=="string"?m.message:JSON.stringify(m.message):m?JSON.stringify(m):k;return h&&O?`${h} ${O}`:h?`${h} status code (no body)`:O||"(no status code or body)"}static generate(h,m,k,O){if(!h||!O)return new umt({message:k,cause:gBt(m)});const P=m==null?void 0:m.error;return h===400?new J7e(h,P,k,O):h===401?new X7e(h,P,k,O):h===403?new Q7e(h,P,k,O):h===404?new Z7e(h,P,k,O):h===409?new t9e(h,P,k,O):h===422?new e9e(h,P,k,O):h===429?new n9e(h,P,k,O):h>=500?new r9e(h,P,k,O):new Ig(h,P,k,O)}}class x3 extends Ig{constructor({message:h}={}){super(void 0,void 0,h||"Request was aborted.",void 0)}}class umt extends Ig{constructor({message:h,cause:m}){super(void 0,void 0,h||"Connection error.",void 0),m&&(this.cause=m)}}class ojt extends umt{constructor({message:h}={}){super({message:h??"Request timed out."})}}class J7e extends Ig{}class X7e extends Ig{}class Q7e extends Ig{}class Z7e extends Ig{}class t9e extends Ig{}class e9e extends Ig{}class n9e extends Ig{}class r9e extends Ig{}class i9e extends Cs{constructor(){super("Could not parse response content as the length limit was reached")}}class a9e extends Cs{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var cbt=function(o,h,m,k,O){if(k==="m")throw new TypeError("Private method is not writable");if(k==="a"&&!O)throw new TypeError("Private accessor was defined without a setter");if(typeof h=="function"?o!==h||!O:!h.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return k==="a"?O.call(o,m):O?O.value=m:h.set(o,m),m},BN=function(o,h,m,k){if(m==="a"&&!k)throw new TypeError("Private accessor was defined without a getter");if(typeof h=="function"?o!==h||!k:!h.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return m==="m"?k:m==="a"?k.call(o):k?k.value:h.get(o)},gw;class lmt{constructor(){gw.set(this,void 0),this.buffer=new Uint8Array,cbt(this,gw,null,"f")}decode(h){if(h==null)return[];const m=h instanceof ArrayBuffer?new Uint8Array(h):typeof h=="string"?new TextEncoder().encode(h):h;let k=new Uint8Array(this.buffer.length+m.length);k.set(this.buffer),k.set(m,this.buffer.length),this.buffer=k;const O=[];let P;for(;(P=vDn(this.buffer,BN(this,gw,"f")))!=null;){if(P.carriage&&BN(this,gw,"f")==null){cbt(this,gw,P.index,"f");continue}if(BN(this,gw,"f")!=null&&(P.index!==BN(this,gw,"f")+1||P.carriage)){O.push(this.decodeText(this.buffer.slice(0,BN(this,gw,"f")-1))),this.buffer=this.buffer.slice(BN(this,gw,"f")),cbt(this,gw,null,"f");continue}const B=BN(this,gw,"f")!==null?P.preceding-1:P.preceding,G=this.decodeText(this.buffer.slice(0,B));O.push(G),this.buffer=this.buffer.slice(P.index),cbt(this,gw,null,"f")}return O}decodeText(h){if(h==null)return"";if(typeof h=="string")return h;if(typeof Buffer<"u"){if(h instanceof Buffer)return h.toString();if(h instanceof Uint8Array)return Buffer.from(h).toString();throw new Cs(`Unexpected: received non-Uint8Array (${h.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if(h instanceof Uint8Array||h instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(h);throw new Cs(`Unexpected: received non-Uint8Array/ArrayBuffer (${h.constructor.name}) in a web platform. Please report this error.`)}throw new Cs("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){return this.buffer.length?this.decode(`
|
|
3198
|
+
a specific function to call, the others would be eliminated.`,validate:(()=>{const o=G=>Array.isArray(G.functions)&&G.functions.every(J=>typeof J=="object"&&J!==null&&h(J)),h=G=>typeof G.reason=="string"&&typeof G.name=="string",m=(G,J,U=!0)=>[(Array.isArray(G.functions)||B(U,{path:J+".functions",expected:"Array<___IChatFunctionReference>",value:G.functions}))&&G.functions.map((nt,at)=>(typeof nt=="object"&&nt!==null||B(U,{path:J+".functions["+at+"]",expected:"___IChatFunctionReference",value:nt}))&&k(nt,J+".functions["+at+"]",U)||B(U,{path:J+".functions["+at+"]",expected:"___IChatFunctionReference",value:nt})).every(nt=>nt)||B(U,{path:J+".functions",expected:"Array<___IChatFunctionReference>",value:G.functions})].every(nt=>nt),k=(G,J,U=!0)=>[typeof G.reason=="string"||B(U,{path:J+".reason",expected:"string",value:G.reason}),typeof G.name=="string"||B(U,{path:J+".name",expected:"string",value:G.name})].every(nt=>nt),O=G=>typeof G=="object"&&G!==null&&o(G);let P,B;return G=>{if(O(G)===!1){P=[],B=nP(P),((U,nt,at=!0)=>(typeof U=="object"&&U!==null||B(!0,{path:nt+"",expected:"__IChatFunctionReference.IProps",value:U}))&&m(U,nt+"",!0)||B(!0,{path:nt+"",expected:"__IChatFunctionReference.IProps",value:U}))(G,"$input",!0);const J=P.length===0;return J?{success:J,data:G}:{success:J,errors:P,data:G}}return{success:!0,data:G}}})()}]};async function nDn(o){var P;if(o.operations.divided===void 0)return Tbt(o,o.operations.array,0);const h=o.operations.divided.map(()=>[]),m=[],k=await Promise.all(o.operations.divided.map(async(B,G)=>Tbt({...o,stack:h[G],dispatch:async J=>{m.push(J)}},B,0)));if(h.every(B=>B.length===0))return k[0];if((((P=o.config)==null?void 0:P.eliticism)??nT.ELITICISM)===!0)return Tbt(o,h.flat().map(B=>o.operations.group.get(B.operation.controller.name).get(B.operation.function.name)),0);const O=omt({id:tjt(),selections:[]});for(const B of m)B.type==="select"&&(O.selections.push(B.selection),await L7e(o,{name:B.selection.operation.name,reason:B.selection.reason}));return[O]}async function Tbt(o,h,m,k){var J,U,nt,at;const O=await o.request("select",{messages:[{role:"system",content:Gj.write(o.config)},{role:"assistant",tool_calls:[{type:"function",id:"getApiFunctions",function:{name:"getApiFunctions",arguments:JSON.stringify({})}}]},{role:"tool",tool_call_id:"getApiFunctions",content:JSON.stringify(h.map(it=>({name:it.name,description:it.function.description,...it.protocol==="http"?{method:it.function.method,path:it.function.path,tags:it.function.tags}:{}})))},...o.histories.map(Uj).flat(),{role:"user",content:o.prompt.text},{role:"system",content:((nt=(U=(J=o.config)==null?void 0:J.systemPrompt)==null?void 0:U.select)==null?void 0:nt.call(U,o.histories))??eP.SELECT},...rDn(k??[])],tools:eDn.functions.map(it=>({type:"function",function:{name:it.name,description:it.description,parameters:it.parameters}})),tool_choice:"auto",parallel_tool_calls:!1}),P=await q5.readAll(O),B=g6.merge(P);if(m++<(((at=o.config)==null?void 0:at.retry)??nT.RETRY)){const it=[];for(const st of B.choices)for(const tt of st.message.tool_calls??[]){if(tt.function.name!=="selectFunctions")continue;const Et=JSON.parse(tt.function.arguments),Lt=(()=>{const Dt=Wn=>Array.isArray(Wn.functions)&&Wn.functions.every(cr=>typeof cr=="object"&&cr!==null&&ae(cr)),ae=Wn=>typeof Wn.reason=="string"&&typeof Wn.name=="string",qt=(Wn,cr,ar=!0)=>[(Array.isArray(Wn.functions)||Mn(ar,{path:cr+".functions",expected:"Array<___IChatFunctionReference>",value:Wn.functions}))&&Wn.functions.map((mn,Vn)=>(typeof mn=="object"&&mn!==null||Mn(ar,{path:cr+".functions["+Vn+"]",expected:"___IChatFunctionReference",value:mn}))&&_e(mn,cr+".functions["+Vn+"]",ar)||Mn(ar,{path:cr+".functions["+Vn+"]",expected:"___IChatFunctionReference",value:mn})).every(mn=>mn)||Mn(ar,{path:cr+".functions",expected:"Array<___IChatFunctionReference>",value:Wn.functions})].every(mn=>mn),_e=(Wn,cr,ar=!0)=>[typeof Wn.reason=="string"||Mn(ar,{path:cr+".reason",expected:"string",value:Wn.reason}),typeof Wn.name=="string"||Mn(ar,{path:cr+".name",expected:"string",value:Wn.name})].every(mn=>mn),gn=Wn=>typeof Wn=="object"&&Wn!==null&&Dt(Wn);let ge,Mn;return Wn=>{if(gn(Wn)===!1){ge=[],Mn=nP(ge),((ar,mn,Vn=!0)=>(typeof ar=="object"&&ar!==null||Mn(!0,{path:mn+"",expected:"__IChatFunctionReference.IProps",value:ar}))&&qt(ar,mn+"",!0)||Mn(!0,{path:mn+"",expected:"__IChatFunctionReference.IProps",value:ar}))(Wn,"$input",!0);const cr=ge.length===0;return cr?{success:cr,data:Wn}:{success:cr,errors:ge,data:Wn}}return{success:!0,data:Wn}}})()(Et);Lt.success===!1&&it.push({id:tt.id,name:tt.function.name,validation:Lt})}if(it.length>0)return Tbt(o,h,m,it)}const G=[];for(const it of B.choices){if(it.message.tool_calls!=null)for(const st of it.message.tool_calls){if(st.type!=="function"||st.function.name!=="selectFunctions")continue;const tt=(()=>{const Lt=qt=>Array.isArray(qt.functions)&&qt.functions.every(_e=>typeof _e=="object"&&_e!==null&&Dt(_e)),Dt=qt=>typeof qt.reason=="string"&&typeof qt.name=="string",ae=qt=>typeof qt=="object"&&qt!==null&&Lt(qt);return qt=>(qt=JSON.parse(qt),ae(qt)?qt:null)})()(st.function.arguments);if(tt===null)continue;const Et=omt({id:st.id,selections:[]});for(const Lt of tt.functions){const Dt=await L7e(o,Lt);Dt!==null&&Et.selections.push(qj({operation:Dt,reason:Lt.reason}))}Et.selections.length!==0&&G.push(Et)}if(it.message.role==="assistant"&&it.message.content!=null&&it.message.content.length!==0){const st=PX({role:"assistant",text:it.message.content});G.push(st),o.dispatch(cmt({role:"assistant",stream:q5.to(st.text),join:async()=>Promise.resolve(st.text),done:()=>!0,get:()=>st.text})).catch(()=>{})}}return G}function rDn(o){return o.map(h=>[{role:"assistant",tool_calls:[{type:"function",id:h.id,function:{name:h.name,arguments:JSON.stringify(h.validation.data)}}]},{role:"tool",content:JSON.stringify(h.validation.errors),tool_call_id:h.id},{role:"system",content:["You A.I. assistant has composed wrong typed arguments.","","Correct it at the next function calling."].join(`
|
|
3199
|
+
`)}]).flat()}function iDn(o){return async h=>{const m=[];if(h.ready()===!1){if((o==null?void 0:o.initialize)===null)await h.initialize();else if(m.push(...await((o==null?void 0:o.initialize)??tDn)(h)),h.ready()===!1)return m}if(h.stack.length!==0&&m.push(...await((o==null?void 0:o.cancel)??JMn)(h)),m.push(...await((o==null?void 0:o.select)??nDn)(h)),h.stack.length===0)return m;for(;;){const k=await((o==null?void 0:o.call)??qMn)(h,h.stack.map(P=>P.operation));m.push(...k);const O=k.filter(P=>P.type==="execute");if(m.push(...await((o==null?void 0:o.describe)??ZMn)(h,O)),O.length===0||h.stack.length===0)break}return m}}function aDn(o){if(o.history.type==="text")return M7e({history:o.history});if(o.history.type==="select")return D7e({operations:o.operations,history:o.history});if(o.history.type==="cancel")return R7e({operations:o.operations,history:o.history});if(o.history.type==="execute")return ijt({operations:o.operations,history:o.history});if(o.history.type==="describe")return B7e({operations:o.operations,history:o.history});throw new Error("Invalid prompt type.")}function M7e(o){return PX(o.history)}function D7e(o){return omt({id:o.history.id,selections:o.history.selections.map(h=>qj({operation:ajt({operations:o.operations,input:h.operation}),reason:h.reason}))})}function R7e(o){return smt({id:o.history.id,selections:o.history.selections.map(h=>qj({operation:ajt({operations:o.operations,input:h.operation}),reason:h.reason}))})}function ijt(o){return $N({id:o.history.id,operation:ajt({operations:o.operations,input:o.history.operation}),arguments:o.history.arguments,value:o.history.value})}function B7e(o){return E7e({text:o.history.text,executes:o.history.executes.map(h=>ijt({operations:o.operations,history:h}))})}function ajt(o){var m;const h=(m=o.operations.get(o.input.controller))==null?void 0:m.get(o.input.function);if(h===void 0)throw new Error(`No operation found: (controller: ${o.input.controller}, function: ${o.input.function})`);return h}const oDn={transform:aDn,transformText:M7e,transformSelect:D7e,transformCancel:R7e,transformExecute:ijt,transformDescribe:B7e};class j7e{constructor(h){var m,k;this.props=h,this.operations_=sLn.compose({controllers:h.controllers,config:h.config}),this.stack_=[],this.listeners_=new Map,this.histories_=(h.histories??[]).map(O=>oDn.transform({operations:this.operations_.group,history:O})),this.token_usage_=lX.zero(),this.ready_=!1,this.executor_=typeof((m=h.config)==null?void 0:m.executor)=="function"?h.config.executor:iDn(((k=h.config)==null?void 0:k.executor)??null)}clone(){var h;return new j7e({...this.props,histories:(h=this.props.histories)==null?void 0:h.slice()})}async conversate(h){const m=PX({role:"user",text:h});this.dispatch(cmt({role:"user",stream:q5.to(h),done:()=>!0,get:()=>h,join:async()=>Promise.resolve(h)})).catch(()=>{});const k=await this.executor_(this.getContext({prompt:m,usage:this.token_usage_}));return this.histories_.push(m,...k),[m,...k]}getConfig(){return this.props.config}getVendor(){return this.props.vendor}getControllers(){return this.props.controllers}getOperations(){return this.operations_.array}getHistories(){return this.histories_}getTokenUsage(){return this.token_usage_}getContext(h){const m=async k=>this.dispatch(k);return{operations:this.operations_,config:this.props.config,histories:this.histories_,stack:this.stack_,ready:()=>this.ready_,prompt:h.prompt,dispatch:async k=>this.dispatch(k),request:async(k,O)=>{const P=wLn({source:k,body:{...O,model:this.props.vendor.model,stream:!0,stream_options:{include_usage:!0}},options:this.props.vendor.options});await m(P);const B=await this.props.vendor.api.chat.completions.create(P.body,P.options),[G,J]=q5.transform(B.toReadableStream(),st=>g6.transformCompletionChunk(st)).tee(),[U,nt]=J.tee();(async()=>{const st=U.getReader();for(;;){const tt=await st.read();if(tt.done)break;tt.value.usage!=null&&uLn.aggregate({kind:k,completionUsage:tt.value.usage,usage:h.usage})}})().catch(()=>{});const[at,it]=G.tee();return await m({type:"response",source:k,stream:at,body:P.body,options:P.options,join:async()=>{const st=await q5.readAll(it);return g6.merge(st)}}),nt},initialize:async()=>{this.ready_=!0,await m(pLn())}}}on(h,m){return _7e(this.listeners_,h,()=>new Set).add(m),this}off(h,m){const k=this.listeners_.get(h);return k!==void 0&&(k.delete(m),k.size===0&&this.listeners_.delete(h)),this}async dispatch(h){const m=this.listeners_.get(h.type);m!==void 0&&await Promise.all(Array.from(m).map(async k=>{try{await k(h)}catch{}}))}}const hBt="RFC3986",fBt={RFC1738:o=>String(o).replace(/%20/g,"+"),RFC3986:o=>String(o)},sDn="RFC1738",cDn=Array.isArray,s6=(()=>{const o=[];for(let h=0;h<256;++h)o.push("%"+((h<16?"0":"")+h.toString(16)).toUpperCase());return o})(),rRt=1024,uDn=(o,h,m,k,O)=>{if(o.length===0)return o;let P=o;if(typeof o=="symbol"?P=Symbol.prototype.toString.call(o):typeof o!="string"&&(P=String(o)),m==="iso-8859-1")return escape(P).replace(/%u[0-9a-f]{4}/gi,function(G){return"%26%23"+parseInt(G.slice(2),16)+"%3B"});let B="";for(let G=0;G<P.length;G+=rRt){const J=P.length>=rRt?P.slice(G,G+rRt):P,U=[];for(let nt=0;nt<J.length;++nt){let at=J.charCodeAt(nt);if(at===45||at===46||at===95||at===126||at>=48&&at<=57||at>=65&&at<=90||at>=97&&at<=122||O===sDn&&(at===40||at===41)){U[U.length]=J.charAt(nt);continue}if(at<128){U[U.length]=s6[at];continue}if(at<2048){U[U.length]=s6[192|at>>6]+s6[128|at&63];continue}if(at<55296||at>=57344){U[U.length]=s6[224|at>>12]+s6[128|at>>6&63]+s6[128|at&63];continue}nt+=1,at=65536+((at&1023)<<10|J.charCodeAt(nt)&1023),U[U.length]=s6[240|at>>18]+s6[128|at>>12&63]+s6[128|at>>6&63]+s6[128|at&63]}B+=U.join("")}return B};function lDn(o){return!o||typeof o!="object"?!1:!!(o.constructor&&o.constructor.isBuffer&&o.constructor.isBuffer(o))}function Y8e(o,h){if(cDn(o)){const m=[];for(let k=0;k<o.length;k+=1)m.push(h(o[k]));return m}return h(o)}const hDn=Object.prototype.hasOwnProperty,F7e={brackets(o){return String(o)+"[]"},comma:"comma",indices(o,h){return String(o)+"["+h+"]"},repeat(o){return String(o)}},u6=Array.isArray,fDn=Array.prototype.push,$7e=function(o,h){fDn.apply(o,u6(h)?h:[h])},dDn=Date.prototype.toISOString,Jp={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:uDn,encodeValuesOnly:!1,format:hBt,formatter:fBt[hBt],indices:!1,serializeDate(o){return dDn.call(o)},skipNulls:!1,strictNullHandling:!1};function pDn(o){return typeof o=="string"||typeof o=="number"||typeof o=="boolean"||typeof o=="symbol"||typeof o=="bigint"}const iRt={};function H7e(o,h,m,k,O,P,B,G,J,U,nt,at,it,st,tt,Et,Lt,Dt){let ae=o,qt=Dt,_e=0,gn=!1;for(;(qt=qt.get(iRt))!==void 0&&!gn;){const ar=qt.get(o);if(_e+=1,typeof ar<"u"){if(ar===_e)throw new RangeError("Cyclic object value");gn=!0}typeof qt.get(iRt)>"u"&&(_e=0)}if(typeof U=="function"?ae=U(h,ae):ae instanceof Date?ae=it==null?void 0:it(ae):m==="comma"&&u6(ae)&&(ae=Y8e(ae,function(ar){return ar instanceof Date?it==null?void 0:it(ar):ar})),ae===null){if(P)return J&&!Et?J(h,Jp.encoder,Lt,"key",st):h;ae=""}if(pDn(ae)||lDn(ae)){if(J){const ar=Et?h:J(h,Jp.encoder,Lt,"key",st);return[(tt==null?void 0:tt(ar))+"="+(tt==null?void 0:tt(J(ae,Jp.encoder,Lt,"value",st)))]}return[(tt==null?void 0:tt(h))+"="+(tt==null?void 0:tt(String(ae)))]}const ge=[];if(typeof ae>"u")return ge;let Mn;if(m==="comma"&&u6(ae))Et&&J&&(ae=Y8e(ae,J)),Mn=[{value:ae.length>0?ae.join(",")||null:void 0}];else if(u6(U))Mn=U;else{const ar=Object.keys(ae);Mn=nt?ar.sort(nt):ar}const Wn=G?String(h).replace(/\./g,"%2E"):String(h),cr=k&&u6(ae)&&ae.length===1?Wn+"[]":Wn;if(O&&u6(ae)&&ae.length===0)return cr+"[]";for(let ar=0;ar<Mn.length;++ar){const mn=Mn[ar],Vn=typeof mn=="object"&&typeof mn.value<"u"?mn.value:ae[mn];if(B&&Vn===null)continue;const hi=at&&G?mn.replace(/\./g,"%2E"):mn,$n=u6(ae)?typeof m=="function"?m(cr,hi):cr:cr+(at?"."+hi:"["+hi+"]");Dt.set(o,_e);const Vt=new WeakMap;Vt.set(iRt,Dt),$7e(ge,H7e(Vn,$n,m,k,O,P,B,G,m==="comma"&&Et&&u6(ae)?null:J,U,nt,at,it,st,tt,Et,Lt,Vt))}return ge}function gDn(o=Jp){if(typeof o.allowEmptyArrays<"u"&&typeof o.allowEmptyArrays!="boolean")throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(typeof o.encodeDotInKeys<"u"&&typeof o.encodeDotInKeys!="boolean")throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(o.encoder!==null&&typeof o.encoder<"u"&&typeof o.encoder!="function")throw new TypeError("Encoder has to be a function.");const h=o.charset||Jp.charset;if(typeof o.charset<"u"&&o.charset!=="utf-8"&&o.charset!=="iso-8859-1")throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let m=hBt;if(typeof o.format<"u"){if(!hDn.call(fBt,o.format))throw new TypeError("Unknown format option provided.");m=o.format}const k=fBt[m];let O=Jp.filter;(typeof o.filter=="function"||u6(o.filter))&&(O=o.filter);let P;if(o.arrayFormat&&o.arrayFormat in F7e?P=o.arrayFormat:"indices"in o?P=o.indices?"indices":"repeat":P=Jp.arrayFormat,"commaRoundTrip"in o&&typeof o.commaRoundTrip!="boolean")throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const B=typeof o.allowDots>"u"?o.encodeDotInKeys?!0:Jp.allowDots:!!o.allowDots;return{addQueryPrefix:typeof o.addQueryPrefix=="boolean"?o.addQueryPrefix:Jp.addQueryPrefix,allowDots:B,allowEmptyArrays:typeof o.allowEmptyArrays=="boolean"?!!o.allowEmptyArrays:Jp.allowEmptyArrays,arrayFormat:P,charset:h,charsetSentinel:typeof o.charsetSentinel=="boolean"?o.charsetSentinel:Jp.charsetSentinel,commaRoundTrip:!!o.commaRoundTrip,delimiter:typeof o.delimiter>"u"?Jp.delimiter:o.delimiter,encode:typeof o.encode=="boolean"?o.encode:Jp.encode,encodeDotInKeys:typeof o.encodeDotInKeys=="boolean"?o.encodeDotInKeys:Jp.encodeDotInKeys,encoder:typeof o.encoder=="function"?o.encoder:Jp.encoder,encodeValuesOnly:typeof o.encodeValuesOnly=="boolean"?o.encodeValuesOnly:Jp.encodeValuesOnly,filter:O,format:m,formatter:k,serializeDate:typeof o.serializeDate=="function"?o.serializeDate:Jp.serializeDate,skipNulls:typeof o.skipNulls=="boolean"?o.skipNulls:Jp.skipNulls,sort:typeof o.sort=="function"?o.sort:null,strictNullHandling:typeof o.strictNullHandling=="boolean"?o.strictNullHandling:Jp.strictNullHandling}}function bDn(o,h={}){let m=o;const k=gDn(h);let O,P;typeof k.filter=="function"?(P=k.filter,m=P("",m)):u6(k.filter)&&(P=k.filter,O=P);const B=[];if(typeof m!="object"||m===null)return"";const G=F7e[k.arrayFormat],J=G==="comma"&&k.commaRoundTrip;O||(O=Object.keys(m)),k.sort&&O.sort(k.sort);const U=new WeakMap;for(let it=0;it<O.length;++it){const st=O[it];k.skipNulls&&m[st]===null||$7e(B,H7e(m[st],st,G,J,k.allowEmptyArrays,k.strictNullHandling,k.skipNulls,k.encodeDotInKeys,k.encode?k.encoder:null,k.filter,k.sort,k.allowDots,k.serializeDate,k.format,k.formatter,k.encodeValuesOnly,k.charset,U))}const nt=B.join(k.delimiter);let at=k.addQueryPrefix===!0?"?":"";return k.charsetSentinel&&(k.charset==="iso-8859-1"?at+="utf8=%26%2310003%3B&":at+="utf8=%E2%9C%93&"),nt.length>0?at+nt:""}const xj="4.91.1";let J8e=!1,hX,z7e,U7e,dBt,G7e,q7e,W7e,K7e,V7e;function mDn(o,h={auto:!1}){if(J8e)throw new Error(`you must \`import 'openai/shims/${o.kind}'\` before importing anything else from openai`);if(hX)throw new Error(`can't \`import 'openai/shims/${o.kind}'\` after \`import 'openai/shims/${hX}'\``);J8e=h.auto,hX=o.kind,z7e=o.fetch,U7e=o.FormData,dBt=o.File,G7e=o.ReadableStream,q7e=o.getMultipartRequestOptions,W7e=o.getDefaultAgent,K7e=o.fileFromPath,V7e=o.isFsReadStream}class yDn{constructor(h){this.body=h}get[Symbol.toStringTag](){return"MultipartBody"}}function wDn({manuallyImported:o}={}){const h=o?"You may need to use polyfills":"Add one of these imports before your first `import … from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n";let m,k,O,P;try{m=fetch,k=Request,O=Response,P=Headers}catch(B){throw new Error(`this environment is missing the following Web Fetch API type: ${B.message}. ${h}`)}return{kind:"web",fetch:m,Request:k,Response:O,Headers:P,FormData:typeof FormData<"u"?FormData:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${h}`)}},Blob:typeof Blob<"u"?Blob:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${h}`)}},File:typeof File<"u"?File:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${h}`)}},ReadableStream:typeof ReadableStream<"u"?ReadableStream:class{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${h}`)}},getMultipartRequestOptions:async(B,G)=>({...G,body:new yDn(B)}),getDefaultAgent:B=>{},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:B=>!1}}const Y7e=()=>{hX||mDn(wDn(),{auto:!0})};Y7e();class Cs extends Error{}class Ig extends Cs{constructor(h,m,k,O){super(`${Ig.makeMessage(h,m,k)}`),this.status=h,this.headers=O,this.request_id=O==null?void 0:O["x-request-id"],this.error=m;const P=m;this.code=P==null?void 0:P.code,this.param=P==null?void 0:P.param,this.type=P==null?void 0:P.type}static makeMessage(h,m,k){const O=m!=null&&m.message?typeof m.message=="string"?m.message:JSON.stringify(m.message):m?JSON.stringify(m):k;return h&&O?`${h} ${O}`:h?`${h} status code (no body)`:O||"(no status code or body)"}static generate(h,m,k,O){if(!h||!O)return new umt({message:k,cause:gBt(m)});const P=m==null?void 0:m.error;return h===400?new J7e(h,P,k,O):h===401?new X7e(h,P,k,O):h===403?new Q7e(h,P,k,O):h===404?new Z7e(h,P,k,O):h===409?new t9e(h,P,k,O):h===422?new e9e(h,P,k,O):h===429?new n9e(h,P,k,O):h>=500?new r9e(h,P,k,O):new Ig(h,P,k,O)}}class x3 extends Ig{constructor({message:h}={}){super(void 0,void 0,h||"Request was aborted.",void 0)}}class umt extends Ig{constructor({message:h,cause:m}){super(void 0,void 0,h||"Connection error.",void 0),m&&(this.cause=m)}}class ojt extends umt{constructor({message:h}={}){super({message:h??"Request timed out."})}}class J7e extends Ig{}class X7e extends Ig{}class Q7e extends Ig{}class Z7e extends Ig{}class t9e extends Ig{}class e9e extends Ig{}class n9e extends Ig{}class r9e extends Ig{}class i9e extends Cs{constructor(){super("Could not parse response content as the length limit was reached")}}class a9e extends Cs{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var cbt=function(o,h,m,k,O){if(k==="m")throw new TypeError("Private method is not writable");if(k==="a"&&!O)throw new TypeError("Private accessor was defined without a setter");if(typeof h=="function"?o!==h||!O:!h.has(o))throw new TypeError("Cannot write private member to an object whose class did not declare it");return k==="a"?O.call(o,m):O?O.value=m:h.set(o,m),m},BN=function(o,h,m,k){if(m==="a"&&!k)throw new TypeError("Private accessor was defined without a getter");if(typeof h=="function"?o!==h||!k:!h.has(o))throw new TypeError("Cannot read private member from an object whose class did not declare it");return m==="m"?k:m==="a"?k.call(o):k?k.value:h.get(o)},gw;class lmt{constructor(){gw.set(this,void 0),this.buffer=new Uint8Array,cbt(this,gw,null,"f")}decode(h){if(h==null)return[];const m=h instanceof ArrayBuffer?new Uint8Array(h):typeof h=="string"?new TextEncoder().encode(h):h;let k=new Uint8Array(this.buffer.length+m.length);k.set(this.buffer),k.set(m,this.buffer.length),this.buffer=k;const O=[];let P;for(;(P=vDn(this.buffer,BN(this,gw,"f")))!=null;){if(P.carriage&&BN(this,gw,"f")==null){cbt(this,gw,P.index,"f");continue}if(BN(this,gw,"f")!=null&&(P.index!==BN(this,gw,"f")+1||P.carriage)){O.push(this.decodeText(this.buffer.slice(0,BN(this,gw,"f")-1))),this.buffer=this.buffer.slice(BN(this,gw,"f")),cbt(this,gw,null,"f");continue}const B=BN(this,gw,"f")!==null?P.preceding-1:P.preceding,G=this.decodeText(this.buffer.slice(0,B));O.push(G),this.buffer=this.buffer.slice(P.index),cbt(this,gw,null,"f")}return O}decodeText(h){if(h==null)return"";if(typeof h=="string")return h;if(typeof Buffer<"u"){if(h instanceof Buffer)return h.toString();if(h instanceof Uint8Array)return Buffer.from(h).toString();throw new Cs(`Unexpected: received non-Uint8Array (${h.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if(typeof TextDecoder<"u"){if(h instanceof Uint8Array||h instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(h);throw new Cs(`Unexpected: received non-Uint8Array/ArrayBuffer (${h.constructor.name}) in a web platform. Please report this error.`)}throw new Cs("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){return this.buffer.length?this.decode(`
|
|
3200
3200
|
`):[]}}gw=new WeakMap;lmt.NEWLINE_CHARS=new Set([`
|
|
3201
3201
|
`,"\r"]);lmt.NEWLINE_REGEXP=/\r\n|[\n\r]/g;function vDn(o,h){for(let O=h??0;O<o.length;O++){if(o[O]===10)return{preceding:O,index:O+1,carriage:!1};if(o[O]===13)return{preceding:O,index:O+1,carriage:!0}}return null}function xDn(o){for(let k=0;k<o.length-1;k++){if(o[k]===10&&o[k+1]===10||o[k]===13&&o[k+1]===13)return k+2;if(o[k]===13&&o[k+1]===10&&k+3<o.length&&o[k+2]===13&&o[k+3]===10)return k+4}return-1}function o9e(o){if(o[Symbol.asyncIterator])return o;const h=o.getReader();return{async next(){try{const m=await h.read();return m!=null&&m.done&&h.releaseLock(),m}catch(m){throw h.releaseLock(),m}},async return(){const m=h.cancel();return h.releaseLock(),await m,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}class d6{constructor(h,m){this.iterator=h,this.controller=m}static fromSSEResponse(h,m){let k=!1;async function*O(){if(k)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");k=!0;let P=!1;try{for await(const B of kDn(h,m))if(!P){if(B.data.startsWith("[DONE]")){P=!0;continue}if(B.event===null||B.event.startsWith("response.")||B.event.startsWith("transcript.")){let G;try{G=JSON.parse(B.data)}catch(J){throw console.error("Could not parse message into JSON:",B.data),console.error("From chunk:",B.raw),J}if(G&&G.error)throw new Ig(void 0,G.error,void 0,d9e(h.headers));yield G}else{let G;try{G=JSON.parse(B.data)}catch(J){throw console.error("Could not parse message into JSON:",B.data),console.error("From chunk:",B.raw),J}if(B.event=="error")throw new Ig(void 0,G.error,G.message,void 0);yield{event:B.event,data:G}}}P=!0}catch(B){if(B instanceof Error&&B.name==="AbortError")return;throw B}finally{P||m.abort()}}return new d6(O,m)}static fromReadableStream(h,m){let k=!1;async function*O(){const B=new lmt,G=o9e(h);for await(const J of G)for(const U of B.decode(J))yield U;for(const J of B.flush())yield J}async function*P(){if(k)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");k=!0;let B=!1;try{for await(const G of O())B||G&&(yield JSON.parse(G));B=!0}catch(G){if(G instanceof Error&&G.name==="AbortError")return;throw G}finally{B||m.abort()}}return new d6(P,m)}[Symbol.asyncIterator](){return this.iterator()}tee(){const h=[],m=[],k=this.iterator(),O=P=>({next:()=>{if(P.length===0){const B=k.next();h.push(B),m.push(B)}return P.shift()}});return[new d6(()=>O(h),this.controller),new d6(()=>O(m),this.controller)]}toReadableStream(){const h=this;let m;const k=new TextEncoder;return new G7e({async start(){m=h[Symbol.asyncIterator]()},async pull(O){try{const{value:P,done:B}=await m.next();if(B)return O.close();const G=k.encode(JSON.stringify(P)+`
|
|
3202
3202
|
`);O.enqueue(G)}catch(P){O.error(P)}},async cancel(){var O;await((O=m.return)==null?void 0:O.call(m))}})}}async function*kDn(o,h){if(!o.body)throw h.abort(),new Cs("Attempted to iterate over a response with no body");const m=new EDn,k=new lmt,O=o9e(o.body);for await(const P of _Dn(O))for(const B of k.decode(P)){const G=m.decode(B);G&&(yield G)}for(const P of k.flush()){const B=m.decode(P);B&&(yield B)}}async function*_Dn(o){let h=new Uint8Array;for await(const m of o){if(m==null)continue;const k=m instanceof ArrayBuffer?new Uint8Array(m):typeof m=="string"?new TextEncoder().encode(m):m;let O=new Uint8Array(h.length+k.length);O.set(h),O.set(k,h.length),h=O;let P;for(;(P=xDn(h))!==-1;)yield h.slice(0,P),h=h.slice(P)}h.length>0&&(yield h)}class EDn{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(h){if(h.endsWith("\r")&&(h=h.substring(0,h.length-1)),!h){if(!this.event&&!this.data.length)return null;const P={event:this.event,data:this.data.join(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as m,o as v,r as f,T as b}from"../client-B3aq8qpT.js";import{v as I,A as B,d as T,_ as y,V as g,c as C,F as A,T as j,B as w}from"../VendorConfigurationMovie-
|
|
1
|
+
import{j as m,o as v,r as f,T as b}from"../client-B3aq8qpT.js";import{v as I,A as B,d as T,_ as y,V as g,c as C,F as A,T as j,B as w}from"../VendorConfigurationMovie-fM6ylLiv.js";import{a as u,_ as p}from"../_isFormatUri-YqTfGpHo.js";import{D as x}from"../Divider-DX1xhf0M.js";class R{constructor(){this.articles=[]}index(){return this.articles}create(c){const d={id:I(),title:c.input.title,body:c.input.body,thumbnail:c.input.thumbnail,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return this.articles.push(d),d}update(c){const d=this.articles.find(s=>s.id===c.id);if(d===void 0)throw new Error("Unable to find the matched article.");c.input.title!==void 0&&(d.title=c.input.title),c.input.body!==void 0&&(d.body=c.input.body),c.input.thumbnail!==void 0&&(d.thumbnail=c.input.thumbnail),d.updated_at=new Date().toISOString()}erase(c){const d=this.articles.findIndex(s=>s.id===c.id);if(d===-1)throw new Error("Unable to find the matched article.");this.articles.splice(d,1)}}const U={chatgpt:{model:"chatgpt",options:{reference:!1,strict:!1,separate:null},functions:[{name:"index",parameters:{description:"",type:"object",properties:{},additionalProperties:!1,required:[],$defs:{}},output:{description:"List of every articles",type:"array",items:{description:`Description of the current {@link IBbsArticle} type:
|
|
2
2
|
|
|
3
3
|
> Article entity.
|
|
4
4
|
>
|