extrait 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/generate-shared.d.ts +8 -2
- package/dist/index.cjs +325 -71
- package/dist/index.d.ts +1 -1
- package/dist/index.js +325 -71
- package/dist/parse.d.ts +1 -1
- package/dist/providers/mcp-runtime.d.ts +1 -1
- package/dist/structured.d.ts +3 -3
- package/dist/types.d.ts +30 -4
- package/package.json +7 -13
package/README.md
CHANGED
|
@@ -71,6 +71,7 @@ These examples cover the most common usage patterns in the repository.
|
|
|
71
71
|
- [`examples/generate.ts`](examples/generate.ts) - High-level text generation
|
|
72
72
|
- [`examples/streaming.ts`](examples/streaming.ts) - Real-time partial output and snapshot updates
|
|
73
73
|
- [`examples/calculator-tool.ts`](examples/calculator-tool.ts) - Structured extraction with MCP tools
|
|
74
|
+
- [`examples/streaming-turns-with-tools.ts`](examples/streaming-turns-with-tools.ts) - Streaming MCP turns, transitions, and reasoning blocks
|
|
74
75
|
- [`examples/conversation.ts`](examples/conversation.ts) - Multi-turn prompts and multimodal content
|
|
75
76
|
- [`examples/image-analysis.ts`](examples/image-analysis.ts) - Vision input with structured output
|
|
76
77
|
- [`examples/embeddings.ts`](examples/embeddings.ts) - Embeddings and similarity workflows
|
|
@@ -345,7 +346,7 @@ const result = await llm.generate(
|
|
|
345
346
|
maxTokens: 800,
|
|
346
347
|
reasoningEffort: "medium",
|
|
347
348
|
mcpClients: [calculatorMCP],
|
|
348
|
-
maxToolRounds:
|
|
349
|
+
maxToolRounds: 10,
|
|
349
350
|
},
|
|
350
351
|
}
|
|
351
352
|
);
|
|
@@ -695,6 +696,7 @@ Available examples:
|
|
|
695
696
|
- `generate` - High-level text generation ([generate.ts](examples/generate.ts))
|
|
696
697
|
- `streaming` - Real LLM streaming + snapshot self-check ([streaming.ts](examples/streaming.ts))
|
|
697
698
|
- `streaming-with-tools` - Real text streaming with MCP tools + self-check ([streaming-with-tools.ts](examples/streaming-with-tools.ts))
|
|
699
|
+
- `streaming-turns-with-tools` - Streaming MCP turns, transitions, and reasoning blocks ([streaming-turns-with-tools.ts](examples/streaming-turns-with-tools.ts))
|
|
698
700
|
- `abort-signal` - Start a generation then cancel quickly with `AbortSignal` ([abort-signal.ts](examples/abort-signal.ts))
|
|
699
701
|
- `timeout` - Set per-request and per-tool timeouts via the `timeout` option ([timeout.ts](examples/timeout.ts))
|
|
700
702
|
- `simple` - Basic structured output with streaming ([simple.ts](examples/simple.ts))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LLMAdapter, LLMMessage, LLMRequest, LLMUsage, MCPToolClient, StructuredDebugOptions, StructuredPromptBuilder, StructuredPromptContext, StructuredPromptPayload, StructuredPromptValue, StructuredTimeoutOptions, ThinkBlock } from "./types";
|
|
1
|
+
import type { LLMAdapter, LLMMessage, LLMRequest, LLMToolCall, LLMUsage, MCPToolClient, ReasoningBlock, StreamTurnTransition, StructuredDebugOptions, StructuredPromptBuilder, StructuredPromptContext, StructuredPromptPayload, StructuredPromptValue, StructuredTimeoutOptions, ThinkBlock } from "./types";
|
|
2
2
|
export type PromptRequestOptions = Omit<LLMRequest, "prompt" | "systemPrompt" | "messages">;
|
|
3
3
|
export interface StreamDelta {
|
|
4
4
|
text: string;
|
|
@@ -12,7 +12,10 @@ export interface NormalizedStreamConfig<TSnapshot> {
|
|
|
12
12
|
done: boolean;
|
|
13
13
|
usage?: LLMUsage;
|
|
14
14
|
finishReason?: string;
|
|
15
|
+
turnIndex?: number;
|
|
16
|
+
toolCalls?: LLMToolCall[];
|
|
15
17
|
}) => void;
|
|
18
|
+
onTurnTransition?: (transition: StreamTurnTransition) => void;
|
|
16
19
|
to?: "stdout";
|
|
17
20
|
}
|
|
18
21
|
export interface NormalizedDebugConfig {
|
|
@@ -24,6 +27,7 @@ export interface NormalizedDebugConfig {
|
|
|
24
27
|
export interface NormalizedModelOutput {
|
|
25
28
|
text: string;
|
|
26
29
|
reasoning: string;
|
|
30
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
27
31
|
thinkBlocks: ThinkBlock[];
|
|
28
32
|
parseSource: string;
|
|
29
33
|
}
|
|
@@ -55,6 +59,7 @@ export interface ModelCallResult {
|
|
|
55
59
|
via: "complete" | "stream";
|
|
56
60
|
usage?: LLMUsage;
|
|
57
61
|
finishReason?: string;
|
|
62
|
+
reasoningBlocks?: ReasoningBlock[];
|
|
58
63
|
}
|
|
59
64
|
export declare function resolvePrompt(prompt: StructuredPromptBuilder, context: StructuredPromptContext): StructuredPromptPayload;
|
|
60
65
|
export declare function normalizePromptValue(value: StructuredPromptValue, _context: StructuredPromptContext): StructuredPromptPayload;
|
|
@@ -65,13 +70,14 @@ export declare function mergeSystemPrompts(primary?: string, secondary?: string)
|
|
|
65
70
|
export declare function normalizeStreamConfig<TSnapshot>(option: boolean | {
|
|
66
71
|
enabled?: boolean;
|
|
67
72
|
onData?: NormalizedStreamConfig<TSnapshot>["onData"];
|
|
73
|
+
onTurnTransition?: NormalizedStreamConfig<TSnapshot>["onTurnTransition"];
|
|
68
74
|
to?: "stdout";
|
|
69
75
|
} | undefined): NormalizedStreamConfig<TSnapshot>;
|
|
70
76
|
export declare function normalizeDebugConfig(option: StructuredDebugOptions | boolean | undefined): NormalizedDebugConfig;
|
|
71
77
|
export declare function withToolTimeout(client: MCPToolClient, toolTimeoutMs: number): MCPToolClient;
|
|
72
78
|
export declare function applyToolTimeout(clients: MCPToolClient[], toolTimeoutMs: number): MCPToolClient[];
|
|
73
79
|
export declare function callModel<TSnapshot, TTraceEvent>(adapter: LLMAdapter, options: ModelCallOptions<TSnapshot, TTraceEvent>): Promise<ModelCallResult>;
|
|
74
|
-
export declare function normalizeModelOutput(text: string, dedicatedReasoning?: string): NormalizedModelOutput;
|
|
80
|
+
export declare function normalizeModelOutput(text: string, dedicatedReasoning?: string, reasoningBlocks?: ReasoningBlock[]): NormalizedModelOutput;
|
|
75
81
|
export declare function composeParseSource(text: string, reasoning?: string): string;
|
|
76
82
|
export declare function aggregateUsage<T extends {
|
|
77
83
|
usage?: LLMUsage;
|