Robitx/gp.nvim

Stopped working for me a few days ago. The chat immediately returns an empty response. Where are the logs?

Closed this issue · 4 comments

I've been absolutely loving this plugin and use it all the time but it stopped working for me a few days ago.

How can I get diagnostic info about why it returns an empty response every time? I dont see any mention of logging output in the readme.

Thank you

@EvanDaley OpenAI recently switched to prepaid billing https://help.openai.com/en/articles/8264644-what-is-prepaid-billing

If this is the case, after you buy some credits, the original API key may still not work immediately (you could speed things up by making a new key and switching to it).

Try running the following with the same API key you're using for Gp.

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-3.5-turbo",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Hello!"
      }
    ],
    "stream": true
  }'

And concerning the logs, there is :GpInspectPlugin command which responds with the state of the plugin including most recent _queries.

Ah shoot, yeah the prepaid thing got me. Its working now. Thanks robitx!

In case someone hits the same issue, the latest version supports sensitive logging

 	-- log file location 
 	log_file = vim.fn.stdpath("log"):gsub("/$", "") .. "/gp.nvim.log", 
 	-- write sensitive data to log file for	debugging purposes (like api keys) 
 	log_sensitive = false, 

when enabled, the :GpInspectLog will show log full curl commands run against providers, such as:

[2024-07-30.08-24-30.212] [284dedb7] DEBUG: [SENSITIVE DATA] vault get_secret openai_api_key:	"sk-..."
[2024-07-30.08-24-30.212] [284dedb7] DEBUG: [SENSITIVE DATA] run command: curl --no-buffer -s https://api.openai.com/v1/chat/completions -H Content-Type: application/json -d {"model":"gpt-4o","top_p":1,"temperature":1.1,"messages":[{"content":"You are a general AI assistant.\n\nThe user provided the additional info about how they would like you to respond:\n\n- If you're unsure don't guess and say you don't know instead.\n- Ask question if you need clarification to provide better answer.\n- Think deeply and carefully from first principles step by step.\n- Zoom out first to see the big picture and then zoom in to details.\n- Use Socratic method to improve your thinking and coding skills.\n- Don't elide any code from your output if the answer requires coding.\n- Take a deep breath; You've got this!","role":"system"},{"content":"Hello there.","role":"user"}],"stream":true} -H Authorization: Bearer sk-... -H api-key: sk-...
[2024-07-30.08-24-30.216] [284dedb7] DEBUG: [SENSITIVE DATA] curl command started with pid: 2636159
[2024-07-30.08-24-37.711] [284dedb7] DEBUG: [SENSITIVE DATA] vault get_secret openai_api_key:	"sk-..."
[2024-07-30.08-24-37.711] [284dedb7] DEBUG: [SENSITIVE DATA] run command: curl --no-buffer -s https://api.openai.com/v1/chat/completions -H Content-Type: application/json -d {"model":"gpt-4o","top_p":1,"temperature":1.1,"messages":[{"content":"You are a general AI assistant.\n\nThe user provided the additional info about how they would like you to respond:\n\n- If you're unsure don't guess and say you don't know instead.\n- Ask question if you need clarification to provide better answer.\n- Think deeply and carefully from first principles step by step.\n- Zoom out first to see the big picture and then zoom in to details.\n- Use Socratic method to improve your thinking and coding skills.\n- Don't elide any code from your output if the answer requires coding.\n- Take a deep breath; You've got this!","role":"system"},{"content":"Hello there.","role":"user"},{"content":"Hello! How can I assist you today? Is there something specific you're working on or something you'd like to know more about?","role":"assistant"},{"content":"Summarize the topic of our conversation above in two or three words. Respond only with those words.","role":"user"}],"stream":true} -H Authorization: Bearer sk-... -H api-key: sk-...

(Just be careful not posting your secret keys, I've redacted them manually in the example).