-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.ts
64 lines (56 loc) · 1.54 KB
/
run.ts
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
// To run file
// npm run dev
require("dotenv").config();
import { type ContentSafetyConfiguration, initEngine } from "./src/index";
const apiKey = process.env.OPENAI_API_KEY;
const basePath = process.env.OPENAI_BASE_PATH;
const openAIConfiguration = {
apiKey,
basePath,
baseOptions: {
headers: { "api-key": apiKey },
params: {
"api-version": "2024-08-01-preview",
},
},
};
const contentSafetyConfiguration = {
endpoint: process.env.CONTENT_SAFETY_ENDPOINT,
key: process.env.CONTENT_SAFETY_KEY,
} as ContentSafetyConfiguration;
const engineInstance = initEngine({
openAIConfiguration,
contentSafetyConfiguration,
});
const prompt = "jungle birds";
const maxSuggestions = 15;
const symbolSet = "arasaac";
//const symbolSet = "global-symbols";
const globalSymbolsSymbolSet = "global-symbols";
//const language = "es";
const language = "en";
//Check content safety
//console.log("isPromptSafe: "+ engineInstance.isContentSafe(prompt));
engineInstance.isContentSafe(prompt).then((result) => {
console.log("Is content safe?", result);
});
// Get suggestions with GlobalSymbols
engineInstance
.getSuggestions({
prompt,
maxSuggestions,
symbolSet,
language,
})
.then(
(suggestions) =>
// console.log(
// "\nSuggestions -----------------------------------------------\n"
// // suggestions,
// // "length: " + suggestions.length
// )
console.log(
"\nSuggestions -----------------------------------------------\n"
)
//console.dir(suggestions, { depth: 2 })
);