@ax-llm/ax 13.0.5 → 13.0.6
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/index.cjs +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -87,7 +87,7 @@ ${c}`:`Assistant: ${p.content}`}default:throw new Error("Unknown role")}}), 'acc
|
|
|
87
87
|
${t.join(`
|
|
88
88
|
`)}`}}toString(){return[`${this.name}: Function execution error in '${this.func.name}'`,...this.fields.map(t=>{let n=this.getFieldDescription(t.field);return` - ${t.field}: ${t.message}${n?` (${n})`:""}`}),this.funcId?` Function ID: ${this.funcId}`:""].join(`
|
|
89
89
|
`)}[Symbol.for("nodejs.util.inspect.custom")](t,n){return this.toString()}}, _class24),dt= exports.AxFunctionProcessor = (_class25 =class{__init63() {this.funcList=[]}constructor(e){;_class25.prototype.__init63.call(this);_class25.prototype.__init64.call(this);_class25.prototype.__init65.call(this);this.funcList=e}__init64() {this.executeFunction=async(e,t,n)=>{let o;typeof t.args=="string"&&t.args.length>0?o=JSON.parse(t.args):o=t.args;let r=n?{sessionId:n.sessionId,traceId:n.traceId,ai:n.ai}:void 0,i;return e.parameters?i=e.func.length===2?await e.func(o,r):await e.func(o):i=e.func.length===1?await e.func(r):await e.func(),(_nullishCoalesce(_optionalChain([n, 'optionalAccess', _686 => _686.functionResultFormatter]), () => (k.functionResultFormatter)))(i)}}__init65() {this.execute=async(e,t)=>{let n=this.funcList.find(o=>o.name.localeCompare(e.name)===0);if(!n)throw new Error(`Function not found: ${e.name}`);if(!n.func)throw new Error(`No handler for function: ${e.name}`);try{return await this.executeFunction(n,e,t)}catch(o){throw o instanceof ct?new ut(o.getFields(),n,e.id):o}}}}, _class25),Tn=(s,e)=>{if(s.length===0)return[..._nullishCoalesce(e, () => ([]))];let t=s.map(n=>"toFunction"in n?n.toFunction():n).flat();for(let n of t.filter(o=>o.parameters))n.parameters&&or(n.parameters);return[..._nullishCoalesce(e, () => ([])),...t]},wn=async({ai:s,functionList:e,functionCalls:t,mem:n,sessionId:o,traceId:r,span:i,excludeContentFromTrace:a,index:l,functionResultFormatter:p})=>{let c=new dt(e),d=new Set,u=t.map(g=>{if(!g.id)throw new Error(`Function ${g.name} did not return an ID`);return c.execute(g,{sessionId:o,traceId:r,ai:s,functionResultFormatter:p}).then(h=>{if(d.add(g.name.toLowerCase()),i){let I={name:g.name};a||(I.args=g.args,I.result=_nullishCoalesce(h, () => (""))),i.addEvent("function.call",I)}return{result:_nullishCoalesce(h, () => ("")),role:"function",functionId:g.id,index:l}}).catch(h=>{if(!(h instanceof ut))throw h;let I=h.getFixingInstructions();if(i){let x={name:g.name,message:h.toString()};a||(x.args=g.args,x.fixing_instructions=I),i.addEvent("function.error",x)}return s.getOptions().debug&&s.getLogger()(`\u274C Function Error Correction:
|
|
90
|
-
${I}`,{tags:["error"]}),{functionId:g.id,isError:!0,index:l,result:I,role:"function"}})}),A=(await Promise.all(u)).filter(g=>g!==void 0);return n.addFunctionResults(A,o),A.some(g=>g.isError)&&n.addTag("error",o),d};function vn(s,e,t,n){if(!e||e.length===0)return;if(!s.getFeatures(n).functions)throw new Error("Functions are not supported by the AI service");return e.map(r=>({id:r.id,name:r.function.name,args:r.function.params}))}function rr(s,e,t){let n=e;return!t&&(n==="required"||typeof n=="function")?{functions:[],functionCall:void 0}:s?{functions:s.map(r=>"toFunction"in r?r.toFunction():r).flat(),functionCall:n}:{functions:[],functionCall:n}}var sr={enabled:!0,enabledCategories:["generation","streaming","functions","errors","performance"],maxLabelLength:100,samplingRate:1},Le,On=s=>{if(Le)return Le;let e=_nullishCoalesce(s, () => (k.meter));if(e)return Le=Ns(e),Le};var Us=()=>{let s=[];return k.meter||s.push("Global meter not initialized"),!Le&&k.meter&&s.push("Metrics instruments not created despite available meter"),{healthy:s.length===0,issues:s}},Ns=s=>({generationLatencyHistogram:s.createHistogram("ax_gen_generation_duration_ms",{description:"End-to-end duration of AxGen generation requests",unit:"ms"}),generationRequestsCounter:s.createCounter("ax_gen_generation_requests_total",{description:"Total number of AxGen generation requests"}),generationErrorsCounter:s.createCounter("ax_gen_generation_errors_total",{description:"Total number of failed AxGen generations"}),multiStepGenerationsCounter:s.createCounter("ax_gen_multistep_generations_total",{description:"Total number of generations that required multiple steps"}),stepsPerGenerationHistogram:s.createHistogram("ax_gen_steps_per_generation",{description:"Number of steps taken per generation"}),maxStepsReachedCounter:s.createCounter("ax_gen_max_steps_reached_total",{description:"Total number of generations that hit max steps limit"}),validationErrorsCounter:s.createCounter("ax_gen_validation_errors_total",{description:"Total number of validation errors encountered"}),assertionErrorsCounter:s.createCounter("ax_gen_assertion_errors_total",{description:"Total number of assertion errors encountered"}),errorCorrectionAttemptsHistogram:s.createHistogram("ax_gen_error_correction_attempts",{description:"Number of error correction attempts per generation"}),errorCorrectionSuccessCounter:s.createCounter("ax_gen_error_correction_success_total",{description:"Total number of successful error corrections"}),errorCorrectionFailureCounter:s.createCounter("ax_gen_error_correction_failure_total",{description:"Total number of failed error corrections"}),maxRetriesReachedCounter:s.createCounter("ax_gen_max_retries_reached_total",{description:"Total number of generations that hit max retries limit"}),functionsEnabledGenerationsCounter:s.createCounter("ax_gen_functions_enabled_generations_total",{description:"Total number of generations with functions enabled"}),functionCallStepsCounter:s.createCounter("ax_gen_function_call_steps_total",{description:"Total number of steps that included function calls"}),functionsExecutedPerGenerationHistogram:s.createHistogram("ax_gen_functions_executed_per_generation",{description:"Number of unique functions executed per generation"}),functionErrorCorrectionCounter:s.createCounter("ax_gen_function_error_correction_total",{description:"Total number of function-related error corrections"}),fieldProcessorsExecutedCounter:s.createCounter("ax_gen_field_processors_executed_total",{description:"Total number of field processors executed"}),streamingFieldProcessorsExecutedCounter:s.createCounter("ax_gen_streaming_field_processors_executed_total",{description:"Total number of streaming field processors executed"}),streamingGenerationsCounter:s.createCounter("ax_gen_streaming_generations_total",{description:"Total number of streaming generations"}),streamingDeltasEmittedCounter:s.createCounter("ax_gen_streaming_deltas_emitted_total",{description:"Total number of streaming deltas emitted"}),streamingFinalizationLatencyHistogram:s.createHistogram("ax_gen_streaming_finalization_duration_ms",{description:"Duration of streaming response finalization",unit:"ms"}),samplesGeneratedHistogram:s.createHistogram("ax_gen_samples_generated",{description:"Number of samples generated per request"}),resultPickerUsageCounter:s.createCounter("ax_gen_result_picker_usage_total",{description:"Total number of times result picker was used"}),resultPickerLatencyHistogram:s.createHistogram("ax_gen_result_picker_duration_ms",{description:"Duration of result picker execution",unit:"ms"}),inputFieldsGauge:s.createGauge("ax_gen_input_fields",{description:"Number of input fields in signature"}),outputFieldsGauge:s.createGauge("ax_gen_output_fields",{description:"Number of output fields in signature"}),examplesUsedGauge:s.createGauge("ax_gen_examples_used",{description:"Number of examples used in generation"}),demosUsedGauge:s.createGauge("ax_gen_demos_used",{description:"Number of demos used in generation"}),promptRenderLatencyHistogram:s.createHistogram("ax_gen_prompt_render_duration_ms",{description:"Duration of prompt template rendering",unit:"ms"}),extractionLatencyHistogram:s.createHistogram("ax_gen_extraction_duration_ms",{description:"Duration of value extraction from responses",unit:"ms"}),assertionLatencyHistogram:s.createHistogram("ax_gen_assertion_duration_ms",{description:"Duration of assertion checking",unit:"ms"}),stateCreationLatencyHistogram:s.createHistogram("ax_gen_state_creation_duration_ms",{description:"Duration of state creation for multiple samples",unit:"ms"}),memoryUpdateLatencyHistogram:s.createHistogram("ax_gen_memory_update_duration_ms",{description:"Duration of memory updates during generation",unit:"ms"})}),mt=sr,Ls= exports.axUpdateMetricsConfig =s=>{mt={...mt,...s}},Bs= exports.axGetMetricsConfig =()=>({...mt}),W=s=>{let e={};for(let[t,n]of Object.entries(s))if(n!=null){let o=String(n),r=mt.maxLabelLength;e[t]=o.length>r?o.substring(0,r):o}return e},ir=(s,e,t,n,o,r)=>{try{let i=W({success:t.toString(),...n?{signature:n}:{},...o?{ai_service:o}:{},...r?{model:r}:{}});s.generationLatencyHistogram&&s.generationLatencyHistogram.record(e,i),s.generationRequestsCounter&&s.generationRequestsCounter.add(1,i),!t&&s.generationErrorsCounter&&s.generationErrorsCounter.add(1,i)}catch(i){console.warn("Failed to record generation metric:",i)}},gt=(s,e,t,n)=>{try{let o=W({...n?{signature:n}:{}});e>1&&s.multiStepGenerationsCounter&&s.multiStepGenerationsCounter.add(1,o),s.stepsPerGenerationHistogram&&s.stepsPerGenerationHistogram.record(e,o),e>=t&&s.maxStepsReachedCounter&&s.maxStepsReachedCounter.add(1,o)}catch(o){console.warn("Failed to record multi-step metric:",o)}},Sn=(s,e,t)=>{try{let n=W({error_type:e,...t?{signature:t}:{}});e==="validation"&&s.validationErrorsCounter&&s.validationErrorsCounter.add(1,n),e==="assertion"&&s.assertionErrorsCounter&&s.assertionErrorsCounter.add(1,n)}catch(n){console.warn("Failed to record validation error metric:",n)}},kn=(s,e,t,n,o)=>{try{let r=W({success:t.toString(),...o?{signature:o}:{}});s.errorCorrectionAttemptsHistogram&&s.errorCorrectionAttemptsHistogram.record(e,r),t&&s.errorCorrectionSuccessCounter&&s.errorCorrectionSuccessCounter.add(1,r),t||(s.errorCorrectionFailureCounter&&s.errorCorrectionFailureCounter.add(1,r),e>=n&&s.maxRetriesReachedCounter&&s.maxRetriesReachedCounter.add(1,r))}catch(r){console.warn("Failed to record error correction metric:",r)}},Mn=(s,e,t,n,o=!1,r)=>{try{let i=W({functions_enabled:e.toString(),had_function_calls:n.toString(),...r?{signature:r}:{}});e&&s.functionsEnabledGenerationsCounter&&s.functionsEnabledGenerationsCounter.add(1,i),n&&s.functionCallStepsCounter&&s.functionCallStepsCounter.add(1,i),t>0&&s.functionsExecutedPerGenerationHistogram&&s.functionsExecutedPerGenerationHistogram.record(t,i),o&&s.functionErrorCorrectionCounter&&s.functionErrorCorrectionCounter.add(1,i)}catch(i){console.warn("Failed to record function calling metric:",i)}},ar=(s,e,t,n)=>{try{let o=W({...n?{signature:n}:{}});e>0&&s.fieldProcessorsExecutedCounter&&s.fieldProcessorsExecutedCounter.add(e,o),t>0&&s.streamingFieldProcessorsExecutedCounter&&s.streamingFieldProcessorsExecutedCounter.add(t,o)}catch(o){console.warn("Failed to record field processing metric:",o)}},lr=(s,e,t,n,o)=>{try{let r=W({is_streaming:e.toString(),...o?{signature:o}:{}});e&&s.streamingGenerationsCounter&&s.streamingGenerationsCounter.add(1,r),t>0&&s.streamingDeltasEmittedCounter&&s.streamingDeltasEmittedCounter.add(t,r),n&&s.streamingFinalizationLatencyHistogram&&s.streamingFinalizationLatencyHistogram.record(n,r)}catch(r){console.warn("Failed to record streaming metric:",r)}},pr=(s,e,t,n,o)=>{try{let r=W({result_picker_used:t.toString(),...o?{signature:o}:{}});s.samplesGeneratedHistogram&&s.samplesGeneratedHistogram.record(e,r),t&&s.resultPickerUsageCounter&&s.resultPickerUsageCounter.add(1,r),n&&s.resultPickerLatencyHistogram&&s.resultPickerLatencyHistogram.record(n,r)}catch(r){console.warn("Failed to record samples metric:",r)}},cr=(s,e,t,n,o,r)=>{try{let i=W({...r?{signature:r}:{}});s.inputFieldsGauge&&s.inputFieldsGauge.record(e,i),s.outputFieldsGauge&&s.outputFieldsGauge.record(t,i),s.examplesUsedGauge&&s.examplesUsedGauge.record(n,i),s.demosUsedGauge&&s.demosUsedGauge.record(o,i)}catch(i){console.warn("Failed to record signature complexity metrics:",i)}},At=(s,e,t,n)=>{try{let o=W({metric_type:e,...n?{signature:n}:{}});switch(e){case"prompt_render":s.promptRenderLatencyHistogram&&s.promptRenderLatencyHistogram.record(t,o);break;case"extraction":s.extractionLatencyHistogram&&s.extractionLatencyHistogram.record(t,o);break;case"assertion":s.assertionLatencyHistogram&&s.assertionLatencyHistogram.record(t,o);break;case"state_creation":s.stateCreationLatencyHistogram&&s.stateCreationLatencyHistogram.record(t,o);break;case"memory_update":s.memoryUpdateLatencyHistogram&&s.memoryUpdateLatencyHistogram.record(t,o);break}}catch(o){console.warn("Failed to record performance metric:",o)}};function ur(s,e){for(let t of e){let n=s.find(o=>o.id===t.id);n?(typeof t.function.name=="string"&&t.function.name.length>0&&(n.function.name+=t.function.name),typeof t.function.params=="string"&&t.function.params.length>0&&(n.function.params+=t.function.params),typeof t.function.params=="object"&&(n.function.params=t.function.params)):s.push(t)}}var _dayjs = require('dayjs'); var _dayjs2 = _interopRequireDefault(_dayjs);var _customParseFormat = require('dayjs/plugin/customParseFormat'); var _customParseFormat2 = _interopRequireDefault(_customParseFormat);var _timezone = require('dayjs/plugin/timezone'); var _timezone2 = _interopRequireDefault(_timezone);var _utc = require('dayjs/plugin/utc'); var _utc2 = _interopRequireDefault(_utc);_dayjs2.default.extend(_utc2.default);_dayjs2.default.extend(_timezone2.default);_dayjs2.default.extend(_customParseFormat2.default);function dr(s,e,t=!1){try{return js(e)}catch(n){if(s.isOptional&&!t)return;let o=n.message;throw new G({fields:[s],message:o,value:e})}}function js(s){if(!_dayjs2.default.call(void 0, s,"YYYY-MM-DD",!0).isValid())throw new Error('Invalid date format. Please provide the date in "YYYY-MM-DD" format.');return _dayjs2.default.utc(s,"YYYY-MM-DD").startOf("day").toDate()}function mr(s,e,t=!1){try{return Hs(e)}catch(n){if(s.isOptional&&!t)return;let o=n.message;throw new G({fields:[s],message:o,value:e})}}function Hs(s){let e=/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?) (.+)$/,t=s.match(e);if(!t)throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');let[,n,o]=t;if(!n||!o)throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');try{let r=n.includes(":")&&n.split(":").length===3?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD HH:mm",i=_dayjs2.default.tz(n,r,o);if(!i.isValid())throw new Error("Invalid date and time values. Please ensure all components are correct.");return i.utc().toDate()}catch (e4){throw new Error(`Unrecognized time zone ${o}. Please provide a valid time zone name, abbreviation, or offset. For example, "America/New_York", or "EST".`)}}var gr=s=>_dayjs2.default.call(void 0, s).utc().format("YYYY-MM-DD HH:mm:ss [UTC]");var En=new H,ue=(s,e,t,n,o,r=20)=>{let i=(s/e*100).toFixed(1),a=Math.round(r*s/e),l=r-a,p=En.blueBright("\u2588".repeat(a)),c=" ".repeat(l),d=e>0?(t/e*100).toFixed(1):"0.0",u=o.includes("Running MIPROv2 optimization")?"Testing prompt variations":o.includes("Tuning Prompt")?"Generating training examples":o;process.stdout.write(`\u2502 ${u}: ${s}/${e} (${En.yellow(i)}%) |${p}${c}| Success rate: ${En.greenBright(d)}%
|
|
90
|
+
${I}`,{tags:["error"]}),{functionId:g.id,isError:!0,index:l,result:I,role:"function"}})}),A=(await Promise.all(u)).filter(g=>g!==void 0);return n.addFunctionResults(A,o),A.some(g=>g.isError)&&n.addTag("error",o),d};function vn(s,e,t,n){if(!e||e.length===0)return;if(!s.getFeatures(n).functions)throw new Error("Functions are not supported by the AI service");return e.map(r=>({id:r.id,name:r.function.name,args:r.function.params}))}function rr(s,e,t){let n=e;return!t&&(n==="required"||typeof n=="function")?{functions:[],functionCall:void 0}:s?{functions:s.map(r=>"toFunction"in r?r.toFunction():r).flat(),functionCall:n}:{functions:[],functionCall:n}}var sr={enabled:!0,enabledCategories:["generation","streaming","functions","errors","performance"],maxLabelLength:100,samplingRate:1},Le,On=s=>{if(Le)return Le;let e=_nullishCoalesce(s, () => (k.meter));if(e)return Le=Ns(e),Le};var Us=()=>{let s=[];return k.meter||s.push("Global meter not initialized"),!Le&&k.meter&&s.push("Metrics instruments not created despite available meter"),{healthy:s.length===0,issues:s}},Ns=s=>({generationLatencyHistogram:s.createHistogram("ax_gen_generation_duration_ms",{description:"End-to-end duration of AxGen generation requests",unit:"ms"}),generationRequestsCounter:s.createCounter("ax_gen_generation_requests_total",{description:"Total number of AxGen generation requests"}),generationErrorsCounter:s.createCounter("ax_gen_generation_errors_total",{description:"Total number of failed AxGen generations"}),multiStepGenerationsCounter:s.createCounter("ax_gen_multistep_generations_total",{description:"Total number of generations that required multiple steps"}),stepsPerGenerationHistogram:s.createHistogram("ax_gen_steps_per_generation",{description:"Number of steps taken per generation"}),maxStepsReachedCounter:s.createCounter("ax_gen_max_steps_reached_total",{description:"Total number of generations that hit max steps limit"}),validationErrorsCounter:s.createCounter("ax_gen_validation_errors_total",{description:"Total number of validation errors encountered"}),assertionErrorsCounter:s.createCounter("ax_gen_assertion_errors_total",{description:"Total number of assertion errors encountered"}),errorCorrectionAttemptsHistogram:s.createHistogram("ax_gen_error_correction_attempts",{description:"Number of error correction attempts per generation"}),errorCorrectionSuccessCounter:s.createCounter("ax_gen_error_correction_success_total",{description:"Total number of successful error corrections"}),errorCorrectionFailureCounter:s.createCounter("ax_gen_error_correction_failure_total",{description:"Total number of failed error corrections"}),maxRetriesReachedCounter:s.createCounter("ax_gen_max_retries_reached_total",{description:"Total number of generations that hit max retries limit"}),functionsEnabledGenerationsCounter:s.createCounter("ax_gen_functions_enabled_generations_total",{description:"Total number of generations with functions enabled"}),functionCallStepsCounter:s.createCounter("ax_gen_function_call_steps_total",{description:"Total number of steps that included function calls"}),functionsExecutedPerGenerationHistogram:s.createHistogram("ax_gen_functions_executed_per_generation",{description:"Number of unique functions executed per generation"}),functionErrorCorrectionCounter:s.createCounter("ax_gen_function_error_correction_total",{description:"Total number of function-related error corrections"}),fieldProcessorsExecutedCounter:s.createCounter("ax_gen_field_processors_executed_total",{description:"Total number of field processors executed"}),streamingFieldProcessorsExecutedCounter:s.createCounter("ax_gen_streaming_field_processors_executed_total",{description:"Total number of streaming field processors executed"}),streamingGenerationsCounter:s.createCounter("ax_gen_streaming_generations_total",{description:"Total number of streaming generations"}),streamingDeltasEmittedCounter:s.createCounter("ax_gen_streaming_deltas_emitted_total",{description:"Total number of streaming deltas emitted"}),streamingFinalizationLatencyHistogram:s.createHistogram("ax_gen_streaming_finalization_duration_ms",{description:"Duration of streaming response finalization",unit:"ms"}),samplesGeneratedHistogram:s.createHistogram("ax_gen_samples_generated",{description:"Number of samples generated per request"}),resultPickerUsageCounter:s.createCounter("ax_gen_result_picker_usage_total",{description:"Total number of times result picker was used"}),resultPickerLatencyHistogram:s.createHistogram("ax_gen_result_picker_duration_ms",{description:"Duration of result picker execution",unit:"ms"}),inputFieldsGauge:s.createGauge("ax_gen_input_fields",{description:"Number of input fields in signature"}),outputFieldsGauge:s.createGauge("ax_gen_output_fields",{description:"Number of output fields in signature"}),examplesUsedGauge:s.createGauge("ax_gen_examples_used",{description:"Number of examples used in generation"}),demosUsedGauge:s.createGauge("ax_gen_demos_used",{description:"Number of demos used in generation"}),promptRenderLatencyHistogram:s.createHistogram("ax_gen_prompt_render_duration_ms",{description:"Duration of prompt template rendering",unit:"ms"}),extractionLatencyHistogram:s.createHistogram("ax_gen_extraction_duration_ms",{description:"Duration of value extraction from responses",unit:"ms"}),assertionLatencyHistogram:s.createHistogram("ax_gen_assertion_duration_ms",{description:"Duration of assertion checking",unit:"ms"}),stateCreationLatencyHistogram:s.createHistogram("ax_gen_state_creation_duration_ms",{description:"Duration of state creation for multiple samples",unit:"ms"}),memoryUpdateLatencyHistogram:s.createHistogram("ax_gen_memory_update_duration_ms",{description:"Duration of memory updates during generation",unit:"ms"})}),mt=sr,Ls= exports.axUpdateMetricsConfig =s=>{mt={...mt,...s}},Bs= exports.axGetMetricsConfig =()=>({...mt}),W=s=>{let e={};for(let[t,n]of Object.entries(s))if(n!=null){let o=String(n),r=mt.maxLabelLength;e[t]=o.length>r?o.substring(0,r):o}return e},ir=(s,e,t,n,o,r)=>{try{let i=W({success:t.toString(),...n?{signature:n}:{},...o?{ai_service:o}:{},...r?{model:r}:{}});s.generationLatencyHistogram&&s.generationLatencyHistogram.record(e,i),s.generationRequestsCounter&&s.generationRequestsCounter.add(1,i),!t&&s.generationErrorsCounter&&s.generationErrorsCounter.add(1,i)}catch(i){console.warn("Failed to record generation metric:",i)}},gt=(s,e,t,n)=>{try{let o=W({...n?{signature:n}:{}});e>1&&s.multiStepGenerationsCounter&&s.multiStepGenerationsCounter.add(1,o),s.stepsPerGenerationHistogram&&s.stepsPerGenerationHistogram.record(e,o),e>=t&&s.maxStepsReachedCounter&&s.maxStepsReachedCounter.add(1,o)}catch(o){console.warn("Failed to record multi-step metric:",o)}},Sn=(s,e,t)=>{try{let n=W({error_type:e,...t?{signature:t}:{}});e==="validation"&&s.validationErrorsCounter&&s.validationErrorsCounter.add(1,n),e==="assertion"&&s.assertionErrorsCounter&&s.assertionErrorsCounter.add(1,n)}catch(n){console.warn("Failed to record validation error metric:",n)}},kn=(s,e,t,n,o)=>{try{let r=W({success:t.toString(),...o?{signature:o}:{}});s.errorCorrectionAttemptsHistogram&&s.errorCorrectionAttemptsHistogram.record(e,r),t&&s.errorCorrectionSuccessCounter&&s.errorCorrectionSuccessCounter.add(1,r),t||(s.errorCorrectionFailureCounter&&s.errorCorrectionFailureCounter.add(1,r),e>=n&&s.maxRetriesReachedCounter&&s.maxRetriesReachedCounter.add(1,r))}catch(r){console.warn("Failed to record error correction metric:",r)}},Mn=(s,e,t,n,o=!1,r)=>{try{let i=W({functions_enabled:e.toString(),had_function_calls:n.toString(),...r?{signature:r}:{}});e&&s.functionsEnabledGenerationsCounter&&s.functionsEnabledGenerationsCounter.add(1,i),n&&s.functionCallStepsCounter&&s.functionCallStepsCounter.add(1,i),t>0&&s.functionsExecutedPerGenerationHistogram&&s.functionsExecutedPerGenerationHistogram.record(t,i),o&&s.functionErrorCorrectionCounter&&s.functionErrorCorrectionCounter.add(1,i)}catch(i){console.warn("Failed to record function calling metric:",i)}},ar=(s,e,t,n)=>{try{let o=W({...n?{signature:n}:{}});e>0&&s.fieldProcessorsExecutedCounter&&s.fieldProcessorsExecutedCounter.add(e,o),t>0&&s.streamingFieldProcessorsExecutedCounter&&s.streamingFieldProcessorsExecutedCounter.add(t,o)}catch(o){console.warn("Failed to record field processing metric:",o)}},lr=(s,e,t,n,o)=>{try{let r=W({is_streaming:e.toString(),...o?{signature:o}:{}});e&&s.streamingGenerationsCounter&&s.streamingGenerationsCounter.add(1,r),t>0&&s.streamingDeltasEmittedCounter&&s.streamingDeltasEmittedCounter.add(t,r),n&&s.streamingFinalizationLatencyHistogram&&s.streamingFinalizationLatencyHistogram.record(n,r)}catch(r){console.warn("Failed to record streaming metric:",r)}},pr=(s,e,t,n,o)=>{try{let r=W({result_picker_used:t.toString(),...o?{signature:o}:{}});s.samplesGeneratedHistogram&&s.samplesGeneratedHistogram.record(e,r),t&&s.resultPickerUsageCounter&&s.resultPickerUsageCounter.add(1,r),n&&s.resultPickerLatencyHistogram&&s.resultPickerLatencyHistogram.record(n,r)}catch(r){console.warn("Failed to record samples metric:",r)}},cr=(s,e,t,n,o,r)=>{try{let i=W({...r?{signature:r}:{}});s.inputFieldsGauge&&s.inputFieldsGauge.record(e,i),s.outputFieldsGauge&&s.outputFieldsGauge.record(t,i),s.examplesUsedGauge&&s.examplesUsedGauge.record(n,i),s.demosUsedGauge&&s.demosUsedGauge.record(o,i)}catch(i){console.warn("Failed to record signature complexity metrics:",i)}},At=(s,e,t,n)=>{try{let o=W({metric_type:e,...n?{signature:n}:{}});switch(e){case"prompt_render":s.promptRenderLatencyHistogram&&s.promptRenderLatencyHistogram.record(t,o);break;case"extraction":s.extractionLatencyHistogram&&s.extractionLatencyHistogram.record(t,o);break;case"assertion":s.assertionLatencyHistogram&&s.assertionLatencyHistogram.record(t,o);break;case"state_creation":s.stateCreationLatencyHistogram&&s.stateCreationLatencyHistogram.record(t,o);break;case"memory_update":s.memoryUpdateLatencyHistogram&&s.memoryUpdateLatencyHistogram.record(t,o);break}}catch(o){console.warn("Failed to record performance metric:",o)}};function ur(s,e){for(let t of e){let n=s.find(o=>o.id===t.id);n?(typeof t.function.name=="string"&&t.function.name.length>0&&(n.function.name+=t.function.name),typeof t.function.params=="string"&&t.function.params.length>0&&(n.function.params+=t.function.params),typeof t.function.params=="object"&&(n.function.params=t.function.params)):s.push(t)}}var _dayjs = require('dayjs'); var _dayjs2 = _interopRequireDefault(_dayjs);var _customParseFormatjs = require('dayjs/plugin/customParseFormat.js'); var _customParseFormatjs2 = _interopRequireDefault(_customParseFormatjs);var _timezonejs = require('dayjs/plugin/timezone.js'); var _timezonejs2 = _interopRequireDefault(_timezonejs);var _utcjs = require('dayjs/plugin/utc.js'); var _utcjs2 = _interopRequireDefault(_utcjs);_dayjs2.default.extend(_utcjs2.default);_dayjs2.default.extend(_timezonejs2.default);_dayjs2.default.extend(_customParseFormatjs2.default);function dr(s,e,t=!1){try{return js(e)}catch(n){if(s.isOptional&&!t)return;let o=n.message;throw new G({fields:[s],message:o,value:e})}}function js(s){if(!_dayjs2.default.call(void 0, s,"YYYY-MM-DD",!0).isValid())throw new Error('Invalid date format. Please provide the date in "YYYY-MM-DD" format.');return _dayjs2.default.utc(s,"YYYY-MM-DD").startOf("day").toDate()}function mr(s,e,t=!1){try{return Hs(e)}catch(n){if(s.isOptional&&!t)return;let o=n.message;throw new G({fields:[s],message:o,value:e})}}function Hs(s){let e=/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?) (.+)$/,t=s.match(e);if(!t)throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');let[,n,o]=t;if(!n||!o)throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');try{let r=n.includes(":")&&n.split(":").length===3?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD HH:mm",i=_dayjs2.default.tz(n,r,o);if(!i.isValid())throw new Error("Invalid date and time values. Please ensure all components are correct.");return i.utc().toDate()}catch (e4){throw new Error(`Unrecognized time zone ${o}. Please provide a valid time zone name, abbreviation, or offset. For example, "America/New_York", or "EST".`)}}var gr=s=>_dayjs2.default.call(void 0, s).utc().format("YYYY-MM-DD HH:mm:ss [UTC]");var En=new H,ue=(s,e,t,n,o,r=20)=>{let i=(s/e*100).toFixed(1),a=Math.round(r*s/e),l=r-a,p=En.blueBright("\u2588".repeat(a)),c=" ".repeat(l),d=e>0?(t/e*100).toFixed(1):"0.0",u=o.includes("Running MIPROv2 optimization")?"Testing prompt variations":o.includes("Tuning Prompt")?"Generating training examples":o;process.stdout.write(`\u2502 ${u}: ${s}/${e} (${En.yellow(i)}%) |${p}${c}| Success rate: ${En.greenBright(d)}%
|
|
91
91
|
`)},ht=(s,e)=>{let t=_nullishCoalesce(s.type, () => ({name:"string",isArray:!1})),n=(a,l)=>{switch(a){case"class":return typeof l=="string";case"code":return typeof l=="string";case"string":return typeof l=="string";case"number":return typeof l=="number";case"boolean":return typeof l=="boolean";case"date":return l instanceof Date||typeof l=="string";case"datetime":return l instanceof Date||typeof l=="string";case"json":return typeof l=="object"||typeof l=="string";default:return!1}},o=a=>!(!a||typeof a!="object"||!("mimeType"in a)||!("data"in a));if(_optionalChain([s, 'access', _687 => _687.type, 'optionalAccess', _688 => _688.name])==="image"){let a;if(Array.isArray(e)){for(let l of e)if(!o(l)){a="object ({ mimeType: string; data: string })";break}}else o(e)||(a="object ({ mimeType: string; data: string })");if(a)throw new Error(`Validation failed: Expected '${s.name}' to be type '${a}' instead got '${e}'`);return}let r=a=>!(!a||typeof a!="object"||!("data"in a));if(_optionalChain([s, 'access', _689 => _689.type, 'optionalAccess', _690 => _690.name])==="audio"){let a;if(Array.isArray(e)){for(let l of e)if(!r(l)){a="object ({ data: string; format?: string })";break}}else r(e)||(a="object ({ data: string; format?: string })");if(a)throw new Error(`Validation failed: Expected '${s.name}' to be type '${a}' instead got '${e}'`);return}let i=!0;if(t.isArray){if(!Array.isArray(e))i=!1;else for(let a of e)if(!n(t.name,a)){i=!1;break}}else i=n(t.name,e);if(!i){let a=Array.isArray(e)?"array":typeof e;throw new Error(`Validation failed: Expected '${s.name}' to be a ${_optionalChain([s, 'access', _691 => _691.type, 'optionalAccess', _692 => _692.isArray])?"an array of ":""}${t.name} instead got '${a}' (${JSON.stringify(e)})`)}};function Ar(s){let e={};for(let t of s){let n=`${t.ai}:${t.model}`;if(!e[n]){e[n]={...t};continue}let o=e[n];if(o){let r=_nullishCoalesce(o.tokens, () => ({promptTokens:0,completionTokens:0,totalTokens:0}));r.promptTokens+=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _693 => _693.tokens, 'optionalAccess', _694 => _694.promptTokens]), () => (0)),r.completionTokens+=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _695 => _695.tokens, 'optionalAccess', _696 => _696.completionTokens]), () => (0)),r.totalTokens+=_nullishCoalesce(_optionalChain([t, 'optionalAccess', _697 => _697.tokens, 'optionalAccess', _698 => _698.totalTokens]), () => (0)),o.tokens=r}}return Object.values(e)}var hr=s=>{if(!s.trim())return[];let e=new Set(["-","*","+"]),t=/^\d+[\s]*[.)\]]\s*/,n=s.split(`
|
|
92
92
|
`),o=[];for(let r of n){let i=r.trim();if(i){if(i[0]&&e.has(i[0]))o.push(i.slice(1).trim());else if(t.test(i))o.push(i.replace(t,"").trim());else if(o.length!==0)throw new Error("Could not parse markdown list: mixed content detected")}}if(o.length===0)throw new Error("Could not parse markdown list: no valid list items found");return o};function _n(s,e){let{index:t,delta:n,version:o}=e,r=_optionalChain([s, 'access', _699 => _699.find, 'call', _700 => _700(i=>i.index===t), 'optionalAccess', _701 => _701.delta]);if(!r)return s.push({index:t,delta:n,version:o}),s;for(let i of Object.keys(n)){let a=r[i],l=n[i];a===void 0&&Array.isArray(l)?r[i]=[...l]:Array.isArray(a)&&Array.isArray(l)?r[i]=[...a,...l]:(a===void 0||typeof a=="string")&&typeof l=="string"?r[i]=`${_nullishCoalesce(a, () => (""))}${l}`:r[i]=l}return s}var Pn= (_class26 =class{__init66() {this.cache=new Map}constructor(e){;_class26.prototype.__init66.call(this);this.maxSize=e}get(e){let t=this.cache.get(e);return t&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){let n=this.cache.keys().next().value;n&&this.cache.delete(n)}this.cache.set(e,t)}}, _class26),Vs=new Pn(500);function xr(s,e,t=0,n=Vs){if(/^```[a-zA-Z]*\s*$/.test(s))return-4;if(/^[\s`]*$/.test(s))return-3;let o=s.indexOf(e,t);if(o!==-1)return o;let r=_nullishCoalesce(n.get(e), () => (Array.from({length:e.length},(a,l)=>e.slice(0,l+1))));n.get(e)||n.set(e,r);let i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(s.endsWith(l)){i=a;break}}return i>=0?-2:-1}var fr=s=>{let e=Math.floor(s/1e3);if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;if(t<60)return`${t}m ${n}s`;let o=Math.floor(t/60),r=t%60;return`${o}h ${r}m ${n}s`},Ws=(s,e,t)=>{if(s===0)return"calculating...";let n=t/s,o=e-s,r=n*o;return fr(r)},yr=(s,e,t,n,o,r,i,a,l)=>{process.stdout.write("\r\x1B[K");let p=(e/t*100).toFixed(1),c=fr(n),d=Ws(e,t,n),u=`Training round ${s+1}/${i.maxRounds}: ${e}/${t} (${p}%) [${c}, ETA: ${d}]`,m=r.totalCalls>0?r.successfulDemos/r.totalCalls*100:0;if(u+=` | Success rate: ${m.toFixed(1)}% (${r.successfulDemos}/${r.totalCalls})`,(i.verboseMode||i.debugMode)&&(i.costMonitoring&&(u+=`
|
|
93
93
|
Tokens: ~${r.estimatedTokenUsage.toLocaleString()} total`),u+=`
|
package/index.js
CHANGED
|
@@ -87,7 +87,7 @@ ${c}`:`Assistant: ${p.content}`}default:throw new Error("Unknown role")}}).join(
|
|
|
87
87
|
${t.join(`
|
|
88
88
|
`)}`};toString(){return[`${this.name}: Function execution error in '${this.func.name}'`,...this.fields.map(t=>{let n=this.getFieldDescription(t.field);return` - ${t.field}: ${t.message}${n?` (${n})`:""}`}),this.funcId?` Function ID: ${this.funcId}`:""].join(`
|
|
89
89
|
`)}[Symbol.for("nodejs.util.inspect.custom")](t,n){return this.toString()}},dt=class{funcList=[];constructor(e){this.funcList=e}executeFunction=async(e,t,n)=>{let o;typeof t.args=="string"&&t.args.length>0?o=JSON.parse(t.args):o=t.args;let r=n?{sessionId:n.sessionId,traceId:n.traceId,ai:n.ai}:void 0,i;return e.parameters?i=e.func.length===2?await e.func(o,r):await e.func(o):i=e.func.length===1?await e.func(r):await e.func(),(n?.functionResultFormatter??k.functionResultFormatter)(i)};execute=async(e,t)=>{let n=this.funcList.find(o=>o.name.localeCompare(e.name)===0);if(!n)throw new Error(`Function not found: ${e.name}`);if(!n.func)throw new Error(`No handler for function: ${e.name}`);try{return await this.executeFunction(n,e,t)}catch(o){throw o instanceof ct?new ut(o.getFields(),n,e.id):o}}},Tn=(s,e)=>{if(s.length===0)return[...e??[]];let t=s.map(n=>"toFunction"in n?n.toFunction():n).flat();for(let n of t.filter(o=>o.parameters))n.parameters&&or(n.parameters);return[...e??[],...t]},wn=async({ai:s,functionList:e,functionCalls:t,mem:n,sessionId:o,traceId:r,span:i,excludeContentFromTrace:a,index:l,functionResultFormatter:p})=>{let c=new dt(e),d=new Set,u=t.map(g=>{if(!g.id)throw new Error(`Function ${g.name} did not return an ID`);return c.execute(g,{sessionId:o,traceId:r,ai:s,functionResultFormatter:p}).then(h=>{if(d.add(g.name.toLowerCase()),i){let I={name:g.name};a||(I.args=g.args,I.result=h??""),i.addEvent("function.call",I)}return{result:h??"",role:"function",functionId:g.id,index:l}}).catch(h=>{if(!(h instanceof ut))throw h;let I=h.getFixingInstructions();if(i){let x={name:g.name,message:h.toString()};a||(x.args=g.args,x.fixing_instructions=I),i.addEvent("function.error",x)}return s.getOptions().debug&&s.getLogger()(`\u274C Function Error Correction:
|
|
90
|
-
${I}`,{tags:["error"]}),{functionId:g.id,isError:!0,index:l,result:I,role:"function"}})}),A=(await Promise.all(u)).filter(g=>g!==void 0);return n.addFunctionResults(A,o),A.some(g=>g.isError)&&n.addTag("error",o),d};function vn(s,e,t,n){if(!e||e.length===0)return;if(!s.getFeatures(n).functions)throw new Error("Functions are not supported by the AI service");return e.map(r=>({id:r.id,name:r.function.name,args:r.function.params}))}function rr(s,e,t){let n=e;return!t&&(n==="required"||typeof n=="function")?{functions:[],functionCall:void 0}:s?{functions:s.map(r=>"toFunction"in r?r.toFunction():r).flat(),functionCall:n}:{functions:[],functionCall:n}}var sr={enabled:!0,enabledCategories:["generation","streaming","functions","errors","performance"],maxLabelLength:100,samplingRate:1},Le,On=s=>{if(Le)return Le;let e=s??k.meter;if(e)return Le=Ns(e),Le};var Us=()=>{let s=[];return k.meter||s.push("Global meter not initialized"),!Le&&k.meter&&s.push("Metrics instruments not created despite available meter"),{healthy:s.length===0,issues:s}},Ns=s=>({generationLatencyHistogram:s.createHistogram("ax_gen_generation_duration_ms",{description:"End-to-end duration of AxGen generation requests",unit:"ms"}),generationRequestsCounter:s.createCounter("ax_gen_generation_requests_total",{description:"Total number of AxGen generation requests"}),generationErrorsCounter:s.createCounter("ax_gen_generation_errors_total",{description:"Total number of failed AxGen generations"}),multiStepGenerationsCounter:s.createCounter("ax_gen_multistep_generations_total",{description:"Total number of generations that required multiple steps"}),stepsPerGenerationHistogram:s.createHistogram("ax_gen_steps_per_generation",{description:"Number of steps taken per generation"}),maxStepsReachedCounter:s.createCounter("ax_gen_max_steps_reached_total",{description:"Total number of generations that hit max steps limit"}),validationErrorsCounter:s.createCounter("ax_gen_validation_errors_total",{description:"Total number of validation errors encountered"}),assertionErrorsCounter:s.createCounter("ax_gen_assertion_errors_total",{description:"Total number of assertion errors encountered"}),errorCorrectionAttemptsHistogram:s.createHistogram("ax_gen_error_correction_attempts",{description:"Number of error correction attempts per generation"}),errorCorrectionSuccessCounter:s.createCounter("ax_gen_error_correction_success_total",{description:"Total number of successful error corrections"}),errorCorrectionFailureCounter:s.createCounter("ax_gen_error_correction_failure_total",{description:"Total number of failed error corrections"}),maxRetriesReachedCounter:s.createCounter("ax_gen_max_retries_reached_total",{description:"Total number of generations that hit max retries limit"}),functionsEnabledGenerationsCounter:s.createCounter("ax_gen_functions_enabled_generations_total",{description:"Total number of generations with functions enabled"}),functionCallStepsCounter:s.createCounter("ax_gen_function_call_steps_total",{description:"Total number of steps that included function calls"}),functionsExecutedPerGenerationHistogram:s.createHistogram("ax_gen_functions_executed_per_generation",{description:"Number of unique functions executed per generation"}),functionErrorCorrectionCounter:s.createCounter("ax_gen_function_error_correction_total",{description:"Total number of function-related error corrections"}),fieldProcessorsExecutedCounter:s.createCounter("ax_gen_field_processors_executed_total",{description:"Total number of field processors executed"}),streamingFieldProcessorsExecutedCounter:s.createCounter("ax_gen_streaming_field_processors_executed_total",{description:"Total number of streaming field processors executed"}),streamingGenerationsCounter:s.createCounter("ax_gen_streaming_generations_total",{description:"Total number of streaming generations"}),streamingDeltasEmittedCounter:s.createCounter("ax_gen_streaming_deltas_emitted_total",{description:"Total number of streaming deltas emitted"}),streamingFinalizationLatencyHistogram:s.createHistogram("ax_gen_streaming_finalization_duration_ms",{description:"Duration of streaming response finalization",unit:"ms"}),samplesGeneratedHistogram:s.createHistogram("ax_gen_samples_generated",{description:"Number of samples generated per request"}),resultPickerUsageCounter:s.createCounter("ax_gen_result_picker_usage_total",{description:"Total number of times result picker was used"}),resultPickerLatencyHistogram:s.createHistogram("ax_gen_result_picker_duration_ms",{description:"Duration of result picker execution",unit:"ms"}),inputFieldsGauge:s.createGauge("ax_gen_input_fields",{description:"Number of input fields in signature"}),outputFieldsGauge:s.createGauge("ax_gen_output_fields",{description:"Number of output fields in signature"}),examplesUsedGauge:s.createGauge("ax_gen_examples_used",{description:"Number of examples used in generation"}),demosUsedGauge:s.createGauge("ax_gen_demos_used",{description:"Number of demos used in generation"}),promptRenderLatencyHistogram:s.createHistogram("ax_gen_prompt_render_duration_ms",{description:"Duration of prompt template rendering",unit:"ms"}),extractionLatencyHistogram:s.createHistogram("ax_gen_extraction_duration_ms",{description:"Duration of value extraction from responses",unit:"ms"}),assertionLatencyHistogram:s.createHistogram("ax_gen_assertion_duration_ms",{description:"Duration of assertion checking",unit:"ms"}),stateCreationLatencyHistogram:s.createHistogram("ax_gen_state_creation_duration_ms",{description:"Duration of state creation for multiple samples",unit:"ms"}),memoryUpdateLatencyHistogram:s.createHistogram("ax_gen_memory_update_duration_ms",{description:"Duration of memory updates during generation",unit:"ms"})}),mt=sr,Ls=s=>{mt={...mt,...s}},Bs=()=>({...mt}),W=s=>{let e={};for(let[t,n]of Object.entries(s))if(n!=null){let o=String(n),r=mt.maxLabelLength;e[t]=o.length>r?o.substring(0,r):o}return e},ir=(s,e,t,n,o,r)=>{try{let i=W({success:t.toString(),...n?{signature:n}:{},...o?{ai_service:o}:{},...r?{model:r}:{}});s.generationLatencyHistogram&&s.generationLatencyHistogram.record(e,i),s.generationRequestsCounter&&s.generationRequestsCounter.add(1,i),!t&&s.generationErrorsCounter&&s.generationErrorsCounter.add(1,i)}catch(i){console.warn("Failed to record generation metric:",i)}},gt=(s,e,t,n)=>{try{let o=W({...n?{signature:n}:{}});e>1&&s.multiStepGenerationsCounter&&s.multiStepGenerationsCounter.add(1,o),s.stepsPerGenerationHistogram&&s.stepsPerGenerationHistogram.record(e,o),e>=t&&s.maxStepsReachedCounter&&s.maxStepsReachedCounter.add(1,o)}catch(o){console.warn("Failed to record multi-step metric:",o)}},Sn=(s,e,t)=>{try{let n=W({error_type:e,...t?{signature:t}:{}});e==="validation"&&s.validationErrorsCounter&&s.validationErrorsCounter.add(1,n),e==="assertion"&&s.assertionErrorsCounter&&s.assertionErrorsCounter.add(1,n)}catch(n){console.warn("Failed to record validation error metric:",n)}},kn=(s,e,t,n,o)=>{try{let r=W({success:t.toString(),...o?{signature:o}:{}});s.errorCorrectionAttemptsHistogram&&s.errorCorrectionAttemptsHistogram.record(e,r),t&&s.errorCorrectionSuccessCounter&&s.errorCorrectionSuccessCounter.add(1,r),t||(s.errorCorrectionFailureCounter&&s.errorCorrectionFailureCounter.add(1,r),e>=n&&s.maxRetriesReachedCounter&&s.maxRetriesReachedCounter.add(1,r))}catch(r){console.warn("Failed to record error correction metric:",r)}},Mn=(s,e,t,n,o=!1,r)=>{try{let i=W({functions_enabled:e.toString(),had_function_calls:n.toString(),...r?{signature:r}:{}});e&&s.functionsEnabledGenerationsCounter&&s.functionsEnabledGenerationsCounter.add(1,i),n&&s.functionCallStepsCounter&&s.functionCallStepsCounter.add(1,i),t>0&&s.functionsExecutedPerGenerationHistogram&&s.functionsExecutedPerGenerationHistogram.record(t,i),o&&s.functionErrorCorrectionCounter&&s.functionErrorCorrectionCounter.add(1,i)}catch(i){console.warn("Failed to record function calling metric:",i)}},ar=(s,e,t,n)=>{try{let o=W({...n?{signature:n}:{}});e>0&&s.fieldProcessorsExecutedCounter&&s.fieldProcessorsExecutedCounter.add(e,o),t>0&&s.streamingFieldProcessorsExecutedCounter&&s.streamingFieldProcessorsExecutedCounter.add(t,o)}catch(o){console.warn("Failed to record field processing metric:",o)}},lr=(s,e,t,n,o)=>{try{let r=W({is_streaming:e.toString(),...o?{signature:o}:{}});e&&s.streamingGenerationsCounter&&s.streamingGenerationsCounter.add(1,r),t>0&&s.streamingDeltasEmittedCounter&&s.streamingDeltasEmittedCounter.add(t,r),n&&s.streamingFinalizationLatencyHistogram&&s.streamingFinalizationLatencyHistogram.record(n,r)}catch(r){console.warn("Failed to record streaming metric:",r)}},pr=(s,e,t,n,o)=>{try{let r=W({result_picker_used:t.toString(),...o?{signature:o}:{}});s.samplesGeneratedHistogram&&s.samplesGeneratedHistogram.record(e,r),t&&s.resultPickerUsageCounter&&s.resultPickerUsageCounter.add(1,r),n&&s.resultPickerLatencyHistogram&&s.resultPickerLatencyHistogram.record(n,r)}catch(r){console.warn("Failed to record samples metric:",r)}},cr=(s,e,t,n,o,r)=>{try{let i=W({...r?{signature:r}:{}});s.inputFieldsGauge&&s.inputFieldsGauge.record(e,i),s.outputFieldsGauge&&s.outputFieldsGauge.record(t,i),s.examplesUsedGauge&&s.examplesUsedGauge.record(n,i),s.demosUsedGauge&&s.demosUsedGauge.record(o,i)}catch(i){console.warn("Failed to record signature complexity metrics:",i)}},At=(s,e,t,n)=>{try{let o=W({metric_type:e,...n?{signature:n}:{}});switch(e){case"prompt_render":s.promptRenderLatencyHistogram&&s.promptRenderLatencyHistogram.record(t,o);break;case"extraction":s.extractionLatencyHistogram&&s.extractionLatencyHistogram.record(t,o);break;case"assertion":s.assertionLatencyHistogram&&s.assertionLatencyHistogram.record(t,o);break;case"state_creation":s.stateCreationLatencyHistogram&&s.stateCreationLatencyHistogram.record(t,o);break;case"memory_update":s.memoryUpdateLatencyHistogram&&s.memoryUpdateLatencyHistogram.record(t,o);break}}catch(o){console.warn("Failed to record performance metric:",o)}};function ur(s,e){for(let t of e){let n=s.find(o=>o.id===t.id);n?(typeof t.function.name=="string"&&t.function.name.length>0&&(n.function.name+=t.function.name),typeof t.function.params=="string"&&t.function.params.length>0&&(n.function.params+=t.function.params),typeof t.function.params=="object"&&(n.function.params=t.function.params)):s.push(t)}}import se from"dayjs";import $s from"dayjs/plugin/customParseFormat";import qs from"dayjs/plugin/timezone";import zs from"dayjs/plugin/utc";se.extend(zs);se.extend(qs);se.extend($s);function dr(s,e,t=!1){try{return js(e)}catch(n){if(s.isOptional&&!t)return;let o=n.message;throw new G({fields:[s],message:o,value:e})}}function js(s){if(!se(s,"YYYY-MM-DD",!0).isValid())throw new Error('Invalid date format. Please provide the date in "YYYY-MM-DD" format.');return se.utc(s,"YYYY-MM-DD").startOf("day").toDate()}function mr(s,e,t=!1){try{return Hs(e)}catch(n){if(s.isOptional&&!t)return;let o=n.message;throw new G({fields:[s],message:o,value:e})}}function Hs(s){let e=/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?) (.+)$/,t=s.match(e);if(!t)throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');let[,n,o]=t;if(!n||!o)throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');try{let r=n.includes(":")&&n.split(":").length===3?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD HH:mm",i=se.tz(n,r,o);if(!i.isValid())throw new Error("Invalid date and time values. Please ensure all components are correct.");return i.utc().toDate()}catch{throw new Error(`Unrecognized time zone ${o}. Please provide a valid time zone name, abbreviation, or offset. For example, "America/New_York", or "EST".`)}}var gr=s=>se(s).utc().format("YYYY-MM-DD HH:mm:ss [UTC]");var En=new H,ue=(s,e,t,n,o,r=20)=>{let i=(s/e*100).toFixed(1),a=Math.round(r*s/e),l=r-a,p=En.blueBright("\u2588".repeat(a)),c=" ".repeat(l),d=e>0?(t/e*100).toFixed(1):"0.0",u=o.includes("Running MIPROv2 optimization")?"Testing prompt variations":o.includes("Tuning Prompt")?"Generating training examples":o;process.stdout.write(`\u2502 ${u}: ${s}/${e} (${En.yellow(i)}%) |${p}${c}| Success rate: ${En.greenBright(d)}%
|
|
90
|
+
${I}`,{tags:["error"]}),{functionId:g.id,isError:!0,index:l,result:I,role:"function"}})}),A=(await Promise.all(u)).filter(g=>g!==void 0);return n.addFunctionResults(A,o),A.some(g=>g.isError)&&n.addTag("error",o),d};function vn(s,e,t,n){if(!e||e.length===0)return;if(!s.getFeatures(n).functions)throw new Error("Functions are not supported by the AI service");return e.map(r=>({id:r.id,name:r.function.name,args:r.function.params}))}function rr(s,e,t){let n=e;return!t&&(n==="required"||typeof n=="function")?{functions:[],functionCall:void 0}:s?{functions:s.map(r=>"toFunction"in r?r.toFunction():r).flat(),functionCall:n}:{functions:[],functionCall:n}}var sr={enabled:!0,enabledCategories:["generation","streaming","functions","errors","performance"],maxLabelLength:100,samplingRate:1},Le,On=s=>{if(Le)return Le;let e=s??k.meter;if(e)return Le=Ns(e),Le};var Us=()=>{let s=[];return k.meter||s.push("Global meter not initialized"),!Le&&k.meter&&s.push("Metrics instruments not created despite available meter"),{healthy:s.length===0,issues:s}},Ns=s=>({generationLatencyHistogram:s.createHistogram("ax_gen_generation_duration_ms",{description:"End-to-end duration of AxGen generation requests",unit:"ms"}),generationRequestsCounter:s.createCounter("ax_gen_generation_requests_total",{description:"Total number of AxGen generation requests"}),generationErrorsCounter:s.createCounter("ax_gen_generation_errors_total",{description:"Total number of failed AxGen generations"}),multiStepGenerationsCounter:s.createCounter("ax_gen_multistep_generations_total",{description:"Total number of generations that required multiple steps"}),stepsPerGenerationHistogram:s.createHistogram("ax_gen_steps_per_generation",{description:"Number of steps taken per generation"}),maxStepsReachedCounter:s.createCounter("ax_gen_max_steps_reached_total",{description:"Total number of generations that hit max steps limit"}),validationErrorsCounter:s.createCounter("ax_gen_validation_errors_total",{description:"Total number of validation errors encountered"}),assertionErrorsCounter:s.createCounter("ax_gen_assertion_errors_total",{description:"Total number of assertion errors encountered"}),errorCorrectionAttemptsHistogram:s.createHistogram("ax_gen_error_correction_attempts",{description:"Number of error correction attempts per generation"}),errorCorrectionSuccessCounter:s.createCounter("ax_gen_error_correction_success_total",{description:"Total number of successful error corrections"}),errorCorrectionFailureCounter:s.createCounter("ax_gen_error_correction_failure_total",{description:"Total number of failed error corrections"}),maxRetriesReachedCounter:s.createCounter("ax_gen_max_retries_reached_total",{description:"Total number of generations that hit max retries limit"}),functionsEnabledGenerationsCounter:s.createCounter("ax_gen_functions_enabled_generations_total",{description:"Total number of generations with functions enabled"}),functionCallStepsCounter:s.createCounter("ax_gen_function_call_steps_total",{description:"Total number of steps that included function calls"}),functionsExecutedPerGenerationHistogram:s.createHistogram("ax_gen_functions_executed_per_generation",{description:"Number of unique functions executed per generation"}),functionErrorCorrectionCounter:s.createCounter("ax_gen_function_error_correction_total",{description:"Total number of function-related error corrections"}),fieldProcessorsExecutedCounter:s.createCounter("ax_gen_field_processors_executed_total",{description:"Total number of field processors executed"}),streamingFieldProcessorsExecutedCounter:s.createCounter("ax_gen_streaming_field_processors_executed_total",{description:"Total number of streaming field processors executed"}),streamingGenerationsCounter:s.createCounter("ax_gen_streaming_generations_total",{description:"Total number of streaming generations"}),streamingDeltasEmittedCounter:s.createCounter("ax_gen_streaming_deltas_emitted_total",{description:"Total number of streaming deltas emitted"}),streamingFinalizationLatencyHistogram:s.createHistogram("ax_gen_streaming_finalization_duration_ms",{description:"Duration of streaming response finalization",unit:"ms"}),samplesGeneratedHistogram:s.createHistogram("ax_gen_samples_generated",{description:"Number of samples generated per request"}),resultPickerUsageCounter:s.createCounter("ax_gen_result_picker_usage_total",{description:"Total number of times result picker was used"}),resultPickerLatencyHistogram:s.createHistogram("ax_gen_result_picker_duration_ms",{description:"Duration of result picker execution",unit:"ms"}),inputFieldsGauge:s.createGauge("ax_gen_input_fields",{description:"Number of input fields in signature"}),outputFieldsGauge:s.createGauge("ax_gen_output_fields",{description:"Number of output fields in signature"}),examplesUsedGauge:s.createGauge("ax_gen_examples_used",{description:"Number of examples used in generation"}),demosUsedGauge:s.createGauge("ax_gen_demos_used",{description:"Number of demos used in generation"}),promptRenderLatencyHistogram:s.createHistogram("ax_gen_prompt_render_duration_ms",{description:"Duration of prompt template rendering",unit:"ms"}),extractionLatencyHistogram:s.createHistogram("ax_gen_extraction_duration_ms",{description:"Duration of value extraction from responses",unit:"ms"}),assertionLatencyHistogram:s.createHistogram("ax_gen_assertion_duration_ms",{description:"Duration of assertion checking",unit:"ms"}),stateCreationLatencyHistogram:s.createHistogram("ax_gen_state_creation_duration_ms",{description:"Duration of state creation for multiple samples",unit:"ms"}),memoryUpdateLatencyHistogram:s.createHistogram("ax_gen_memory_update_duration_ms",{description:"Duration of memory updates during generation",unit:"ms"})}),mt=sr,Ls=s=>{mt={...mt,...s}},Bs=()=>({...mt}),W=s=>{let e={};for(let[t,n]of Object.entries(s))if(n!=null){let o=String(n),r=mt.maxLabelLength;e[t]=o.length>r?o.substring(0,r):o}return e},ir=(s,e,t,n,o,r)=>{try{let i=W({success:t.toString(),...n?{signature:n}:{},...o?{ai_service:o}:{},...r?{model:r}:{}});s.generationLatencyHistogram&&s.generationLatencyHistogram.record(e,i),s.generationRequestsCounter&&s.generationRequestsCounter.add(1,i),!t&&s.generationErrorsCounter&&s.generationErrorsCounter.add(1,i)}catch(i){console.warn("Failed to record generation metric:",i)}},gt=(s,e,t,n)=>{try{let o=W({...n?{signature:n}:{}});e>1&&s.multiStepGenerationsCounter&&s.multiStepGenerationsCounter.add(1,o),s.stepsPerGenerationHistogram&&s.stepsPerGenerationHistogram.record(e,o),e>=t&&s.maxStepsReachedCounter&&s.maxStepsReachedCounter.add(1,o)}catch(o){console.warn("Failed to record multi-step metric:",o)}},Sn=(s,e,t)=>{try{let n=W({error_type:e,...t?{signature:t}:{}});e==="validation"&&s.validationErrorsCounter&&s.validationErrorsCounter.add(1,n),e==="assertion"&&s.assertionErrorsCounter&&s.assertionErrorsCounter.add(1,n)}catch(n){console.warn("Failed to record validation error metric:",n)}},kn=(s,e,t,n,o)=>{try{let r=W({success:t.toString(),...o?{signature:o}:{}});s.errorCorrectionAttemptsHistogram&&s.errorCorrectionAttemptsHistogram.record(e,r),t&&s.errorCorrectionSuccessCounter&&s.errorCorrectionSuccessCounter.add(1,r),t||(s.errorCorrectionFailureCounter&&s.errorCorrectionFailureCounter.add(1,r),e>=n&&s.maxRetriesReachedCounter&&s.maxRetriesReachedCounter.add(1,r))}catch(r){console.warn("Failed to record error correction metric:",r)}},Mn=(s,e,t,n,o=!1,r)=>{try{let i=W({functions_enabled:e.toString(),had_function_calls:n.toString(),...r?{signature:r}:{}});e&&s.functionsEnabledGenerationsCounter&&s.functionsEnabledGenerationsCounter.add(1,i),n&&s.functionCallStepsCounter&&s.functionCallStepsCounter.add(1,i),t>0&&s.functionsExecutedPerGenerationHistogram&&s.functionsExecutedPerGenerationHistogram.record(t,i),o&&s.functionErrorCorrectionCounter&&s.functionErrorCorrectionCounter.add(1,i)}catch(i){console.warn("Failed to record function calling metric:",i)}},ar=(s,e,t,n)=>{try{let o=W({...n?{signature:n}:{}});e>0&&s.fieldProcessorsExecutedCounter&&s.fieldProcessorsExecutedCounter.add(e,o),t>0&&s.streamingFieldProcessorsExecutedCounter&&s.streamingFieldProcessorsExecutedCounter.add(t,o)}catch(o){console.warn("Failed to record field processing metric:",o)}},lr=(s,e,t,n,o)=>{try{let r=W({is_streaming:e.toString(),...o?{signature:o}:{}});e&&s.streamingGenerationsCounter&&s.streamingGenerationsCounter.add(1,r),t>0&&s.streamingDeltasEmittedCounter&&s.streamingDeltasEmittedCounter.add(t,r),n&&s.streamingFinalizationLatencyHistogram&&s.streamingFinalizationLatencyHistogram.record(n,r)}catch(r){console.warn("Failed to record streaming metric:",r)}},pr=(s,e,t,n,o)=>{try{let r=W({result_picker_used:t.toString(),...o?{signature:o}:{}});s.samplesGeneratedHistogram&&s.samplesGeneratedHistogram.record(e,r),t&&s.resultPickerUsageCounter&&s.resultPickerUsageCounter.add(1,r),n&&s.resultPickerLatencyHistogram&&s.resultPickerLatencyHistogram.record(n,r)}catch(r){console.warn("Failed to record samples metric:",r)}},cr=(s,e,t,n,o,r)=>{try{let i=W({...r?{signature:r}:{}});s.inputFieldsGauge&&s.inputFieldsGauge.record(e,i),s.outputFieldsGauge&&s.outputFieldsGauge.record(t,i),s.examplesUsedGauge&&s.examplesUsedGauge.record(n,i),s.demosUsedGauge&&s.demosUsedGauge.record(o,i)}catch(i){console.warn("Failed to record signature complexity metrics:",i)}},At=(s,e,t,n)=>{try{let o=W({metric_type:e,...n?{signature:n}:{}});switch(e){case"prompt_render":s.promptRenderLatencyHistogram&&s.promptRenderLatencyHistogram.record(t,o);break;case"extraction":s.extractionLatencyHistogram&&s.extractionLatencyHistogram.record(t,o);break;case"assertion":s.assertionLatencyHistogram&&s.assertionLatencyHistogram.record(t,o);break;case"state_creation":s.stateCreationLatencyHistogram&&s.stateCreationLatencyHistogram.record(t,o);break;case"memory_update":s.memoryUpdateLatencyHistogram&&s.memoryUpdateLatencyHistogram.record(t,o);break}}catch(o){console.warn("Failed to record performance metric:",o)}};function ur(s,e){for(let t of e){let n=s.find(o=>o.id===t.id);n?(typeof t.function.name=="string"&&t.function.name.length>0&&(n.function.name+=t.function.name),typeof t.function.params=="string"&&t.function.params.length>0&&(n.function.params+=t.function.params),typeof t.function.params=="object"&&(n.function.params=t.function.params)):s.push(t)}}import se from"dayjs";import $s from"dayjs/plugin/customParseFormat.js";import qs from"dayjs/plugin/timezone.js";import zs from"dayjs/plugin/utc.js";se.extend(zs);se.extend(qs);se.extend($s);function dr(s,e,t=!1){try{return js(e)}catch(n){if(s.isOptional&&!t)return;let o=n.message;throw new G({fields:[s],message:o,value:e})}}function js(s){if(!se(s,"YYYY-MM-DD",!0).isValid())throw new Error('Invalid date format. Please provide the date in "YYYY-MM-DD" format.');return se.utc(s,"YYYY-MM-DD").startOf("day").toDate()}function mr(s,e,t=!1){try{return Hs(e)}catch(n){if(s.isOptional&&!t)return;let o=n.message;throw new G({fields:[s],message:o,value:e})}}function Hs(s){let e=/^(\d{4}-\d{2}-\d{2} \d{2}:\d{2}(?::\d{2})?) (.+)$/,t=s.match(e);if(!t)throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');let[,n,o]=t;if(!n||!o)throw new Error('Invalid date and time format. Please provide the date and time in "YYYY-MM-DD HH:mm" or "YYYY-MM-DD HH:mm:ss" format, followed by the timezone.');try{let r=n.includes(":")&&n.split(":").length===3?"YYYY-MM-DD HH:mm:ss":"YYYY-MM-DD HH:mm",i=se.tz(n,r,o);if(!i.isValid())throw new Error("Invalid date and time values. Please ensure all components are correct.");return i.utc().toDate()}catch{throw new Error(`Unrecognized time zone ${o}. Please provide a valid time zone name, abbreviation, or offset. For example, "America/New_York", or "EST".`)}}var gr=s=>se(s).utc().format("YYYY-MM-DD HH:mm:ss [UTC]");var En=new H,ue=(s,e,t,n,o,r=20)=>{let i=(s/e*100).toFixed(1),a=Math.round(r*s/e),l=r-a,p=En.blueBright("\u2588".repeat(a)),c=" ".repeat(l),d=e>0?(t/e*100).toFixed(1):"0.0",u=o.includes("Running MIPROv2 optimization")?"Testing prompt variations":o.includes("Tuning Prompt")?"Generating training examples":o;process.stdout.write(`\u2502 ${u}: ${s}/${e} (${En.yellow(i)}%) |${p}${c}| Success rate: ${En.greenBright(d)}%
|
|
91
91
|
`)},ht=(s,e)=>{let t=s.type??{name:"string",isArray:!1},n=(a,l)=>{switch(a){case"class":return typeof l=="string";case"code":return typeof l=="string";case"string":return typeof l=="string";case"number":return typeof l=="number";case"boolean":return typeof l=="boolean";case"date":return l instanceof Date||typeof l=="string";case"datetime":return l instanceof Date||typeof l=="string";case"json":return typeof l=="object"||typeof l=="string";default:return!1}},o=a=>!(!a||typeof a!="object"||!("mimeType"in a)||!("data"in a));if(s.type?.name==="image"){let a;if(Array.isArray(e)){for(let l of e)if(!o(l)){a="object ({ mimeType: string; data: string })";break}}else o(e)||(a="object ({ mimeType: string; data: string })");if(a)throw new Error(`Validation failed: Expected '${s.name}' to be type '${a}' instead got '${e}'`);return}let r=a=>!(!a||typeof a!="object"||!("data"in a));if(s.type?.name==="audio"){let a;if(Array.isArray(e)){for(let l of e)if(!r(l)){a="object ({ data: string; format?: string })";break}}else r(e)||(a="object ({ data: string; format?: string })");if(a)throw new Error(`Validation failed: Expected '${s.name}' to be type '${a}' instead got '${e}'`);return}let i=!0;if(t.isArray){if(!Array.isArray(e))i=!1;else for(let a of e)if(!n(t.name,a)){i=!1;break}}else i=n(t.name,e);if(!i){let a=Array.isArray(e)?"array":typeof e;throw new Error(`Validation failed: Expected '${s.name}' to be a ${s.type?.isArray?"an array of ":""}${t.name} instead got '${a}' (${JSON.stringify(e)})`)}};function Ar(s){let e={};for(let t of s){let n=`${t.ai}:${t.model}`;if(!e[n]){e[n]={...t};continue}let o=e[n];if(o){let r=o.tokens??{promptTokens:0,completionTokens:0,totalTokens:0};r.promptTokens+=t?.tokens?.promptTokens??0,r.completionTokens+=t?.tokens?.completionTokens??0,r.totalTokens+=t?.tokens?.totalTokens??0,o.tokens=r}}return Object.values(e)}var hr=s=>{if(!s.trim())return[];let e=new Set(["-","*","+"]),t=/^\d+[\s]*[.)\]]\s*/,n=s.split(`
|
|
92
92
|
`),o=[];for(let r of n){let i=r.trim();if(i){if(i[0]&&e.has(i[0]))o.push(i.slice(1).trim());else if(t.test(i))o.push(i.replace(t,"").trim());else if(o.length!==0)throw new Error("Could not parse markdown list: mixed content detected")}}if(o.length===0)throw new Error("Could not parse markdown list: no valid list items found");return o};function _n(s,e){let{index:t,delta:n,version:o}=e,r=s.find(i=>i.index===t)?.delta;if(!r)return s.push({index:t,delta:n,version:o}),s;for(let i of Object.keys(n)){let a=r[i],l=n[i];a===void 0&&Array.isArray(l)?r[i]=[...l]:Array.isArray(a)&&Array.isArray(l)?r[i]=[...a,...l]:(a===void 0||typeof a=="string")&&typeof l=="string"?r[i]=`${a??""}${l}`:r[i]=l}return s}var Pn=class{cache=new Map;maxSize;constructor(e){this.maxSize=e}get(e){let t=this.cache.get(e);return t&&(this.cache.delete(e),this.cache.set(e,t)),t}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){let n=this.cache.keys().next().value;n&&this.cache.delete(n)}this.cache.set(e,t)}},Vs=new Pn(500);function xr(s,e,t=0,n=Vs){if(/^```[a-zA-Z]*\s*$/.test(s))return-4;if(/^[\s`]*$/.test(s))return-3;let o=s.indexOf(e,t);if(o!==-1)return o;let r=n.get(e)??Array.from({length:e.length},(a,l)=>e.slice(0,l+1));n.get(e)||n.set(e,r);let i=-1;for(let a=r.length-1;a>=0;a--){let l=r[a];if(s.endsWith(l)){i=a;break}}return i>=0?-2:-1}var fr=s=>{let e=Math.floor(s/1e3);if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;if(t<60)return`${t}m ${n}s`;let o=Math.floor(t/60),r=t%60;return`${o}h ${r}m ${n}s`},Ws=(s,e,t)=>{if(s===0)return"calculating...";let n=t/s,o=e-s,r=n*o;return fr(r)},yr=(s,e,t,n,o,r,i,a,l)=>{process.stdout.write("\r\x1B[K");let p=(e/t*100).toFixed(1),c=fr(n),d=Ws(e,t,n),u=`Training round ${s+1}/${i.maxRounds}: ${e}/${t} (${p}%) [${c}, ETA: ${d}]`,m=r.totalCalls>0?r.successfulDemos/r.totalCalls*100:0;if(u+=` | Success rate: ${m.toFixed(1)}% (${r.successfulDemos}/${r.totalCalls})`,(i.verboseMode||i.debugMode)&&(i.costMonitoring&&(u+=`
|
|
93
93
|
Tokens: ~${r.estimatedTokenUsage.toLocaleString()} total`),u+=`
|