Nutlope / aicommits

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

Set path, hostname, auth #272

Open tgolsen opened 7 months ago

tgolsen commented 7 months ago

This PR lets you set your hostname and path, as well as change your auth type. This was driven by necessity to connect to the Azure instance of ChatGPT I wanted to connect to. I'm using this version to write my commit messages now.

First, new configs:

./dist/cli.mjs config set OPENAI_KEY=****
./dist/cli.mjs config set authHeaderName=api-key
./dist/cli.mjs config set hostname=gpt4-resources.openai.azure.com
./dist/cli.mjs config set apipath='/openai/deployments/*****/chat/completions?api-version=2023-05-15'

OPENAI_KEY works with AuthHeaderName to create something like the below.

  headers: {
    'api-key': '***',
    ...
  },
# Or, by default
  headers: {
    'Authorization': 'Bearer sk-***',
    ...
  },

The fields hostname and apipath are probably self-explanatory.

I'm failing some tests, but so is develop 🤔 So I'm not sure if this is a step back or something up with my local set up.

image image

Looking forward to feedback!