Skip to content

Commit 09b0d2d

Browse files
authored
fix: Include destinations in deployment id lookup (#548)
1 parent 4dd280a commit 09b0d2d

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

.changeset/purple-lizards-buy.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@sap-ai-sdk/foundation-models': minor
3+
'@sap-ai-sdk/ai-api': minor
4+
'@sap-ai-sdk/orchestration': minor
5+
---
6+
7+
[Fixed Issue] Consider destination when resolving deployment ids.

packages/ai-api/src/utils/deployment-resolver.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
} from '../client/AI_CORE_API/index.js';
55
import { deploymentCache } from './deployment-cache.js';
66
import { extractModel, type FoundationModel } from './model.js';
7+
import type { HttpDestinationOrFetchOptions } from '@sap-cloud-sdk/connectivity';
78

89
/**
910
* The model deployment configuration when using a model.
@@ -93,6 +94,10 @@ export interface DeploymentResolutionOptions {
9394
* The resource group of the deployment.
9495
*/
9596
resourceGroup?: string;
97+
/**
98+
* The destination to use for the request.
99+
*/
100+
destination?: HttpDestinationOrFetchOptions;
96101
}
97102

98103
/**
@@ -136,7 +141,12 @@ export async function resolveDeploymentId(
136141
async function getAllDeployments(
137142
opts: DeploymentResolutionOptions
138143
): Promise<AiDeployment[]> {
139-
const { scenarioId, executableId, resourceGroup = 'default' } = opts;
144+
const {
145+
destination,
146+
scenarioId,
147+
executableId,
148+
resourceGroup = 'default'
149+
} = opts;
140150
try {
141151
const { resources } = await DeploymentApi.deploymentQuery(
142152
{
@@ -145,7 +155,7 @@ async function getAllDeployments(
145155
...(executableId && { executableIds: [executableId] })
146156
},
147157
{ 'AI-Resource-Group': resourceGroup }
148-
).execute();
158+
).execute(destination);
149159

150160
deploymentCache.setAll(opts, resources);
151161

@@ -164,7 +174,8 @@ async function getAllDeployments(
164174
*/
165175
export async function getDeploymentId(
166176
modelDeployment: ModelDeployment,
167-
executableId: string
177+
executableId: string,
178+
destination?: HttpDestinationOrFetchOptions
168179
): Promise<string> {
169180
if (isDeploymentIdConfig(modelDeployment)) {
170181
return modelDeployment.deploymentId;
@@ -179,7 +190,8 @@ export async function getDeploymentId(
179190
scenarioId: 'foundation-models',
180191
executableId,
181192
model: translateToFoundationModel(model),
182-
resourceGroup: model.resourceGroup
193+
resourceGroup: model.resourceGroup,
194+
destination
183195
});
184196
}
185197

packages/foundation-models/src/azure-openai/azure-openai-chat-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ export class AzureOpenAiChatClient {
7070
): Promise<HttpResponse> {
7171
const deploymentId = await getDeploymentId(
7272
this.modelDeployment,
73-
'azure-openai'
73+
'azure-openai',
74+
this.destination
7475
);
7576
const resourceGroup = getResourceGroup(this.modelDeployment);
7677
return executeRequest(

packages/foundation-models/src/azure-openai/azure-openai-embedding-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export class AzureOpenAiEmbeddingClient {
3535
): Promise<AzureOpenAiEmbeddingResponse> {
3636
const deploymentId = await getDeploymentId(
3737
this.modelDeployment,
38-
'azure-openai'
38+
'azure-openai',
39+
this.destination
3940
);
4041
const resourceGroup = getResourceGroup(this.modelDeployment);
4142
const response = await executeRequest(

packages/orchestration/src/orchestration-client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export class OrchestrationClient {
105105

106106
const deploymentId = await resolveDeploymentId({
107107
scenarioId: 'orchestration',
108-
...(this.deploymentConfig ?? {})
108+
...(this.deploymentConfig ?? {}),
109+
destination: this.destination
109110
});
110111

111112
return executeRequest(

0 commit comments

Comments
 (0)