Skip to content

Commit d4aee77

Browse files
authored
search and replace (#5)
1 parent 9a5c9be commit d4aee77

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# @libretto/openai
1+
# @libretto/anthropic
22

3-
A drop-in replacement of the official `OpenAI` client for sending events to Libretto.
3+
A drop-in replacement of the official `Anthropic` client for sending events to Libretto.
44

55
## Installation
66

77
```bash
8-
npm install @libretto/openai
8+
npm install @libretto/anthropic
99
```
1010

1111
## Get Started
@@ -19,24 +19,24 @@ To send events to Libretto, you'll need to create a project. From the project yo
1919

2020
## Usage
2121

22-
You can use the `OpenAI` client provided by `@libretto/openai` anywhere that you're currently using the official client.
22+
You can use the `Anthropic` client provided by `@libretto/anthropic` anywhere that you're currently using the official client.
2323

24-
When instantiating the client, you can/should provide any of the standard `OpenAI` parameters in the constructor. Libretto-specific configuration can be provided via an additional `libretto` argument (see below).
24+
When instantiating the client, you can/should provide any of the standard `Anthropic` parameters in the constructor. Libretto-specific configuration can be provided via an additional `libretto` argument (see below).
2525

2626
To allow our tools to separate the "prompt" from the "prompt parameters", use the included `objectTemplate` helper and pass the parameters separately as follows:
2727

2828
```typescript
29-
import { OpenAI, objectTemplate } from "@libretto/openai";
29+
import { Anthropic, objectTemplate } from "@libretto/anthropic";
3030

3131
async function main() {
32-
const openai = new OpenAI({
33-
apiKey: "<OpenAI API Key>", // defaults to process.env.OPENAI_API_KEY
32+
const anthropic = new Anthropic({
33+
apiKey: "<Anthropic API Key>", // defaults to process.env.ANTHROPIC_API_KEY
3434
libretto: {
3535
apiKey: "<Libretto API Key>", // defaults to process.env.LIBRETTO_API_KEY
3636
},
3737
});
3838

39-
const completion = await openai.chat.completions.create({
39+
const completion = await anthropic.chat.completions.create({
4040
// Instead of a chat message array, you can pass objectTemplate instead.
4141
messages: objectTemplate([
4242
{ role: "user", content: "Give a hearty welcome to our new user {name}" },
@@ -60,7 +60,7 @@ main();
6060

6161
### Configuration
6262

63-
The following options may be set in the `libretto` object that has been added to the OpenAI client constructor:
63+
The following options may be set in the `libretto` object that has been added to the Anthropic client constructor:
6464

6565
- `promptTemplateName`: A default name to associate with prompts. If provided,
6666
this is the name that will be associated with any `create` call that's made
@@ -77,7 +77,7 @@ The following options may be set in the `libretto` object that has been added to
7777
### Additional Parameters
7878

7979
The following parameters can be specified in the `libretto` object that has been
80-
added to the base OpenAI `create` call interface:
80+
added to the base Anthropic `create` call interface:
8181

8282
- `templateParams`: The parameters to use for template strings. This is a
8383
dictionary of key-value pairs.
@@ -96,7 +96,7 @@ added to the base OpenAI `create` call interface:
9696
parent id are grouped as a "Run Group".
9797
- `feedbackKey`: The optional key used to send feedback on the prompt, for
9898
use with `sendFeedback()` later. This is normally auto-generated, and the
99-
value is returned in the OpenAI response.
99+
value is returned in the Anthropic response.
100100
- `context`: This optional key/value map lets you send additional information
101101
along with your request such as internal tracing IDs, user IDs etc.
102102

@@ -116,7 +116,7 @@ following:
116116
```
117117

118118
Finally, you have control over what gets inserted there in your request sent
119-
to OpenAI. In your `templateParams` you provide the aforementioned messages:
119+
to Anthropic. In your `templateParams` you provide the aforementioned messages:
120120

121121
```typescript
122122
templateParams: {
@@ -150,13 +150,13 @@ tests and improve your prompts.
150150
151151
```typescript
152152
import crypto from "crypto";
153-
import { OpenAI, sendFeedback } from "@libretto/openai";
153+
import { Anthropic, sendFeedback } from "@libretto/anthropic";
154154

155155
async function main() {
156-
const openai = new OpenAI();
156+
const anthropic = new Anthropic();
157157

158-
// Must be unique for each call to OpenAI
159-
const completion = await openai.chat.completions.create({
158+
// Must be unique for each call to Anthropic
159+
const completion = await anthropic.chat.completions.create({
160160
// ...
161161
});
162162

@@ -165,7 +165,7 @@ async function main() {
165165

166166
// If the user provided a better answer, send feedback to Libretto
167167
if (betterAnswer !== completion.choices[0].text) {
168-
// feedback key is automatically injected into OpenAI response object.
168+
// feedback key is automatically injected into Anthropic response object.
169169
const feedbackKey = completion.libretto?.feedbackKey;
170170
await sendFeedback({
171171
apiKey: "<Libretto API Key>", // defaults to process.env.LIBRETTO_API_KEY

examples/chathistory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Anthropic } from "../src/client";
33

44
async function main() {
55
const anthropic = new Anthropic({
6-
// apiKey: process.env.OPENAI_API_KEY
6+
// apiKey: process.env.ANTHROPIC_API_KEY
77
});
88

99
console.log("Testing Chat API with chat history...");

examples/simple.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Anthropic } from "../src/client";
33

44
async function main() {
55
const anthropic = new Anthropic({
6-
// apiKey: process.env.OPENAI_API_KEY
6+
// apiKey: process.env.ANTHROPIC_API_KEY
77
});
88

99
console.log("Testing Chat API...");

examples/simplestream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Anthropic } from "../src/client";
44

55
async function main() {
66
const anthropic = new Anthropic({
7-
// apiKey: process.env.OPENAI_API_KEY
7+
// apiKey: process.env.ANTHROPIC_API_KEY
88
});
99

1010
console.log("Testing Streaming Chat API...");

0 commit comments

Comments
 (0)