zed icon indicating copy to clipboard operation
zed copied to clipboard

assistant not working

Open LORE-D-NATO opened this issue 1 year ago • 17 comments

Check for existing issues

  • [X] Completed

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

LORE-D-NATO avatar Jan 25 '24 07:01 LORE-D-NATO

Dude beware you leaked your openai api key

ditorodev avatar Jan 25 '24 07:01 ditorodev

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

mrnugget avatar Jan 25 '24 09:01 mrnugget

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

NicolayD avatar Jan 25 '24 14:01 NicolayD

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.

mikaelsouza avatar Jan 25 '24 16:01 mikaelsouza

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.

NicolayD avatar Jan 25 '24 16:01 NicolayD

@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!

LORE-D-NATO avatar Jan 25 '24 17:01 LORE-D-NATO

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

Screenshot 2024-01-25 at 18 30 55

aalin avatar Jan 25 '24 23:01 aalin

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

mrnugget avatar Jan 26 '24 08:01 mrnugget

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

mrnugget avatar Jan 26 '24 08:01 mrnugget

@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:

  • I think the shortcut for the Assist button doesn't work - it should be Cmd-Enter according to the pop-up hint but that or even Cmd-Shift-Enter does nothing.
  • when I tried to check if my OpenAI key is saved, it's not displayed. I guess that might be better for security purposes but still it would be good to see if the configuration is valid. But also, I couldn't find a way to go back to the assistant panel without inputting a key again and pressing Enter. Closing and reopening the panel still show the reset key window and pressing Enter without inputting a key does nothing.
  • the Close Right Dock button (Cmd-R) doesn't work - I tried Cmd-R and Cmd-Shift-R.

I might be missing something or doing something wrong though, I'll look through the docs again.

NicolayD avatar Jan 26 '24 10:01 NicolayD

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.

NicolayD avatar Jan 26 '24 11:01 NicolayD

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?

mrnugget avatar Jan 26 '24 13:01 mrnugget

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.

NicolayD avatar Jan 26 '24 14:01 NicolayD

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?

noah-troncoso avatar Jan 26 '24 16:01 noah-troncoso

@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.

mrnugget avatar Jan 26 '24 16:01 mrnugget

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!

multipletwigs avatar Jan 27 '24 06:01 multipletwigs

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

vigneshksaithal avatar Jan 28 '24 06:01 vigneshksaithal

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 avatar Feb 01 '24 08:02 mrnugget

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.

mrnugget avatar Feb 01 '24 10:02 mrnugget

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

0xFlo avatar Feb 22 '24 10:02 0xFlo

Do you have credits on your account?

mrnugget avatar Feb 22 '24 16:02 mrnugget

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: @.***>

0xFlo avatar Feb 22 '24 21:02 0xFlo

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.

hsiachi avatar Feb 28 '24 07:02 hsiachi

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.

mrnugget avatar Feb 28 '24 08:02 mrnugget

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

xinx1n avatar Feb 29 '24 02:02 xinx1n

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

hsiachi avatar Feb 29 '24 03:02 hsiachi

@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?

mrnugget avatar Feb 29 '24 08:02 mrnugget

@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!

hsiachi avatar Feb 29 '24 08:02 hsiachi