diff --git a/packages/gen-ai-hub/src/client/openai/openai-client.ts b/packages/gen-ai-hub/src/client/openai/openai-client.ts index 9c949ff6..561821f5 100644 --- a/packages/gen-ai-hub/src/client/openai/openai-client.ts +++ b/packages/gen-ai-hub/src/client/openai/openai-client.ts @@ -1,6 +1,6 @@ import { type HttpRequestConfig } from '@sap-cloud-sdk/http-client'; import { type CustomRequestConfig, executeRequest } from '@sap-ai-sdk/core'; -import { pickValueIgnoreCase } from '@sap-cloud-sdk/util'; +import { mergeIgnoreCase, pickValueIgnoreCase } from '@sap-cloud-sdk/util'; import { type DeploymentConfiguration, type FoundationModel, @@ -100,16 +100,21 @@ function translateToFoundationModel( }; } -// TODO: merge headers and query params too?! function mergeRequestConfig( requestConfig?: CustomRequestConfig ): HttpRequestConfig { return { method: 'POST', - headers: { - 'content-type': 'application/json' - }, - params: { 'api-version': apiVersion }, + headers: mergeIgnoreCase( + { + 'content-type': 'application/json' + }, + requestConfig?.headers + ), + params: mergeIgnoreCase( + { 'api-version': apiVersion }, + requestConfig?.params + ), ...requestConfig }; } diff --git a/packages/gen-ai-hub/src/utils/deployment-resolver.test.ts b/packages/gen-ai-hub/src/utils/deployment-resolver.test.ts index 71a949db..99bbafa7 100644 --- a/packages/gen-ai-hub/src/utils/deployment-resolver.test.ts +++ b/packages/gen-ai-hub/src/utils/deployment-resolver.test.ts @@ -19,13 +19,13 @@ describe('deployment resolver', () => { mockResponse(); }); - // it('should return the first deployment, if multiple are given', async () => { - // const { id, configurationId } = await resolveDeployment({ - // scenarioId: 'foundation-models', - // }); - // expect(id).toBe('1'); - // expect(configurationId).toBe('c1'); - // }); + it('should return the first deployment, if multiple are given', async () => { + const { id, configurationId } = await resolveDeployment({ + scenarioId: 'foundation-models' + }); + expect(id).toBe('1'); + expect(configurationId).toBe('c1'); + }); it('should return the first deployment with the correct model name', async () => { const { id } = await resolveDeployment({ diff --git a/packages/gen-ai-hub/src/utils/deployment-resolver.ts b/packages/gen-ai-hub/src/utils/deployment-resolver.ts index 57bd2796..fc31eb64 100644 --- a/packages/gen-ai-hub/src/utils/deployment-resolver.ts +++ b/packages/gen-ai-hub/src/utils/deployment-resolver.ts @@ -83,7 +83,7 @@ interface DeploymentResolutionOptions { /** * The name and potentially version of the model to look for. */ - model: FoundationModel; + model?: FoundationModel; /** * The executable ID of the deployment. */