Skip to content

Commit 7c9b20c

Browse files
committed
👌 IMPROVE: examples
1 parent 5d3f07a commit 7c9b20c

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

examples/nextjs/app/api/langbase/pipe/generate-text/route.ts renamed to examples/nextjs/app/langbase/pipe/generate-text/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ export async function POST(req: Request) {
55
const {prompt} = await req.json();
66

77
// 1. Initiate the Pipe.
8-
const pipe = new Pipe({apiKey: process.env.LANGBASE_PIPE_LESS_WORDY!});
8+
const myPipe = new Pipe({apiKey: process.env.LANGBASE_PIPE_LESS_WORDY!});
99

1010
// 3. Generate the text by asking a question.
11-
const result = await pipe.generateText({
11+
const result = await myPipe.generateText({
1212
// Add user question prompt here to generate completion.
1313
messages: [{role: 'user', content: prompt}],
1414
});

examples/nextjs/app/api/langbase/pipe/stream-text/route.ts renamed to examples/nextjs/app/langbase/pipe/stream-text/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ export async function POST(req: NextRequest) {
77
const {prompt} = await req.json();
88

99
// 1. Initiate the Pipe.
10-
const pipe = new Pipe({
10+
const myPipe = new Pipe({
1111
apiKey: process.env.LANGBASE_PIPE_LESS_WORDY!,
1212
});
1313

1414
// 2. Generate a stream by asking a question
15-
const stream = await pipe.streamText({
15+
const {stream} = await myPipe.streamText({
1616
messages: [{role: 'user', content: prompt}],
1717
});
1818

examples/nextjs/components/langbase/generate-text.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default function GenerateTextExample() {
1515

1616
setLoading(true);
1717
try {
18-
const response = await fetch('/api/langbase/pipe/generate-text', {
18+
const response = await fetch('/langbase/pipe/generate-text', {
1919
method: 'POST',
2020
headers: {
2121
'Content-Type': 'application/json',

examples/nextjs/components/langbase/stream-text.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default function StreamTextExample() {
1919
setCompletion('');
2020

2121
try {
22-
const response = await fetch('/api/langbase/pipe/stream-text', {
22+
const response = await fetch('/langbase/pipe/stream-text', {
2323
method: 'POST',
2424
body: JSON.stringify({prompt}),
2525
headers: {'Content-Type': 'text/plain'},

examples/nextjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"@radix-ui/react-slot": "^1.1.0",
1313
"class-variance-authority": "^0.7.0",
1414
"clsx": "^2.1.1",
15-
"langbase": "*",
15+
"langbase": "^1.0.0",
1616
"lucide-react": "^0.416.0",
1717
"mxcn": "^2.0.0",
1818
"next": "14.2.5",

examples/nodejs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"license": "UNLICENSED",
1212
"dependencies": {
1313
"dotenv": "^16.4.5",
14-
"langbase": "*"
14+
"langbase": "^1.0.0"
1515
}
1616
}

0 commit comments

Comments
 (0)