BuilderIO / ai-shell

A CLI that converts natural language to shell commands.
MIT License
4.04k stars 257 forks source link

feat: add custom openai api endpoint #40

Closed kingzez closed 1 year ago

kingzez commented 1 year ago

If you can't access the OpenAI API directly (due to firewall or other issues), you can use it.

And you can custom OpenAI API endpoint to set OPENAI_API_ENDPOINT (default: https://api.openai.com/v1

ai-shell config set OPENAI_API_ENDPOINT=<your proxy endpoint>
steve8708 commented 1 year ago

This is great! Can you add it to the new config UI as well? https://github.com/BuilderIO/ai-shell/blob/main/src/helpers/config.ts#L105-L134

steve8708 commented 1 year ago

looks great! we've just got a merge conflict now, then ready to merge

kingzez commented 1 year ago

done ~

steve8708 commented 1 year ago

thanks for this great contribution @kingzez! will release shortyly

lzhgus commented 1 year ago

Hi @steve8708,

With Azure OpenAI endpoint, I got this error '✖ Invalid config property OPENAI_KEY: Must start with "sk-"', probably you need to change the logic here . Can you please take a look at it? Thanks!

steve8708 commented 1 year ago

oh, they handle different keys too, I'll go back and reopen your issue, as it sounds like the scope of this is larger than first thought

I would had to remove the validation of openai keys, I gues an alternative is if you use azure (e.g. detecting an azure url configured) we add different logic for validating keys (or remove the validation)

interested in sending a PR @lzhgus?

lzhgus commented 1 year ago

@steve8708 , I raised the PR to remove the restriction that require OPENAI_KEY to start with 'SK'. This is because we cannot determine whether the proxy endpoint is for Azure or OpenAI without introducing another configuration setting such as "USEAZURE: boolean". Therefore, I believe it would be better to remove the validation of openai keys. Please review. Thanks!