Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions apps/demo/src/app/chat-demo/chat-demo.component.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Component, Input, OnInit, Injector, runInInjectionContext } from '@angular/core';
import { agent } from '@ngaf/langgraph';
import type { BaseMessage } from '@langchain/core/messages';

@Component({
selector: 'stream-chat-demo',
standalone: false,
template: `
<div class="chat-demo">
<div class="messages" *ngIf="chat">
<div *ngFor="let msg of chat.messages()" class="message" [class.ai]="msg.getType() === 'ai'">
<div *ngFor="let msg of chat.messages()" class="message" [class.ai]="msg.role === 'assistant'">
{{ msg.content }}
</div>
<div *ngIf="chat.isLoading()" class="loading">Thinking…</div>
Expand All @@ -34,14 +33,14 @@ export class ChatDemoComponent implements OnInit {
@Input() apiUrl = 'http://localhost:2024';
@Input() assistantId = 'chat_agent';

chat: ReturnType<typeof agent<{ messages: BaseMessage[] }>> | null = null;
chat: ReturnType<typeof agent> | null = null;

constructor(private injector: Injector) {}

ngOnInit() {
// @Input() values are available in ngOnInit, so use runInInjectionContext
runInInjectionContext(this.injector, () => {
this.chat = agent<{ messages: BaseMessage[] }>({
this.chat = agent({
apiUrl: this.apiUrl,
assistantId: this.assistantId,
});
Expand All @@ -55,7 +54,6 @@ export class ChatDemoComponent implements OnInit {
const content = input.value.trim();
if (!content || !this.chat) return;
input.value = '';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this.chat.submit({ messages: [{ role: 'human', content }] } as any);
this.chat.submit({ message: content });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ AG-UI is the open agent-to-UI protocol from the CopilotKit ecosystem. It standar
┌───────────┴───────────┐
▼ ▼
@ngaf/langgraph @ngaf/ag-ui
(toAgent: AgentRef→Agent) (toAgent: AbstractAgent→Agent)
(LangGraphAgent) (toAgent: AbstractAgent→Agent)
│ │
▼ ▼
LangGraph Platform Any AG-UI backend
Expand All @@ -28,7 +28,7 @@ AG-UI is the open agent-to-UI protocol from the CopilotKit ecosystem. It standar

## What you get

- **`toAgent(source: AbstractAgent): Agent`** — wraps any `AbstractAgent` subclass (custom transports, mocks).
- **`toAgent(source: AbstractAgent): Agent`** — wraps any `AbstractAgent` subclass (custom transports, mocks) into the runtime-neutral `Agent` contract.
- **`provideAgUiAgent({ url })`** — DI convenience that instantiates `HttpAgent` under the hood for the common SSE/HTTP case.
- **`FakeAgent`** — in-process `AbstractAgent` subclass that emits canned streaming events for offline demos and tests.

Expand Down
Loading
Loading