streamTokenizedResponse: () => Effect.gen(function* () {
const remoteChain = new RemoteRunnable({
url: `https://mylangchain.com`
});
const remoteStream = yield* Effect.tryPromise({
try: () =>
remoteChain.stream(
{
question: "What's your favourite colour?"
},
{
configurable: {
session_id: '123abc'
}
}
),
catch: (error) =>
new Error(`Failed to establish a streaming connection: ${error}`)
});
return Stream.fromAsyncIterable(
remoteStream, // Pass the async iterable
(error) => Effect.fail(new Error('Streaming failed'))
) as Stream.Stream<string>;
})
streamTokenizedResponse: () => Effect.gen(function* () {
const remoteChain = new RemoteRunnable({
url: `https://mylangchain.com`
});
const remoteStream = yield* Effect.tryPromise({
try: () =>
remoteChain.stream(
{
question: "What's your favourite colour?"
},
{
configurable: {
session_id: '123abc'
}
}
),
catch: (error) =>
new Error(`Failed to establish a streaming connection: ${error}`)
});
return Stream.fromAsyncIterable(
remoteStream, // Pass the async iterable
(error) => Effect.fail(new Error('Streaming failed'))
) as Stream.Stream<string>;
})