Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Wanneer u OpenAI-API's in uw app gebruikt, moet u testen hoe uw app API-fouten verwerkt. Met dev Proxy kunt u fouten in elke OpenAI-API simuleren met behulp van de GenericRandomErrorPlugin.
Tip
Download deze voorinstelling door in de opdrachtprompt devproxy config get openai-throttlinguit te voeren.
Zoek in de map Dev Proxy install de map config. Maak in de map config een nieuw bestand met de naam openai-errors.json. Open het bestand in een code-editor.
Maak een nieuw object in de plugins matrix waarnaar de GenericRandomErrorPluginverwijst. Definieer de OpenAI API URL voor de plugin om naar te kijken en voeg een verwijzing toe aan de configuratie van de plugin.
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/rc.schema.json",
"plugins": [
{
"name": "GenericRandomErrorPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "openAIAPI",
"urlsToWatch": [
"https://api.openai.com/*"
]
}
]
}
Maak het configuratieobject van de invoegtoepassing om de invoegtoepassing de locatie van de foutreacties te geven.
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/rc.schema.json",
"plugins": [
{
"name": "GenericRandomErrorPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "openAIAPI",
"urlsToWatch": [
"https://api.openai.com/*"
]
}
],
"openAIAPI": {
"errorsFile": "errors-openai.json"
}
}
Maak in dezelfde map het errors-openai.json-bestand. Dit bestand bevat de mogelijke foutreacties die kunnen worden geretourneerd wanneer de invoegtoepassing een foutmelding verzendt.
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/genericrandomerrorplugin.schema.json",
"errors": [
{
"request": {
"url": "https://api.openai.com/*"
},
"responses": [
{
"statusCode": 429,
"headers": [
{
"name": "content-type",
"value": "application/json; charset=utf-8"
}
],
"body": {
"error": {
"message": "Rate limit reached for default-text-davinci-003 in organization org-K7hT684bLccDbBRnySOoK9f2 on tokens per min. Limit: 150000.000000 / min. Current: 160000.000000 / min. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://beta.openai.com/account/billing to add a payment method.",
"type": "tokens",
"param": null,
"code": null
}
}
},
{
"statusCode": 429,
"headers": [
{
"name": "content-type",
"value": "application/json; charset=utf-8"
}
],
"body": {
"error": {
"message": "Rate limit reached for default-text-davinci-003 in organization org-K7hT684bLccDbBRnySOoK9f2 on requests per min. Limit: 60.000000 / min. Current: 70.000000 / min. Contact support@openai.com if you continue to have issues. Please add a payment method to your account to increase your rate limit. Visit https://beta.openai.com/account/billing to add a payment method.",
"type": "requests",
"param": null,
"code": null
}
}
},
{
"statusCode": 429,
"addDynamicRetryAfter": true,
"headers": [
{
"name": "content-type",
"value": "application/json; charset=utf-8"
}
],
"body": {
"error": {
"message": "The engine is currently overloaded, please try again later.",
"type": "requests",
"param": null,
"code": null
}
}
}
]
}
]
}
Start Dev Proxy met het configuratiebestand:
devproxy --config-file "~appFolder/config/openai-errors.json"
Wanneer u uw app gebruikt die OpenAI-API's aanroept, retourneert Dev Proxy willekeurig een van de foutreacties die u hebt gedefinieerd in het errors-openai.json-bestand.
Meer informatie over genericRandomErrorPlugin.