-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanthropic.ts
More file actions
37 lines (33 loc) · 753 Bytes
/
anthropic.ts
File metadata and controls
37 lines (33 loc) · 753 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
import dotenv from "dotenv";
import { prompt } from "../src";
// load api keys from .env
dotenv.config();
console.log("Promise-based Anthropic Claude 3 Haiku:")
const result = await prompt(
[
{
role: "user",
content: "Let's have fun with JSON, shall we?",
},
{
role: "assistant",
content: "Yeah. Let's have fun with JSON.",
},
{
role: "user",
content: "Respond with JSON: { works: true }",
},
],
"anthropic",
{
// model identifier of the provider
model: "claude-3-haiku-20240307",
temperature: 0.7,
max_tokens: 4096,
},
{
// union of options passed down, mapped internally
apiKey: process.env[`anthropic_api_key`],
},
);
console.log("result", result);