Nutlope / aicommits

A CLI that writes your git commit messages for you with AI
https://www.npmjs.com/package/aicommits
MIT License
7.53k stars 360 forks source link

feat: `hostname` config to support other api services #232

Open savoygu opened 11 months ago

eMUQI commented 10 months ago

Nice work! This is also a feature that I have been expecting.

However, after taking a quick look at your commit, I have a few suggestions regarding the code (Please forgive me for not being familiar with JavaScript or Node.js, so my suggestions below may contain errors):

  1. According to the OpenAI Node.js Library, it is actually possible to achieve this functionality by setting the basePath. However, it seems that this project may have modified some of the logic to support proxies, which has resulted in the inability to use this feature. However, I still recommend referring to the naming in the OpenAI Node.js Library and considering using basePath as a more appropriate naming option instead of hostname.

  2. And this commit has given me inspiration. When checking for OPENAI_KEY, OpenAI uses sk- as a prefix. However, when using a third-party basePath, some API distributors or proxies may not adhere to this format. Therefore, when using a third-party basePath, I suggest no longer checking the key format.

savoygu commented 10 months ago

However, it seems that this project may have modified some of the logic to support proxies, which has resulted in the inability to use this feature.

Yes, aicommits encapsulates the logic for the standalone request itself, without the help of the official OpenAI Node.js Library, which requires a lot of tweaking because the basePath in the official library is different from the hostname in the current pr.

For the OPENAI_KEY checksum, it's not really related to basePath, so maybe we can provide another pr to do it.

0xemc commented 9 months ago

Bump on this. Though it looks like hostname must now always be provided and doesn't default to the openai api

toropanov commented 4 months ago

Can you add also custom path for api? I need not /v1/chat/completions but /openai/v1/chat/completions

tgolsen commented 4 months ago

Not to step on toes but I made this PR: https://github.com/Nutlope/aicommits/pull/272

Currently using this with an Azure instance of GPT and it's working for me.