Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marikaner committed Aug 27, 2024
1 parent aae6fc8 commit 1aa5689
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
17 changes: 11 additions & 6 deletions packages/gen-ai-hub/src/client/openai/openai-client.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
};
}
14 changes: 7 additions & 7 deletions packages/gen-ai-hub/src/utils/deployment-resolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion packages/gen-ai-hub/src/utils/deployment-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 1aa5689

Please sign in to comment.