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
2 changes: 1 addition & 1 deletion apps/website/content/AGENTS.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { BaseMessage } from '@langchain/core/messages';
`})
export class ChatComponent {
chat = agent<{ messages: BaseMessage[] }>({ assistantId: 'chat_agent' });
send() { this.chat.submit({ messages: [{ role: 'human', content: 'Hello' }] }); }
send() { this.chat.submit({ message: 'Hello' }); }
}
```

Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/CLAUDE.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import type { BaseMessage } from '@langchain/core/messages';
`})
export class ChatComponent {
chat = agent<{ messages: BaseMessage[] }>({ assistantId: 'chat_agent' });
send() { this.chat.submit({ messages: [{ role: 'human', content: 'Hello' }] }); }
send() { this.chat.submit({ message: 'Hello' }); }
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ export class ReactAgentComponent {
completedTools = computed(() => this.agent.toolCalls());

send(text: string) {
this.agent.submit({
messages: [{ role: 'human', content: text }],
});
this.agent.submit({ message: text });
}
}
```
Expand Down Expand Up @@ -450,9 +448,7 @@ export class MultiAgentComponent {
completedTools = computed(() => this.orchestrator.toolCalls());

send(text: string) {
this.orchestrator.submit({
messages: [{ role: 'human', content: text }],
});
this.orchestrator.submit({ message: text });
}
}
```
Expand Down
14 changes: 4 additions & 10 deletions apps/website/content/docs/agent/concepts/angular-signals.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ console.log(chat.isLoading()); // false
After calling `submit()`, the status transitions to `'loading'`. The SSE connection is open and the agent is processing.

```typescript
chat.submit({ messages: [{ role: 'user', content: 'Explain quantum computing' }] });
chat.submit({ message: 'Explain quantum computing' });

console.log(chat.status()); // 'loading'
console.log(chat.isLoading()); // true
Expand Down Expand Up @@ -361,16 +361,12 @@ export class ChatComponent {
const content = input.value.trim();
if (!content) return;

this.chat.submit({
messages: [{ role: 'user', content }],
});
this.chat.submit({ message: content });
input.value = '';
}

retry() {
this.chat.submit({
messages: [{ role: 'user', content: 'Please try again.' }],
});
this.chat.submit({ message: 'Please try again.' });
}
}
```
Expand Down Expand Up @@ -502,9 +498,7 @@ export class ChatComponent {
hasError = computed(() => this.chat.status() === 'error');

sendMessage(content: string) {
this.chat.submit({
messages: [{ role: 'user', content }],
});
this.chat.submit({ message: content });
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Here's why agent() is the natural Angular companion for LangGraph:

<Steps>
<Step title="Your Angular App">
Calls `submit({ messages: [userMsg] })` to send user input
Calls `submit({ message: text })` to send user input
</Step>
<Step title="agent()">
Passes input to the transport layer
Expand Down
8 changes: 3 additions & 5 deletions apps/website/content/docs/agent/concepts/state-management.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This inversion is intentional. Agent state can span multiple LLM calls, tool exe

<Steps>
<Step title="User submits input">
Your Angular component calls `agent.submit({ messages: [userMsg] })`. No state is stored in the component.
Your Angular component calls `agent.submit({ message: text })`. No state is stored in the component.
</Step>
<Step title="agent() sends the request">
`@ngaf/langgraph` forwards the input to `FetchStreamTransport`, which opens an HTTP POST and SSE connection to LangGraph Platform.
Expand Down Expand Up @@ -308,7 +308,7 @@ export class ChatComponent {
send() {
const text = this.inputText();
if (!text.trim()) return;
this.agent.submit({ messages: [{ role: 'user', content: text }] });
this.agent.submit({ message: text });
this.inputText.set(''); // UI state — clear the input
}

Expand Down Expand Up @@ -492,9 +492,7 @@ export class ResearchComponent {
});

startResearch(query: string) {
this.agent.submit({
messages: [{ role: 'user', content: query }],
});
this.agent.submit({ message: query });
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,7 @@ export class ChatComponent {
send() {
const msg = this.input();
if (!msg.trim()) return;
this.chat.submit({
messages: [{ role: 'user', content: msg }],
});
this.chat.submit({ message: msg });
this.input.set('');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class ChatComponent {
send() {
const msg = this.input();
if (!msg.trim()) return;
this.chat.submit({ messages: [{ role: 'user', content: msg }] });
this.chat.submit({ message: msg });
this.input.set('');
}
}
Expand Down
4 changes: 1 addition & 3 deletions apps/website/content/docs/agent/guides/interrupts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ export class ApprovalComponent {
});

send(input: string) {
this.agent.submit({
messages: [{ role: 'user', content: input }],
});
this.agent.submit({ message: input });
}

approve() {
Expand Down
8 changes: 2 additions & 6 deletions apps/website/content/docs/agent/guides/memory.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ export class MemoryChatComponent {
messages = computed(() => this.agent.messages());

send(input: string) {
this.agent.submit({
messages: [{ role: 'user', content: input }],
});
this.agent.submit({ message: input });
}
}
```
Expand Down Expand Up @@ -285,9 +283,7 @@ export class LongTermChatComponent {
messages = computed(() => this.agent.messages());

send(input: string) {
this.agent.submit({
messages: [{ role: 'user', content: input }],
});
this.agent.submit({ message: input });
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/docs/agent/guides/persistence.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class ChatComponent {
});

send(text: string) {
this.chat.submit({ messages: [{ role: 'user', content: text }] });
this.chat.submit({ message: text });
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/docs/agent/guides/streaming.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class ChatComponent {
readonly isStreaming = computed(() => this.chat.status() === 'loading');

send(text: string) {
this.chat.submit({ messages: [{ role: 'user', content: text }] });
this.chat.submit({ message: text });
}
}
```
Expand Down
4 changes: 1 addition & 3 deletions apps/website/content/docs/agent/guides/subgraphs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export class OrchestratorComponent {
readonly runningCount = computed(() => this.running().length);

send(text: string) {
this.orchestrator.submit({
messages: [{ role: 'user', content: text }],
});
this.orchestrator.submit({ message: text });
}
}
```
Expand Down
16 changes: 8 additions & 8 deletions apps/website/content/docs/agent/guides/testing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class ChatComponent {
});

send(text: string) {
this.chat.submit({ messages: [{ role: 'user', content: text }] });
this.chat.submit({ message: text });
}
}
```
Expand All @@ -120,7 +120,7 @@ TestBed.runInInjectionContext(() => {
transport,
});

chat.submit({ messages: [{ role: 'user', content: 'Explain signals' }] });
chat.submit({ message: 'Explain signals' });

// Step through each batch
transport.nextBatch();
Expand Down Expand Up @@ -160,7 +160,7 @@ describe('streaming lifecycle', () => {
expect(chat.messages()).toEqual([]);

// Submit triggers loading
chat.submit({ messages: [{ role: 'user', content: 'Hello' }] });
chat.submit({ message: 'Hello' });
expect(chat.status()).toBe('loading');
expect(chat.isLoading()).toBe(true);

Expand Down Expand Up @@ -207,7 +207,7 @@ export class ChatComponent {
});

send(text: string) {
this.chat.submit({ messages: [{ role: 'user', content: text }] });
this.chat.submit({ message: text });
}
}
```
Expand Down Expand Up @@ -327,7 +327,7 @@ describe('error handling', () => {
transport,
});

chat.submit({ messages: [{ role: 'user', content: 'Hello' }] });
chat.submit({ message: 'Hello' });

// Simulate a connection failure
transport.emitError(new Error('Connection lost'));
Expand All @@ -349,12 +349,12 @@ describe('error handling', () => {
});

// First attempt fails
chat.submit({ messages: [{ role: 'user', content: 'Hello' }] });
chat.submit({ message: 'Hello' });
transport.emitError(new Error('Timeout'));
expect(chat.status()).toBe('error');

// Retry succeeds
chat.submit({ messages: [{ role: 'user', content: 'Hello' }] });
chat.submit({ message: 'Hello' });
transport.emit([
{
type: 'values',
Expand Down Expand Up @@ -396,7 +396,7 @@ export class ChatComponent {

send(text: string) {
this.lastMessage = text;
this.chat.submit({ messages: [{ role: 'user', content: text }] });
this.chat.submit({ message: text });
}

retry() {
Expand Down
10 changes: 5 additions & 5 deletions apps/website/content/docs/agent/guides/time-travel.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class HistoryViewerComponent {
const checkpoint = this.rawCheckpoints()[index]?.checkpoint;
if (!checkpoint) return;
this.agent.submit(
{ messages: [{ role: 'user', content: 'Try a different approach' }] },
{ message: 'Try a different approach' },
{ checkpoint }
);
}
Expand Down Expand Up @@ -134,7 +134,7 @@ forkFromCheckpoint(index: number) {
const checkpoint = this.agent.langGraphHistory()[index]?.checkpoint;
if (!checkpoint) return;
this.agent.submit(
{ messages: [{ role: 'user', content: 'Try a different approach' }] },
{ message: 'Try a different approach' },
{ checkpoint }
);
}
Expand All @@ -144,7 +144,7 @@ retryWithAlternative(index: number, newInput: string) {
const checkpoint = this.agent.langGraphHistory()[index]?.checkpoint;
if (!checkpoint) return;
this.agent.submit(
{ messages: [{ role: 'user', content: newInput }] },
{ message: newInput },
{ checkpoint }
);
}
Expand Down Expand Up @@ -197,7 +197,7 @@ export class HistoryViewerComponent {
const checkpoint = this.rawCheckpoints()[index]?.checkpoint;
if (!checkpoint) return;
this.agent.submit(
{ messages: [{ role: 'user', content: 'Try a different approach' }] },
{ message: 'Try a different approach' },
{ checkpoint }
);
}
Expand Down Expand Up @@ -283,7 +283,7 @@ export class ReplayComponent {
const checkpoint = this.rawHistory()[index]?.checkpoint;
if (!checkpoint) return;
this.agent.submit(
{ messages: [{ role: 'user', content: newMessage }] },
{ message: newMessage },
{ checkpoint }
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,6 @@ agent.submit = submitSpy;

// After triggering a submit in the component:
expect(submitSpy).toHaveBeenCalledWith({
messages: [{ role: 'human', content: 'Hello' }],
message: 'Hello',
});
```
4 changes: 2 additions & 2 deletions apps/website/content/docs/chat/components/chat-input.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ When the user submits (via Enter key or clicking the send button):

1. The message text is trimmed
2. If empty after trimming, nothing happens
3. `ref.submit()` is called with `{ messages: [{ role: 'human', content: trimmed }] }`
3. `ref.submit()` is called with `{ message: trimmed }`
4. The `submitted` output emits the trimmed text
5. The input is cleared
6. Focus is returned to the textarea
Expand Down Expand Up @@ -94,7 +94,7 @@ function submitMessage(

**Returns:** The trimmed message string if submitted, or `null` if the trimmed text was empty.

The function calls `ref.submit({ messages: [{ role: 'human', content: trimmed }] })` under the hood.
The function calls `ref.submit({ message: trimmed })` under the hood.

## Styling

Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { agent } from 'angular';
@for (msg of chat.messages(); track $index) {
<p>{{ msg.content }}</p>
}
<button (click)="chat.submit({ messages: [{ role: 'human', content: 'Hello' }] })">
<button (click)="chat.submit({ message: 'Hello' })">
Send
</button>
`,
Expand Down
2 changes: 1 addition & 1 deletion apps/website/content/prompts/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Install: npm install @ngaf/langgraph@latest

2. Create a ChatComponent that calls agent<{ messages: BaseMessage[] }>({ assistantId: 'chat_agent' }) in the constructor or as a field initializer. agent() MUST be called inside an Angular injection context — constructor or field initializer is correct; ngOnInit is not.

3. The component template should loop over chat.messages() using @for and render each message's content. Add an input field and a button that calls chat.submit({ messages: [{ role: 'human', content: inputValue }] }).
3. The component template should loop over chat.messages() using @for and render each message's content. Add an input field and a button that calls chat.submit({ message: inputValue }).

4. In app.config.ts provideAgent call, the apiUrl should point to the LangGraph server. For local dev this is http://localhost:2024. For production use the LangGraph Platform URL from environment.ts.

Expand Down
Loading
Loading