Not
Bu sayfaya erişim yetkilendirme gerektiriyor. Oturum açmayı veya dizinleri değiştirmeyi deneyebilirsiniz.
Bu sayfaya erişim yetkilendirme gerektiriyor. Dizinleri değiştirmeyi deneyebilirsiniz.
Uygulamanızda OpenAI API'lerini kullandığınızda uygulamanızın API hatalarını nasıl işlediğini test etmelisiniz. Dev Proxy, GenericRandomErrorPluginkullanarak herhangi bir OpenAI API'sinde hataların benzetimini yapmanızı sağlar.
Bahşiş
devproxy preset get openai-throttling
komut isteminde komutunu çalıştırarak bu ön ayarı indirin.
Dev Proxy yükleme klasöründe presets
klasörünü bulun.
presets
klasöründe openai-errors.json
adlı yeni bir dosya oluşturun. Dosyayı bir kod düzenleyicisinde açın.
GenericRandomErrorPlugin
'i referans eden plugins
dizisinde yeni bir nesne oluşturun. OpenAI API URL'sini eklentinin izlemesi için tanımlayın ve eklenti yapılandırmasına bir referans ekleyin.
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.29.2/rc.schema.json",
"plugins": [
{
"name": "GenericRandomErrorPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "openAIAPI",
"urlsToWatch": [
"https://api.openai.com/*"
]
}
]
}
Eklentiye hata yanıtlarının konumunu sağlamak için eklenti yapılandırma nesnesini oluşturun.
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.23.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"
}
}
Aynı klasörde errors-openai.json
dosyasını oluşturun. Bu dosya, eklenti bir hata yanıtı gönderdiğinde döndürülebilecek olası hata yanıtlarını içerir.
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v0.23.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
}
}
}
]
}
]
}
Geliştirme Proxy'sini yapılandırma dosyasıyla başlatın:
devproxy --config-file "~appFolder/presets/openai-errors.json"
Uygulamanızı OpenAI API'lerini çağırarak kullandığınızda Dev Proxy, errors-openai.json
dosyasında tanımladığınız hata yanıtlarından birini rastgele döndürür.
GenericRandomErrorPlugin hakkında daha fazla bilgi edinin.