forked from humanlayer/humanlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01-no-humans.ts
More file actions
43 lines (38 loc) · 882 Bytes
/
01-no-humans.ts
File metadata and controls
43 lines (38 loc) · 882 Bytes
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
import { config } from "dotenv";
import { HumanLayer } from "@humanlayer/sdk";
import {
ClassifiedEmail,
classifyEmail,
logEmails,
twoEmailsShuffled,
} from "./common";
config(); // Load environment variables
const hl = new HumanLayer({
verbose: true,
runId: "email-classifier",
});
async function main() {
try {
console.log("\nClassifying emails...\n");
const results: ClassifiedEmail[] = [];
for (const email of twoEmailsShuffled) {
const classification = await classifyEmail(email);
console.log(
`Classification for "${email.subject}" was ${classification}`,
);
results.push({
...email,
classification,
});
}
logEmails(results);
} catch (error) {
console.error("Error:", error);
}
}
main()
.then(console.log)
.catch((e) => {
console.error(e);
process.exit(1);
});