Skip to content
English

明确的重试范围 ​

策略的具体实现如下。

ts
export async function retryMultipleModelCalls<Value>(request: {
  readonly logger?: import('../structs/debug.js').SubFlowLogger;
  readonly signal?: AbortSignal;
  readonly invoke: () => Promise<Value>;
  readonly retry: (error: unknown) => Promise<Value>;
}): Promise<Value> {
  try {
    return await request.invoke();
  } catch (error) {
    if (!getErrorInfo(error).codes.includes('MODEL_MULTIPLE_CALLS')) throw error;
    return nativeSubFlowAsync(request, 'retry', 'MODEL_MULTIPLE_CALLS', () => request.retry(error));
  }
}

接口参考、使用示例与开发指南。