@nomyx/assistant
Version:
A powerful assistant library and cli for your AI projects. works with Vertex AI (Claude and Gemini)
47 lines (40 loc) • 1.29 kB
text/typescript
import { ILogger } from '../../../types/common';
import { AzureProviderConfig } from './types';
export class AzureConfig {
private config: AzureProviderConfig;
private logger: ILogger;
constructor(config: AzureProviderConfig, logger: ILogger) {
this.config = config;
this.logger = logger;
this.logger.debug(`AzureConfig initialized with endpoint: ${this.config.endpoint}`);
}
get apiKey(): string {
return this.config.apiKey;
}
get endpoint(): string {
let endpoint = this.config.endpoint;
if (!endpoint.startsWith('https://') && !endpoint.startsWith('http://')) {
endpoint = `https://${endpoint}`;
}
this.logger.debug(`AzureConfig endpoint: ${endpoint}`);
return endpoint;
}
get deployment(): string {
return this.config.deployment;
}
get subscriptionId(): string {
return this.config.subscriptionId;
}
getApiUrl(path: string): string {
let baseUrl = this.endpoint
if (!baseUrl.endsWith('.openai.azure.com')) {
baseUrl += '.openai.azure.com';
}
if (!baseUrl.endsWith('/')) {
baseUrl += '/';
}
const apiUrl = `${baseUrl}openai/deployments/${this.deployment}/${path}?api-version=2023-05-15`;
this.logger.debug(`AzureConfig getApiUrl: ${apiUrl}`);
return apiUrl;
}
}