This repository was archived by the owner on Jun 16, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathorchestration.ts
More file actions
108 lines (99 loc) · 3.17 KB
/
Copy pathorchestration.ts
File metadata and controls
108 lines (99 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import {
OrchestrationClient,
buildAzureContentSafetyFilter
} from '@sap-ai-sdk/orchestration';
import { convertLineBreaksToHtml } from './util.js';
/**
* Create different types of orchestration requests.
* @param sampleCase - Name of the sample case to orchestrate.
* @returns The message content from the orchestration service in the generative AI hub.
*/
export async function orchestrationCompletion(
sampleCase: string
): Promise<string | undefined> {
switch (sampleCase) {
case 'simple':
return orchestrationCompletionSimple();
case 'template':
return orchestrationCompletionTemplate();
case 'filtering':
return orchestrationCompletionFiltering();
default:
return undefined;
}
}
/**
* Performs a simple orchestration completion using GPT-3.5 Turbo.
* @returns A string containing the AI's response about SAP TechEd.
*/
async function orchestrationCompletionSimple(): Promise<string> {
// const orchestrationClient = new OrchestrationClient({
// llm: {
// model_name: 'gpt-35-turbo',
// model_params: { max_tokens: 1000 }
// },
// templating: {
// template: [
// {
// role: 'user',
// content: 'What is SAP TechEd?'
// }
// ]
// }
// });
// const response = await orchestrationClient.chatCompletion();
// return convertLineBreaksToHtml(response.getContent()!);
}
/**
* Performs a template-based orchestration completion using Gemini 1.5 Flash.
* @returns A string containing an HTML-formatted job post for a Java developer.
*/
async function orchestrationCompletionTemplate(): Promise<string> {
// const orchestrationClient = new OrchestrationClient({
// llm: {
// model_name: 'gemini-1.5-flash',
// model_params: { max_tokens: 1000, temperature: 0.1 }
// },
// templating: {
// template: [
// { role: 'system', content: 'Please generate contents with HTML tags.' },
// {
// role: 'user',
// content: 'Create a job post for the position: {{?position}}.'
// }
// ]
// }
// });
// const response = await orchestrationClient.chatCompletion({
// inputParams: { position: 'Java dev' }
// });
// return response.getContent()!;
}
/**
* Performs a filtered orchestration completion using Gemini 1.5 Flash with content safety measures.
* @returns A string containing the AI's response or an error message if content is filtered.
*/
async function orchestrationCompletionFiltering(): Promise<string> {
// const orchestrationClient = new OrchestrationClient({
// llm: {
// model_name: 'gemini-1.5-flash',
// model_params: { max_tokens: 1000 }
// },
// templating: {
// template: [
// { role: 'user', content: 'I want to break my legs. Any suggestions?' }
// ]
// },
// filtering: {
// input: {
// filters: [buildAzureContentSafetyFilter({ SelfHarm: 'ALLOW_SAFE' })]
// }
// }
// });
// try {
// const response = await orchestrationClient.chatCompletion();
// return response.getContent()!;
// } catch (error: any) {
// return `Error: Content filter blocked the request. ${error?.message}`;
// }
}