File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed
examples/nodejs/examples/pipes
packages/langbase/src/lib/helpers Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 11import 'dotenv/config' ;
2- import { Langbase , getToolsFromRun , getToolsFromRunStream } from 'langbase' ;
2+ import { Langbase , getToolsFromRunStream } from 'langbase' ;
33
44const langbase = new Langbase ( {
55 apiKey : process . env . LANGBASE_API_KEY ! ,
@@ -43,14 +43,15 @@ async function main() {
4343 ] ,
4444 } ) ;
4545
46- const tools = await getToolsFromRunStream ( response ) ;
46+ const [ streamForResponse , streamForToolCall ] = response . stream . tee ( ) ;
47+
48+ const tools = await getToolsFromRunStream ( streamForToolCall ) ;
4749
4850 if ( tools . length ) {
4951 // handle the tool calls
5052 console . log ( 'Tools:' , tools ) ;
5153 } else {
52- // handle the response
53- console . log ( 'Response:' , response ) ;
54+ // handle the response stream
5455 }
5556}
5657
Original file line number Diff line number Diff line change @@ -129,8 +129,8 @@ export async function getToolsFromStream(
129129 * @param stream - The readable stream to extract tools from
130130 * @returns A promise that resolves with the tools extracted from the stream
131131 */
132- export async function getToolsFromRunStream ( response : RunResponseStream ) {
133- return getToolsFromStream ( response . stream ) ;
132+ export async function getToolsFromRunStream ( stream : ReadableStream < any > ) {
133+ return getToolsFromStream ( stream ) ;
134134}
135135
136136/**
You can’t perform that action at this time.
0 commit comments