Creates a shared useStream instance and makes it available to all
descendant components via Svelte's setContext/getContext.
Call this in a parent component's <script> block. Children access
the shared stream via getStream.
Uses the same context key as setStreamContext/getStreamContext, so both retrieval functions work interchangeably.
provideStream<
T = Record<string, unknown>,
Bag extends BagTemplate = BagTemplate
>(
options: ResolveStreamOptions<T, InferBag<T, Bag>> | UseStreamCustomOptions<InferStateType<T>, InferBag<T, Bag>>
): WithClassMessages<ResolveStreamInterface<T, InferBag<T, Bag>>>| Name | Type | Description |
|---|---|---|
options* | ResolveStreamOptions<T, InferBag<T, Bag>> | UseStreamCustomOptions<InferStateType<T>, InferBag<T, Bag>> |
<!-- ChatContainer.svelte -->
<script lang="ts">
import { provideStream } from "@langchain/svelte";
provideStream({
assistantId: "agent",
apiUrl: "http://localhost:2024",
});
</script>
<ChatHeader />
<MessageList />
<MessageInput />