mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🔗 fix: Provided Azure Base URL Construction for Responses API (#10289)
* fix: response api works with azure base url configured * add unit test --------- Co-authored-by: Peter Rothlaender <peter.rothlaender@ginkgo.com>
This commit is contained in:
parent
ce6456c39f
commit
658921af88
2 changed files with 24 additions and 1 deletions
|
|
@ -737,6 +737,27 @@ describe('getOpenAIConfig', () => {
|
|||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should create correct Azure baseURL when response api is selected', () => {
|
||||
const azure = {
|
||||
azureOpenAIApiInstanceName: 'test-instance',
|
||||
azureOpenAIApiDeploymentName: 'test-deployment',
|
||||
azureOpenAIApiVersion: '2023-08-15',
|
||||
azureOpenAIApiKey: 'azure-key',
|
||||
};
|
||||
|
||||
const result = getOpenAIConfig(mockApiKey, {
|
||||
azure,
|
||||
modelOptions: { useResponsesApi: true },
|
||||
reverseProxyUrl:
|
||||
'https://${INSTANCE_NAME}.openai.azure.com/openai/deployments/${DEPLOYMENT_NAME}',
|
||||
});
|
||||
|
||||
expect(result.configOptions?.baseURL).toBe(
|
||||
'https://test-instance.openai.azure.com/openai/v1',
|
||||
);
|
||||
expect(result.configOptions?.baseURL).not.toContain('deployments');
|
||||
});
|
||||
|
||||
it('should handle Azure with organization from environment', () => {
|
||||
const originalOrg = process.env.OPENAI_ORGANIZATION;
|
||||
process.env.OPENAI_ORGANIZATION = 'test-org-123';
|
||||
|
|
|
|||
|
|
@ -113,8 +113,10 @@ export function getOpenAIConfig(
|
|||
return;
|
||||
}
|
||||
|
||||
const updatedUrl = configOptions.baseURL?.replace(/\/deployments(?:\/.*)?$/, '/v1');
|
||||
|
||||
configOptions.baseURL = constructAzureURL({
|
||||
baseURL: configOptions.baseURL || 'https://${INSTANCE_NAME}.openai.azure.com/openai/v1',
|
||||
baseURL: updatedUrl || 'https://${INSTANCE_NAME}.openai.azure.com/openai/v1',
|
||||
azureOptions: azure,
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue