pfrankov / obsidian-local-gpt

Local Ollama and OpenAI-like GPT's assistance for maximum privacy and offline access
MIT License
265 stars 18 forks source link

[BUG] Multiple API calls are performed instead of one #26

Open martineliascz opened 3 weeks ago

martineliascz commented 3 weeks ago

Hi Pavel,

I appreciate the Local GPT plugin for its immense productivity boost! 🔥

However, I've seen that each action makes two API calls instead of just one, which unnecessarily increases credit usage. It's critical to address this bug with a single API call to reduce these costs.

Proposed adjustment: Make only one API request per action to preserve credits.

Observing the issue involves: Performing any action needing an API request - basically any prompt action.

Observations show two requests are made instead of only one. This issue happens only when using Local GPT plugin for Obsidian.

Fixing this will make the plugin more economically feasible, ensuring I'm eager to use it daily.

Thank you for considering this change and fix.

Br, Martin

image

pfrankov commented 3 weeks ago

Thank you for the feedback! Unfortunately preflight request is unavoidable in browser (which Obsidian actually is). It should be excluded by the AI provider that you use. Try to reach the support and ask them to exclude OPTIONS (Preflight) requests from the tariff.

martineliascz commented 3 weeks ago

Hi @pfrankov,

Thank you so much for taking the time to respond to my previous message; your assistance is greatly appreciated. I wanted to update you on some tests I carried out recently regarding various plugins in Obsidian, particularly focusing on the Local GPT plugin.

After extensively retesting 8 other Obsidian plugins, I have observed that the issue seems to be isolated to the Local GPT plugin. I am currently using a custom API proxy that has consistently demonstrated compatibility across numerous other AI tools, plugins, and services without any hitch. Hence, this leads me to believe that the underlying problem might be unique to the Local GPT plugin.

The specific issue I am encountering with Local GPT is that it generates two requests instead of the expected one. I am curious to know if there is a possibility to address this discrepancy directly within the plugin’s configuration or code to ensure it performs optimally.

I'm puzzled as to why this issue only manifests with the Local GPT plugin, especially considering that all other AI-related plugins in Obsidian seem to function perfectly without any complications. Could this be an indication of a more intricate problem that doesn't affect the other plugins?

Your insights or any potential solutions you might have would be invaluable. Thank you once again for your help and attention to this matter, and I look forward to any advice you can provide.

Br, Martin

screenshot

martineliascz commented 1 week ago

Hi @pfrankov, have you had the opportunity to look into the issue? Do you need any additional input from me to move forward with the fix? The Local GPT plugin is the top Obsidian plugin, but it's not advisable to use it because it consumes double the credits, at least for me.. I haven't encountered this issue with other less popular plugins.. Thanks!

pfrankov commented 1 week ago

@martineliascz Sadly I can not reproduce any difference between Text Generator and Local GPT — I have only one request each time. Please provide the data.json for both plugins located in {{PATH_TO_YOUR_OBSIDIAN_VAULT}}/.obsidian/plugins