@tanstack/ai 0.21.3 → 0.22.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/dist/esm/activities/chat/adapter.d.ts +20 -0
- package/dist/esm/activities/chat/adapter.js.map +1 -1
- package/dist/esm/activities/chat/index.js +184 -8
- package/dist/esm/activities/chat/index.js.map +1 -1
- package/dist/esm/activities/generateSpeech/index.d.ts +3 -3
- package/dist/esm/activities/generateSpeech/index.js.map +1 -1
- package/dist/esm/types.d.ts +20 -4
- package/package.json +2 -2
- package/skills/ai-core/adapter-configuration/SKILL.md +31 -0
- package/skills/ai-core/structured-outputs/SKILL.md +21 -9
- package/src/activities/chat/adapter.ts +23 -0
- package/src/activities/chat/index.ts +300 -13
- package/src/activities/generateSpeech/index.ts +3 -3
- package/src/types.ts +20 -4
|
@@ -103,10 +103,10 @@ function createId(prefix: string): string {
|
|
|
103
103
|
* @example Generate speech from text
|
|
104
104
|
* ```ts
|
|
105
105
|
* import { generateSpeech } from '@tanstack/ai'
|
|
106
|
-
* import {
|
|
106
|
+
* import { openaiSpeech } from '@tanstack/ai-openai'
|
|
107
107
|
*
|
|
108
108
|
* const result = await generateSpeech({
|
|
109
|
-
* adapter:
|
|
109
|
+
* adapter: openaiSpeech('tts-1-hd'),
|
|
110
110
|
* text: 'Hello, welcome to TanStack AI!',
|
|
111
111
|
* voice: 'nova'
|
|
112
112
|
* })
|
|
@@ -117,7 +117,7 @@ function createId(prefix: string): string {
|
|
|
117
117
|
* @example With format and speed options
|
|
118
118
|
* ```ts
|
|
119
119
|
* const result = await generateSpeech({
|
|
120
|
-
* adapter:
|
|
120
|
+
* adapter: openaiSpeech('tts-1'),
|
|
121
121
|
* text: 'This is slower speech.',
|
|
122
122
|
* voice: 'alloy',
|
|
123
123
|
* format: 'wav',
|
package/src/types.ts
CHANGED
|
@@ -800,10 +800,26 @@ export interface TextOptions<
|
|
|
800
800
|
|
|
801
801
|
/**
|
|
802
802
|
* Schema for structured output.
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
*
|
|
806
|
-
*
|
|
803
|
+
*
|
|
804
|
+
* **Two distinct use sites:**
|
|
805
|
+
*
|
|
806
|
+
* 1. **User-facing (activity layer):** accepts any
|
|
807
|
+
* {@link SchemaInput} — Zod, ArkType, Valibot, or a raw JSON Schema.
|
|
808
|
+
* The activity layer converts to JSON Schema before handing off.
|
|
809
|
+
*
|
|
810
|
+
* 2. **Adapter-facing (`chatStream` call):** the engine populates this with
|
|
811
|
+
* a pre-converted JSON Schema **only** when the adapter declared
|
|
812
|
+
* `supportsCombinedToolsAndSchema(modelOptions) === true`. The adapter
|
|
813
|
+
* should then wire the schema into the upstream request (e.g.
|
|
814
|
+
* `response_format: { type: 'json_schema', ... }`, `text.format`,
|
|
815
|
+
* `output_format`) alongside any `tools`. The model's natural final
|
|
816
|
+
* turn carries the schema-constrained JSON text and the engine
|
|
817
|
+
* harvests it from the agent loop without a separate finalization
|
|
818
|
+
* round-trip.
|
|
819
|
+
*
|
|
820
|
+
* Adapters that did NOT declare the capability never see this field
|
|
821
|
+
* populated — the engine instead invokes `structuredOutput` /
|
|
822
|
+
* `structuredOutputStream` after the agent loop.
|
|
807
823
|
*/
|
|
808
824
|
outputSchema?: SchemaInput
|
|
809
825
|
/**
|