Troubleshooting of OpenAI API: Difference between revisions
Jump to navigation
Jump to search
→Troubleshooting of OpenAI API
| Line 1: | Line 1: | ||
== Troubleshooting of OpenAI API == | == Troubleshooting of OpenAI API == | ||
=== How to fix "An error occurred" === | === How to fix "An error occurred" === | ||
| Line 136: | Line 118: | ||
} | } | ||
</pre> | </pre> | ||
=== How to fix "The model `gtp-4` does not exist" === | === How to fix "The model `gtp-4` does not exist" === | ||
| Line 151: | Line 135: | ||
* Solution: (1) Correct the typo in the model name. (2) Visit the [https://platform.openai.com/docs/models Models - OpenAI API] to view the list of models. You can also go to the [https://openai.com/product/gpt-4 GPT-4 product page] to join the waiting list. | * Solution: (1) Correct the typo in the model name. (2) Visit the [https://platform.openai.com/docs/models Models - OpenAI API] to view the list of models. You can also go to the [https://openai.com/product/gpt-4 GPT-4 product page] to join the waiting list. | ||
=== How to fix "This model's maximum context length is 4097 tokens" === | |||
Error message: | |||
** "The message you submitted was too long, please reload the conversation and submit something shorter." or "This model's maximum context length is 4097 tokens, however you requested 4270 tokens (3770 in your prompt; 500 for the completion). Please reduce your prompt; or completion length." | |||
<pre> | |||
{ | |||
"error": { | |||
"message": "This model's maximum context length is 4097 tokens. However, your messages resulted in 9324 tokens. Please reduce the length of the messages.", | |||
"type": "invalid_request_error", | |||
"param": "messages", | |||
"code": "context_length_exceeded" | |||
} | |||
} | |||
</pre> | |||
Solution: | |||
* Reduce the length of an input message<ref>[https://community.openai.com/t/splitting-chunking-large-input-text-for-summarisation-greater-than-4096-tokens/18494/3 ⬛ Splitting / Chunking Large input text for Summarisation (greater than 4096 tokens....) - General API discussion - OpenAI API Community Forum]</ref>. ([[Count number of characters]]) | |||
* Adjust to another model which support longer text | |||
=== How to fix "The server had an error while processing your request" === | === How to fix "The server had an error while processing your request" === | ||
| Line 202: | Line 207: | ||
* 在問題前面加上 #zh-TW <ref>[https://learntech.tw/chatgpt-traditional-chinese/ ChatGPT:如何強制保持繁體中文輸出 |學科技、省時間 - 學科技]</ref> | * 在問題前面加上 #zh-TW <ref>[https://learntech.tw/chatgpt-traditional-chinese/ ChatGPT:如何強制保持繁體中文輸出 |學科技、省時間 - 學科技]</ref> | ||
* 或「使用臺灣常用的繁體中文」 | * 或「使用臺灣常用的繁體中文」 | ||
== Further reading == | == Further reading == | ||