AJaySi / AI-Writer

Alwrity - AI contextual Content generation Suite. Prevents AI hallucinations, Web Researched factual, SEO optimized content. Get blog Images. Create your AI-Powered Content Agents team. Create content with RAG, Local documents, web urls. Open Source AI writer.
https://alwrity.com
113 stars 38 forks source link

Issue regarding messages result token #14

Closed umesh070 closed 3 months ago

umesh070 commented 3 months ago

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.

umesh070 commented 3 months ago

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

KlotzJesse commented 3 months ago

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.

AJaySi commented 3 months ago

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