zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.28k stars 2.99k forks source link

assistant not working #6685

Closed LORE-D-NATO closed 9 months ago

LORE-D-NATO commented 9 months ago

Check for existing issues

Describe the bug / provide steps to reproduce it

The assistant feature does not ask for an API key on a fresh install and instead cmd+enter doesn't do anything. Resetting the key makes cmd+enter generate an empty assistant response.

https://github.com/zed-industries/zed/assets/115497894/4f6e859e-f98d-452a-b3c4-65c3dbc2ff35

Environment

Zed: v0.119.19 (Zed) OS: macOS 14.1.2 Memory: 8 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

If you only need the most recent lines, you can run the zed: open log command palette action to see the last 1000.

2024-01-25T06:41:20 [INFO] ========== starting zed ==========
2024-01-25T06:41:20 [INFO] Opening main db
2024-01-25T06:41:21 [ERROR] crates/settings/src/settings_file.rs:76: EOF while parsing a value at line 1 column 0
2024-01-25T06:41:21 [ERROR] crates/zed/src/zed.rs:538: EOF while parsing a value at line 1 column 0
2024-01-25T06:41:21 [INFO] Opening main db
2024-01-25T06:41:21 [INFO] Node runtime install_if_needed
2024-01-25T06:41:22 [INFO] 0 unhandled notification LogMessage:
{
  "level": 0,
  "message": "[DEBUG] [agent] [2024-01-25T06:41:22.061Z] Agent service starting",
  "metadataStr": "[DEBUG] [agent] [2024-01-25T06:41:22.061Z]",
  "extra": [
    "Agent service starting"
  ]
}
2024-01-25T06:41:22 [INFO] 0 unhandled notification client/registerCapability:
{
  "registrations": [
    {
      "id": "cd70c5dc-8092-4206-8f06-9ee990627207",
      "method": "workspace/didChangeWorkspaceFolders",
      "registerOptions": {}
    }
  ]
}
2024-01-25T06:41:22 [INFO] 0 unhandled notification LogMessage:
{
  "level": 0,
  "message": "[DEBUG] [agent] [2024-01-25T06:41:22.068Z] Telemetry initialized",
  "metadataStr": "[DEBUG] [agent] [2024-01-25T06:41:22.068Z]",
  "extra": [
    "Telemetry initialized"
  ]
}
2024-01-25T06:42:18 [ERROR] crates/ai/src/providers/open_ai/completion.rs
:232: NotPresent
2024-01-25T06:48:26 [ERROR] crates/ai/src/providers/open_ai/completion.rs:286: delete password failed: -25300
ditorodev commented 9 months ago

Dude beware you leaked your openai api key

mrnugget commented 9 months ago

Hey @LORE-D-NATO, thanks for reporting! I'm wondering whether this has something to do with Zed not having access to the key chain. Once you've added the key, does Zed and the key show up in Keychain Access?

  1. Open Keychain Access.app
  2. Search for api.openai.com (this is (1) in the screenshot)
  3. See whether Zed has access to it (that's (2) in screenshot)

screenshot-2024-01-25-10 38 13@2x

NicolayD commented 9 months ago

Hey, @mrnugget, I'm having the same issue, I did what you mention and everything is there as expected.

mikaelsouza commented 9 months ago

The assistant on my machine also didn't work for some reason, but after resetting the key using assistant: reset key, it's working now.

NicolayD commented 9 months ago

I think I wasn't able to save the key with assistant: reset key, I insert it, then I click the button to close the assistant, and when I reopen it it's the same window with the key inserted but I cannot open the assistant chat itself, and upon restart the key does not seem to be saved.

Edit: my bad, hitting Enter closes it and goes to the assistant chat but the key is still not saved.

LORE-D-NATO commented 9 months ago

@mrnugget My keychain looks right. I fixed my issue by generating a new API key -- for some reason a key I generated before adding credits wasn't able to make calls. Thanks!

aalin commented 9 months ago

I don't even have assistant: reset key in my installation, version 0.119.19.

Screenshot 2024-01-25 at 18 30 55
mrnugget commented 9 months ago

@aalin yeah, that's a bug: the assistant: reset key only shows up when you have the assistant window focused.

mrnugget commented 9 months ago

@NicolayD so it still doesn't work, right? Can you provide some exact steps to reproduce?

NicolayD commented 9 months ago

@NicolayD so it still doesn't work, right? Can you provide some exact steps to reproduce?

Actually, I'm not sure how, but it's working now. But there are still several bugs, I think.

I am opening the assistant window, opening the command panel and selecting the assistant: reset key command (it works as you mentioned above), then clicking Enter. I get redirected to the assistant, but if I write something and press Shift-Enter, nothing happens. I have to click the Assist button on top. That way it answers. I'm not sure what changed as I did try this yesterday too. Aside from that though:

NicolayD commented 9 months ago

One more thing I'm wondering about is if there's a way to delete conversations, but that might be better fit for a different issue.

mrnugget commented 9 months ago

Actually, I'm not sure how, but it's working now. But there are still several bugs, I think.

Is this maybe related to this?

https://github.com/zed-industries/zed/issues/6719#issuecomment-1911993130

(FWIW: we're aware that we need to make the whole UX and flow around setting the API key a lot better! I don't want anyone to think I'm coming up with excuses for this flow)

but if I write something and press Shift-Enter, nothing happens. I have to click the Assist button on top. T

Hmmm, the official keybinding is Cmd-enter. But that also doesn't work? Can you reproduce this with the key setup correctly?

NicolayD commented 9 months ago

Actually, I'm not sure how, but it's working now. But there are still several bugs, I think.

Is this maybe related to this?

#6719 (comment)

No, I used an old key. But I also had a similar issue on my personal computer and I'll check later if it works there too.

(FWIW: we're aware that we need to make the whole UX and flow around setting the API key a lot better! I don't want anyone to think I'm coming up with excuses for this flow)

You guys are amazing, I already love the app, it's great! I hope I didn't sound too critical, but I was just trying to give feedback. :) And the fact that you're so responsive is honestly unbelievable, after all the publicity in the last few days. Thanks for everything you're doing.

but if I write something and press Shift-Enter, nothing happens. I have to click the Assist button on top. T

Hmmm, the official keybinding is Cmd-enter. But that also doesn't work? Can you reproduce this with the key setup correctly?

Yeah, that worked! Thanks, I thought I tried and had an issue with it but I was probably mixing things up, sorry about that.

noah-troncoso commented 9 months ago

I'm experiencing this issue as well. I checked my Keychain and I just generated a new key today. This is a fresh install of Zed. Is there any more information I can provide to help resolve this issue?

mrnugget commented 9 months ago

@noah-troncoso did you add credits to your OpenAI platform account? That's the thing that I ran into when I first tried to use it.

multipletwigs commented 9 months ago

Hey @mrnugget @mikaelsouza, I've managed to get the cmd + Enter on the assistant to work now! I had to...

  1. Generate a new API key, add some credits
  2. Run cmd + shift + p > assistant: reset key by focusing on the assistants panel
  3. Restart Zed!

Appreciate everyone's help here!

vigneshksaithal commented 9 months ago

Hey @mrnugget @mikaelsouza, I've managed to get the cmd + Enter on the assistant to work now! I had to...

  1. Generate a new API key, add some credits
  2. Run cmd + shift + p > assistant: reset key by focusing on the assistants panel
  3. Restart Zed!

Appreciate everyone's help here!

It worked, Thank you @multipletwigs

mrnugget commented 9 months ago

FWIW I updated the docs https://zed.dev/docs/assistant-panel. We still need to fix that the action doesn't show up when the panel isn't focused.

mrnugget commented 9 months ago

I also just merged a PR that should fix the root problem: https://github.com/zed-industries/zed/pull/7197

Once this is released, I can revert my changes to the docs.

0xFlo commented 8 months ago

even when entering the API key, it doesn't work

mrnugget commented 8 months ago

Do you have credits on your account?

0xFlo commented 8 months ago

No, that was the problem! I thought it wasn't needed because I used the AI before without credits but maybe it's because I cancelled my subscription earlier. It's working with having active credits on my account. Thanks!

On Thu, 22 Feb 2024 at 16:24, Thorsten Ball @.***> wrote:

Do you have credits on your account?

— Reply to this email directly, view it on GitHub https://github.com/zed-industries/zed/issues/6685#issuecomment-1959805409, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANWQBGWCQSC5U5JSOM647EDYU5WMTAVCNFSM6AAAAABCKAB4K6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJZHAYDKNBQHE . You are receiving this because you commented.Message ID: @.***>

hsiachi commented 8 months ago

Hi, I wonder whether it is necessary to buy credits to use the assistant if my OpenAI account is under Pay-as-you-go billing plan. I could normally call the OpenAI API, but fail to use the Zed assistant. I have tried to reset the key, but it still didn't work.

mrnugget commented 8 months ago

I think Pay-as-you-go means that your credits are used in a pay-as-you-go way, vs. monthly costs billed to you.

Here's a screenshot from my account:

screenshot-2024-02-28-09 34 42@2x

Notice that it says Pay-as-you-go and I have credits.

xinx1n commented 8 months ago

The key is not recorded correctly in the keychain access app,only 'sk-' can be saved.

hsiachi commented 8 months ago

Oh sorry I made confusion. I was supposed to say the monthly bill. Here's a screenshot of my account: image

mrnugget commented 8 months ago

@hsiachi can you create a new issue for that? OpenAI API access does not work with "Pending Invoice" pay-as-you-go billing or something like that?

hsiachi commented 8 months ago

@hsiachi can you create a new issue for that? OpenAI API access does not work with "Pending Invoice" pay-as-you-go billing or something like that?

Yeah sure, it's now in #8585. Thank you so much for your help!