ProviderUserMessage
SUPPORT · interface · Type contract
User turn; the only message type that may carry images, and never tool calls.
Import
ts
import type { ProviderUserMessage } from '@jangts/agent-core/support';1
js
/** @typedef {import('@jangts/agent-core/support').ProviderUserMessage} ProviderUserMessage */1
Other public entry points:@jangts/agent-core/support, @jangts/agent-core/support/model.
Definition
ts
interface ProviderUserMessage1
Field structure
| Field | Type | Required | Description |
|---|---|---|---|
role | "user" | Required | Read-only. See the type definition and usage context. |
content | string | Required | Read-only. See the type definition and usage context. |
images | readonly ModelImage[] | undefined | Optional | Read-only. See the type definition and usage context. |
toolCallId | undefined | Optional | Read-only. See the type definition and usage context. |
toolCalls | undefined | Optional | Read-only. See the type definition and usage context. |
Examples
- Compatible Provider and custom Providers: Support owns the common Chat Completions HTTP/SSE lifecycle; an App can substitute its own ChatProvider.
- Support: the aggregate entry for recommended usage: Support aggregates recommended construction, policies, and same-source configuration generation; Core execution does not depend on this namespace.
Connect a common protocol with real server-side configuration
Beginner · Node.js
Running this example requires connection configuration for an available model service.
ts
import { ModelRunner, Support } from '@jangts/agent-core';
const provider = new Support.CompatibleModelProvider({ config: {
baseUrl: process.env.MODEL_BASE_URL!, apiKey: process.env.MODEL_API_KEY!, model: process.env.MODEL_NAME!,
} });
const runner = new ModelRunner({ provider });
console.log((await runner.invoke('你好')).value);1
2
3
4
5
6
2
3
4
5
6
js
import { ModelRunner, Support } from '@jangts/agent-core';
const provider = new Support.CompatibleModelProvider({ config: {
baseUrl: process.env.MODEL_BASE_URL, apiKey: process.env.MODEL_API_KEY, model: process.env.MODEL_NAME,
} });
const runner = new ModelRunner({ provider });
console.log((await runner.invoke('你好')).value);1
2
3
4
5
6
2
3
4
5
6
Declared fields and wire mapping for a direct tool thread
Configuration · Node.js
This only demonstrates message conversion, with no network request or tool execution. Raw tool_calls, tool_call_id, and host-attached data are not forwarded.
ts
import { Support } from '@jangts/agent-core';
const messages: Support.ProviderMessage[] = [
{ role: 'user', content: '查询资料' },
{ role: 'assistant', content: '', toolCalls: [
{ id: 'call-1', name: 'lookup', arguments: '{"query":"资料"}' },
] },
{ role: 'tool', content: '{"found":true}', toolCallId: 'call-1' },
];
console.log(Support.chatCompletionMessages(messages));1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
js
import { Support } from '@jangts/agent-core';
const messages = [
{ role: 'user', content: '查询资料' },
{ role: 'assistant', content: '', toolCalls: [
{ id: 'call-1', name: 'lookup', arguments: '{"query":"资料"}' },
] },
{ role: 'tool', content: '{"found":true}', toolCallId: 'call-1' },
];
console.log(Support.chatCompletionMessages(messages));1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9