『チャットの完了を生成』で「Too Many Requests」エラーが発生する

:white_question_mark: Question

『チャットの完了を生成 (Generate Chat Completion)』アクティビティで「Too Many Requests」エラーが発生します。

ソース: Generate Chat Completion
メッセージ: Too Many Requests
RequestId: <Request ID>
ProviderMessage: error - {message=Request too large for gpt-4 in organization <Organization Name> on tokens per min (TPM): Limit 10000, Requested 100000. The input or output tokens must be reduced in order to run successfully. Visit https://platform.openai.com/account/rate-limits to learn more., type=tokens, param=null, code=rate_limit_exceeded}

例外の型: UiPath.BAF.Infrastructure.Exceptions.BusinessActivityExecutionException

UiPath.BAF.Infrastructure.Exceptions.BusinessActivityExecutionException: Too Many Requests
RequestId: <Request ID>
ProviderMessage: error - {message=Request too large for gpt-4 in organization <Organization Name> on tokens per min (TPM): Limit 10000, Requested 100000. The input or output tokens must be reduced in order to run successfully. Visit https://platform.openai.com/account/rate-limits to learn more., type=tokens, param=null, code=rate_limit_exceeded}
at UiPath.BAF.Activities.BAFAsyncCodeActivity`1.EndExecute(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

:light_bulb: Answer

原因

下記 OpenAI 社公開情報 (要サインイン) の記載によると「Too Many Requests」および「Limit 10000, Requested 100000. The input or output tokens must be reduced in order to run successfully.」というエラーメッセージは OpenAI 側から返ってきており、リクエスト可能な TPM (Tokens Per Minute) が上限「10000」であるところを「100000」でリクエストしているため、エラーとなっている可能性があります。
https://platform.openai.com/account/limits

解決策

『チャットの完了を生成 (Generate Chat Completion)』アクティビティでリクエスト可能な TPM (Tokens Per Minute) を制限値内に抑えてリクエストすることをお試しください。