-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.ts
96 lines (88 loc) · 1.85 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
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
import {
Struct,
String,
type Schema,
Array,
Number,
} from "@effect/schema/Schema";
import { geni } from "./index";
import { Effect } from "effect";
import { LLM } from "./types";
const provideMockLLM = Effect.provideService(LLM, {
request: (prompt: string) =>
Effect.gen(function* () {
return `function main(people: ReadonlyArray<{ readonly name: string; readonly age: number }>): string {
return people.map(person => \`Welcome \${person.name}, age \${person.age}!\`).join(' ');
}`;
}),
});
const TwoArrays = Struct({
fst: Array(Number),
snd: Array(Number),
});
const dotproductpair = await geni(
"Dot product two array pairs",
[TwoArrays, TwoArrays],
TwoArrays,
[]
);
console.log(
dotproductpair(
{ fst: [1, 2, 3], snd: [4, 5, 6] },
{ fst: [7, 2, 3], snd: [10, 5, 6] }
)
);
const concat = await geni(
"Append number to the string",
[Number, String],
String,
[]
);
console.log(concat(13, "Hello"));
const Person = Struct({
name: String,
age: Number,
});
const welcome = await geni(
"Write a welcome message to people in the input array mentioning their names and ages",
[Array(Person)],
String,
[]
);
console.log(
welcome([
{ name: "anton", age: 30 },
{ name: "geni", age: 28 },
])
);
const theOldest = await geni(
"Return the oldest person",
[Array(Person)],
Person,
[
{
input: [
[
{ name: "anton", age: 30 },
{ name: "geni", age: 28 },
] as const,
],
output: { name: "anton", age: 30 },
},
{
input: [
[
{ name: "geni", age: 28 },
{ name: "dave", age: 39 },
{ name: "deniz", age: 35 },
] as const,
],
output: { name: "dave", age: 39 },
},
]
);
const o = theOldest([
{ name: "anton", age: 30 },
{ name: "geni", age: 28 },
]);
console.log(o);