Creates a provider for a shared useStream instance at the component level.
Add the returned provider to a component's providers array so that all
child components can access the same stream via injectStream().
provideStream<T = Record<string, unknown>>(options: UseStreamOptions<InferStateType<T>>): __type| Name | Type | Description |
|---|---|---|
options* | UseStreamOptions<InferStateType<T>> |
import { Component } from "@angular/core";
import { provideStream, injectStream } from "@langchain/angular";
@Component({
providers: [provideStream({ assistantId: "agent" })],
template: `
<app-message-list />
<app-message-input />
`,
})
export class ChatContainer {}
// In child components:
@Component({
template: `
@for (msg of stream.messages(); track msg.id) {
<div>{{ msg.content }}</div>
}
`,
})
export class MessageListComponent {
stream = injectStream();
}