feat: Azure Vision Support & Docs Update (#1389)

* feat(AzureOpenAI): Vision Support

* chore(ci/OpenAIClient.test): update test to reflect Azure now uses chatCompletion method as opposed to getCompletion, while still testing the latter method

* docs: update documentation mainly revolving around Azure setup, but also reformatting the 'Tokens and API' section completely

* docs: add images and links to ai_setup.md

* docs: ai setup reference
This commit is contained in:
Danny Avila 2023-12-18 18:43:50 -05:00 committed by GitHub
parent c9d3e0ab6a
commit 8d563d61f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 378 additions and 85 deletions

View file

@ -397,7 +397,7 @@ class OpenAIClient extends BaseClient {
let streamResult = null;
this.modelOptions.user = this.user;
const invalidBaseUrl = this.completionsUrl && extractBaseURL(this.completionsUrl) === null;
const useOldMethod = !!(this.azure || invalidBaseUrl || !this.isChatCompletion);
const useOldMethod = !!(invalidBaseUrl || !this.isChatCompletion);
if (typeof opts.onProgress === 'function' && useOldMethod) {
await this.getCompletion(
payload,
@ -764,6 +764,15 @@ ${convo}
modelOptions.max_tokens = 4000;
}
if (this.azure || this.options.azure) {
// Azure does not accept `model` in the body, so we need to remove it.
delete modelOptions.model;
opts.baseURL = this.azureEndpoint.split('/chat')[0];
opts.defaultQuery = { 'api-version': this.azure.azureOpenAIApiVersion };
opts.defaultHeaders = { ...opts.defaultHeaders, 'api-key': this.apiKey };
}
let chatCompletion;
const openai = new OpenAI({
apiKey: this.apiKey,