Skip to content

Commit

Permalink
👌 IMPROVE: Examples lingo
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Jul 27, 2024
1 parent 9e1f8f5 commit a3a2716
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/nextjs/components/langbase/generate-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function GenerateTextExample() {

{!loading && completion && (
<p className="mt-4">
<strong>Completion:</strong> {completion}
<strong>Generated completion:</strong> {completion}
</p>
)}
</div>
Expand Down
6 changes: 2 additions & 4 deletions examples/nextjs/components/langbase/stream-text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import {Button} from '@/components/ui/button';
import {Input} from '@/components/ui/input';
import {fromReadableStream} from 'langbase';
import {useState} from 'react';
// import {fromReadableStream} from 'langbase';
import {fromReadableStream} from '../../../../packages/langbase/src/lib/browser/stream';
// import {fromReadableStream} from '../../../../packages/langbase/src/lib/browser/stream';

export default function StreamTextExample() {
const [prompt, setPrompt] = useState('');
Expand All @@ -27,11 +27,9 @@ export default function StreamTextExample() {

if (response.body) {
const stream = fromReadableStream(response.body);
console.log('✨ ~ stream:', stream);

// Method #1 to get all of the chunk.
for await (const chunk of stream) {
console.log('✨ ~ chunk:', chunk);
const content = chunk?.choices[0]?.delta?.content;
content && setCompletion(prev => prev + content);
}
Expand Down

0 comments on commit a3a2716

Please sign in to comment.