[GH-ISSUE #14] Issue regarding messages result token #345

Closed
opened 2026-03-13 20:04:28 +03:00 by kerem · 3 comments
Owner

Originally created by @uniqueumesh on GitHub (Mar 26, 2024).
Original GitHub issue: https://github.com/AJaySi/ALwrity/issues/14

ERROR|metaphor_basic_neural_web_search.py:213:save_in_file| Error occurred while writing to the file: [Errno 2] No such file or directory: 'C:\Users\Dell\AI-Blog-Writer\workspace\web_research_reports\kanamo_peak_trek_in_details_2024-03-23_18-41-33'
INFO|combine_research_and_blog.py:75:blog_with_research| Calling OpenAI LLM.
2024-03-23 18:44:14,373-INFO-_client-1013-HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 400 Bad Request"
2024-03-23 18:44:14,388-ERROR-openai_chat_completion-53-OpenAI API Error: Error code: 400 - {'error': {'message': "This model's maximum context length is 16385 tokens. However, your messages resulted in 25664 tokens. Please reduce the length of the messages.", 'type': 'invalid_request_error', 'param': 'messages', 'code': 'context_length_exceeded'}}
PS C:\Users\Dell\AI-Blog-Writer>

  1. I am getting the above issue while using open AI API. In Gemini API I do not have the same issue.
  2. While using Open AI API, the blog category is not coming in the results, while with Gemini API it's coming.

Thank you for your help regarding this issue.

Originally created by @uniqueumesh on GitHub (Mar 26, 2024). Original GitHub issue: https://github.com/AJaySi/ALwrity/issues/14 ERROR|metaphor_basic_neural_web_search.py:213:save_in_file| Error occurred while writing to the file: [Errno 2] No such file or directory: 'C:\\Users\\Dell\\AI-Blog-Writer\\workspace\\web_research_reports\\kanamo_peak_trek_in_details_2024-03-23_18-41-33' INFO|combine_research_and_blog.py:75:blog_with_research| Calling OpenAI LLM. 2024-03-23 18:44:14,373-INFO-_client-1013-HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 400 Bad Request" 2024-03-23 18:44:14,388-ERROR-openai_chat_completion-53-OpenAI API Error: Error code: 400 - {'error': {'message': "This model's maximum context length is 16385 tokens. However, your messages resulted in 25664 tokens. Please reduce the length of the messages.", 'type': 'invalid_request_error', 'param': 'messages', 'code': 'context_length_exceeded'}} PS C:\Users\Dell\AI-Blog-Writer> 1. I am getting the above issue while using open AI API. In Gemini API I do not have the same issue. 2. While using Open AI API, the blog category is not coming in the results, while with Gemini API it's coming. Thank you for your help regarding this issue.
kerem closed this issue 2026-03-13 20:04:34 +03:00
Author
Owner

@uniqueumesh commented on GitHub (Mar 26, 2024):

INFO|get_blog_category.py:29:get_blog_categories| Generating blog categories for the given blog.
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:10<00:00, 1.00s/it]
2024-03-26 23:42:49,091-INFO-_client-1013-HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 404 Not Found"
INFO|get_blog_metadata.py:24:blog_metadata| Generated blog categories: None

<!-- gh-comment-id:2021165545 --> @uniqueumesh commented on GitHub (Mar 26, 2024): INFO|get_blog_category.py:29:get_blog_categories| Generating blog categories for the given blog. 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:10<00:00, 1.00s/it] 2024-03-26 23:42:49,091-INFO-_client-1013-HTTP Request: POST https://api.openai.com/v1/chat/completions "HTTP/1.1 404 Not Found" INFO|get_blog_metadata.py:24:blog_metadata| Generated blog categories: None
Author
Owner

@KlotzJesse commented on GitHub (Mar 26, 2024):

Quick fixes:
Error occurred while writing to the file: [Errno 2] No such file or directory:
Fix for the missing folder, just create it for now, until the script is automatically generating the folder:
in your cloned project, inside the workspace folder, create a web_research_reports folder.

For the openai error 'code': 'context_length_exceeded:

For now, just choose a model with a larger context range:
https://platform.openai.com/docs/models/continuous-model-upgrades

e.g. gpt-4-0125-preview

found in following methods:
https://github.com/search?q=repo%3AAJaySi%2FAI-Blog-Writer+gpt-3.5&type=code

@A-jmesh

For long-term fixes, we should make a pull request so that the script is automatically creating the folders and make the model configurable in the config. As the config is atm not integrated as i've seen, it should both be tackled when this will be done.

<!-- gh-comment-id:2021194617 --> @KlotzJesse commented on GitHub (Mar 26, 2024): Quick fixes: `Error occurred while writing to the file: [Errno 2] No such file or directory:` Fix for the missing folder, just create it for now, until the script is automatically generating the folder: in your cloned project, inside the workspace folder, create a `web_research_reports` folder. For the openai error `'code': 'context_length_exceeded:` For now, just choose a model with a larger context range: https://platform.openai.com/docs/models/continuous-model-upgrades e.g. `gpt-4-0125-preview` found in following methods: https://github.com/search?q=repo%3AAJaySi%2FAI-Blog-Writer+gpt-3.5&type=code @A-jmesh For long-term fixes, we should make a pull request so that the script is automatically creating the folders and make the model configurable in the config. As the config is atm not integrated as i've seen, it should both be tackled when this will be done.
Author
Owner

@AJaySi commented on GitHub (Mar 27, 2024):

@KlotzJesse Thanks a lot.
As per your last comments, I am making config_main changes and will ask for your review.
Regards.

<!-- gh-comment-id:2023213709 --> @AJaySi commented on GitHub (Mar 27, 2024): @KlotzJesse Thanks a lot. As per your last comments, I am making config_main changes and will ask for your review. Regards.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ALwrity#345
No description provided.