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 5fd4200e..bc1986ce 100644 --- a/packages/gen-ai-hub/src/client/openai/openai-client.ts +++ b/packages/gen-ai-hub/src/client/openai/openai-client.ts @@ -2,9 +2,9 @@ import { type HttpRequestConfig } from '@sap-cloud-sdk/http-client'; import { type CustomRequestConfig, executeRequest } from '@sap-ai-sdk/core'; import { mergeIgnoreCase, pickValueIgnoreCase } from '@sap-cloud-sdk/util'; import { - type DeploymentConfiguration, + type ModelDeployment, type FoundationModel, - type ModelConfiguration, + type Model, isDeploymentIdConfiguration, resolveDeployment } from '../../utils/deployment-resolver.js'; @@ -32,7 +32,7 @@ export class OpenAiClient { */ async chatCompletion( data: OpenAiChatCompletionParameters, - deploymentConfig: DeploymentConfiguration, + deploymentConfig: ModelDeployment, requestConfig?: CustomRequestConfig ): Promise { const deploymentId = await getDeploymentId(deploymentConfig, requestConfig); @@ -56,7 +56,7 @@ export class OpenAiClient { */ async embeddings( data: OpenAiEmbeddingParameters, - deploymentConfig: DeploymentConfiguration, + deploymentConfig: ModelDeployment, requestConfig?: CustomRequestConfig ): Promise { const deploymentId = await getDeploymentId(deploymentConfig); @@ -70,7 +70,7 @@ export class OpenAiClient { } async function getDeploymentId( - deploymentConfig: DeploymentConfiguration, + deploymentConfig: ModelDeployment, requestConfig?: CustomRequestConfig ) { if (isDeploymentIdConfiguration(deploymentConfig)) { @@ -87,9 +87,7 @@ async function getDeploymentId( ).id; } -function translateToFoundationModel( - modelConfig: ModelConfiguration -): FoundationModel { +function translateToFoundationModel(modelConfig: Model): FoundationModel { if (typeof modelConfig === 'string') { return { name: modelConfig }; } diff --git a/packages/gen-ai-hub/src/utils/deployment-resolver.ts b/packages/gen-ai-hub/src/utils/deployment-resolver.ts index fc31eb64..7b827aca 100644 --- a/packages/gen-ai-hub/src/utils/deployment-resolver.ts +++ b/packages/gen-ai-hub/src/utils/deployment-resolver.ts @@ -20,7 +20,7 @@ export type ModelConfiguration = /** * The deployment configuration when using a deployment ID. */ -export interface DeploymentIdConfiguration { +export interface DeploymentId { /** * The deployment ID. */ @@ -31,9 +31,9 @@ export interface DeploymentIdConfiguration { * The deployment configuration can be either a model configuration or a deployment ID configuration. * @typeParam ModelNameT - String literal type representing the name of the model. */ -export type DeploymentConfiguration = +export type ModelDeployment = | ModelConfiguration - | DeploymentIdConfiguration; + | DeploymentId; /** * Type guard to check if the given deployment configuration is a deployment ID configuration. @@ -41,23 +41,13 @@ export type DeploymentConfiguration = * @returns `true` if the configuration is a deployment ID configuration, `false` otherwise. */ export function isDeploymentIdConfiguration( - deploymentConfig: DeploymentConfiguration -): deploymentConfig is DeploymentIdConfiguration { + deploymentConfig: ModelDeployment +): deploymentConfig is DeploymentId { return ( typeof deploymentConfig === 'object' && 'deploymentId' in deploymentConfig ); } -/** - * A deployment resolver can be either a deployment ID or a function that returns a full deployment object. - */ -export type DeploymentResolver = DeploymentId | (() => Promise); - -/** - * A deployment ID is a string that uniquely identifies a deployment. - */ -export type DeploymentId = string; - /** * A foundation model is identified by its name and potentially a version. */