-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathexample.ts
58 lines (51 loc) · 1.71 KB
/
example.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
import { Shapeshift } from ".";
// Example usage
async function main() {
const sourceObj = {
personalInfo: {
name: "John Doe",
age: 30,
},
occupation: "Software Engineer",
FullAddress: "123 Main St, Anytown",
address: {
street: "123 Main St",
city: "Anytown"
}
};
const targetObj = {
fullName: "",
yearsOld: 0,
profession: "",
location: {
streetAddress: "",
cityName: ""
}
};
try {
// Cohere example
const shapeshifter = new Shapeshift(
{ embeddingClient: 'cohere', apiKey: process.env.COHERE_API_KEY || '' },
{ embeddingModel: 'embed-english-v3.0', similarityThreshold: 0.5 }
);
const shiftedObj = await shapeshifter.shapeshift(sourceObj, targetObj);
console.log("Shifted object:", shiftedObj);
// OpenAI example
const openaiShapeshifter = new Shapeshift(
{ embeddingClient: 'openai', apiKey: process.env.OPENAI_API_KEY || '' },
{ embeddingModel: 'text-embedding-ada-002', similarityThreshold: 0.5 }
);
const openaiShiftedObj = await openaiShapeshifter.shapeshift(sourceObj, targetObj);
console.log("OpenAI Shifted object:", openaiShiftedObj);
// Voyage example
const voyageShapeshifter = new Shapeshift(
{ embeddingClient: 'voyage', apiKey: process.env.VOYAGE_API_KEY || '' },
{ embeddingModel: 'voyage-large-2', similarityThreshold: 0.5 }
);
const voyageShiftedObj = await voyageShapeshifter.shapeshift(sourceObj, targetObj);
console.log("Voyage Shifted object:", voyageShiftedObj);
} catch (error) {
console.error("Error:", error);
}
}
main();