Skip to content

Commit 5ff4e60

Browse files
bloveclaude
andcommitted
fix(demo): align chat-demo with unified Message type and AgentSubmitInput
- msg.getType() === 'ai' → msg.role === 'assistant' (Message has 'role', not BaseMessage's getType()). - chat.submit({ messages: [{ role: 'human', content }] } as any) → chat.submit({ message: content }) (the runtime-neutral AgentSubmitInput shape). - Drop unused BaseMessage import + generic. This resolves the TS2339 error that blocked website lint/build CI. The demo's old code path predates the unification refactor and was reading raw LangChain types directly off the agent. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent dba611b commit 5ff4e60

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

apps/demo/src/app/chat-demo/chat-demo.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { Component, Input, OnInit, Injector, runInInjectionContext } from '@angular/core';
22
import { agent } from '@ngaf/langgraph';
3-
import type { BaseMessage } from '@langchain/core/messages';
43

54
@Component({
65
selector: 'stream-chat-demo',
76
standalone: false,
87
template: `
98
<div class="chat-demo">
109
<div class="messages" *ngIf="chat">
11-
<div *ngFor="let msg of chat.messages()" class="message" [class.ai]="msg.getType() === 'ai'">
10+
<div *ngFor="let msg of chat.messages()" class="message" [class.ai]="msg.role === 'assistant'">
1211
{{ msg.content }}
1312
</div>
1413
<div *ngIf="chat.isLoading()" class="loading">Thinking…</div>
@@ -34,14 +33,14 @@ export class ChatDemoComponent implements OnInit {
3433
@Input() apiUrl = 'http://localhost:2024';
3534
@Input() assistantId = 'chat_agent';
3635

37-
chat: ReturnType<typeof agent<{ messages: BaseMessage[] }>> | null = null;
36+
chat: ReturnType<typeof agent> | null = null;
3837

3938
constructor(private injector: Injector) {}
4039

4140
ngOnInit() {
4241
// @Input() values are available in ngOnInit, so use runInInjectionContext
4342
runInInjectionContext(this.injector, () => {
44-
this.chat = agent<{ messages: BaseMessage[] }>({
43+
this.chat = agent({
4544
apiUrl: this.apiUrl,
4645
assistantId: this.assistantId,
4746
});
@@ -55,7 +54,6 @@ export class ChatDemoComponent implements OnInit {
5554
const content = input.value.trim();
5655
if (!content || !this.chat) return;
5756
input.value = '';
58-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
59-
this.chat.submit({ messages: [{ role: 'human', content }] } as any);
57+
this.chat.submit({ message: content });
6058
}
6159
}

0 commit comments

Comments
 (0)