Skip to content

enhance: ask user for OpenAI key and store it in the cred store #396

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 5, 2024

Conversation

g-linville
Copy link
Member

No description provided.

@g-linville g-linville marked this pull request as ready for review May 31, 2024 00:13
return nil, err
}

oAIClient, err := openai.NewClient(cliCfg, opts.CredentialContext, opts.OpenAI, openai.Options{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
oAIClient, err := openai.NewClient(cliCfg, opts.CredentialContext, opts.OpenAI, openai.Options{
oaiClient, err := openai.NewClient(cliCfg, opts.CredentialContext, opts.OpenAI, openai.Options{

@g-linville g-linville marked this pull request as draft June 1, 2024 14:16
@g-linville g-linville force-pushed the openai-credential branch 2 times, most recently from d9190b5 to 145a039 Compare June 3, 2024 14:50
@g-linville g-linville marked this pull request as ready for review June 3, 2024 14:50
@g-linville
Copy link
Member Author

I made some pretty substantial changes to this PR:

  • We now use SysPrompt to ask the user (which means I had to move it to its own package in order to avoid an import cycle)
  • We only prompt the user for the token when it is actually needed
    • This involved creating a custom error type and checking for it in a couple places, which is a bit gross but is the cleanest solution I could come up with for this

@g-linville g-linville requested review from thedadams and njhale June 3, 2024 14:51
@cjellick
Copy link
Contributor

cjellick commented Jun 3, 2024

We will need to make sure this works with @tylerslaton's UI, once he has prompting support

@g-linville g-linville marked this pull request as draft June 4, 2024 14:22
@g-linville g-linville force-pushed the openai-credential branch from d1f3e8a to 49e83fe Compare June 4, 2024 14:50
@g-linville
Copy link
Member Author

Okay, this is finally ready again. Darren wanted me to add support for the remote client to prompt for credentials as well, so that is the main thing I introduced. I also had to make some changes to accommodate the changes in the prompt server.

@g-linville g-linville marked this pull request as ready for review June 4, 2024 16:02
@g-linville g-linville force-pushed the openai-credential branch from 62807c0 to 2b377fc Compare June 4, 2024 21:24
@g-linville g-linville force-pushed the openai-credential branch from 10a2287 to f8cbdd5 Compare June 5, 2024 00:29
Signed-off-by: Grant Linville <[email protected]>
@g-linville g-linville merged commit 49fc1c9 into gptscript-ai:main Jun 5, 2024
2 checks passed
@g-linville g-linville deleted the openai-credential branch June 5, 2024 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants