Skip to content

Commit 0401a30

Browse files
authored
chore: Add sample-code/e2e-test for scoped prompt-template refs (#1292)
1 parent 80f4a1f commit 0401a30

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

sample-code/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export {
1010
orchestrationChatCompletion,
1111
orchestrationTemplating,
1212
orchestrationPromptRegistry,
13+
orchestrationCompletionPromptRegistryScoped,
1314
orchestrationInputFiltering,
1415
orchestrationOutputFiltering,
1516
orchestrationRequestConfig,

sample-code/src/orchestration.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,39 @@ export async function orchestrationPromptRegistry(): Promise<OrchestrationRespon
205205
});
206206
}
207207

208+
/**
209+
* Use a template stored in the prompt registry store at
210+
* the resource group scope.
211+
* @returns The orchestration service response.
212+
*/
213+
export async function orchestrationCompletionPromptRegistryScoped(): Promise<OrchestrationResponse> {
214+
const orchestrationClient = new OrchestrationClient(
215+
{
216+
promptTemplating: {
217+
prompt: {
218+
// refer to a prompt template stored at resource group scope
219+
template_ref: {
220+
name: 'e2e-test-scoped',
221+
scenario: 'e2e-test-scoped',
222+
version: '0.0.1',
223+
scope: 'resource_group'
224+
}
225+
},
226+
// define the language model to be used
227+
model: {
228+
name: 'gpt-4o'
229+
}
230+
}
231+
},
232+
// provide resource group where the template is stored
233+
{ resourceGroup: 'ai-sdk-js-e2e' }
234+
);
235+
236+
return orchestrationClient.chatCompletion({
237+
placeholderValues: { country: 'France' }
238+
});
239+
}
240+
208241
/**
209242
* Apply multiple content filters to the input.
210243
* @returns The orchestration service error response.

tests/e2e-tests/src/orchestration.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
orchestrationChatCompletion,
33
orchestrationTemplating,
44
orchestrationPromptRegistry,
5+
orchestrationCompletionPromptRegistryScoped,
56
orchestrationInputFiltering,
67
orchestrationOutputFiltering,
78
orchestrationRequestConfig,
@@ -52,6 +53,12 @@ describe('orchestration', () => {
5253
assertContent(response);
5354
});
5455

56+
it('should complete a chat with a scoped template reference', async () => {
57+
const response = await orchestrationCompletionPromptRegistryScoped();
58+
59+
assertContent(response);
60+
});
61+
5562
it('should trigger an input filter', async () => {
5663
await orchestrationInputFiltering();
5764
});

0 commit comments

Comments
 (0)