forked from cboard-org/cboard-ai-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.ts
62 lines (52 loc) · 1.45 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
// To run file
// npm run dev
require('dotenv').config()
import { type ContentSafetyConfiguration, initEngine } from "./src/index";
const apiKey = process.env.OPENAI_API_KEY;
const openAIConfiguration = {
apiKey,
basePath:
"https://cboard-openai.openai.azure.com/openai/deployments/ToEdit-01",
baseOptions: {
headers: { "api-key": apiKey },
params: {
"api-version": "2022-12-01",
},
},
};
const contentSafetyConfiguration = {
endpoint: process.env.CONTENT_SAFETY_ENDPOINT,
key: process.env.CONTENT_SAFETY_KEY,
} as ContentSafetyConfiguration;
const engineInstance = initEngine({
openAIConfiguration,
contentSafetyConfiguration,
});
const prompt = "familia";
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.dir(suggestions, { depth: null })
);