@tanstack/ai-muse 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +79 -2
- package/dist/esm/adapters/text.d.ts +51 -0
- package/dist/esm/adapters/text.js +53 -0
- package/dist/esm/adapters/text.js.map +1 -0
- package/dist/esm/byok.d.ts +1 -0
- package/dist/esm/byok.js +11 -0
- package/dist/esm/byok.js.map +1 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/message-types.d.ts +43 -0
- package/dist/esm/model-meta.d.ts +369 -0
- package/dist/esm/model-meta.js +214 -0
- package/dist/esm/model-meta.js.map +1 -0
- package/dist/esm/text/text-provider-options.d.ts +57 -0
- package/dist/esm/utils/client.d.ts +28 -0
- package/dist/esm/utils/client.js +38 -0
- package/dist/esm/utils/client.js.map +1 -0
- package/package.json +69 -3
- package/src/adapters/text.ts +113 -0
- package/src/byok.ts +7 -0
- package/src/index.ts +36 -0
- package/src/message-types.ts +45 -0
- package/src/model-meta.ts +329 -0
- package/src/text/text-provider-options.ts +66 -0
- package/src/utils/client.ts +49 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
//#region src/model-meta.ts
|
|
2
|
+
var EFFORT_MINIMAL_TO_MAX = {
|
|
3
|
+
levels: {
|
|
4
|
+
minimal: "minimal",
|
|
5
|
+
low: "low",
|
|
6
|
+
medium: "medium",
|
|
7
|
+
high: "high",
|
|
8
|
+
xhigh: "xhigh",
|
|
9
|
+
max: "max"
|
|
10
|
+
},
|
|
11
|
+
budget: false
|
|
12
|
+
};
|
|
13
|
+
var EFFORT_MINIMAL_TO_XHIGH = {
|
|
14
|
+
levels: {
|
|
15
|
+
minimal: "minimal",
|
|
16
|
+
low: "low",
|
|
17
|
+
medium: "medium",
|
|
18
|
+
high: "high",
|
|
19
|
+
xhigh: "xhigh"
|
|
20
|
+
},
|
|
21
|
+
budget: false
|
|
22
|
+
};
|
|
23
|
+
var FEATURES = [
|
|
24
|
+
"streaming",
|
|
25
|
+
"tools",
|
|
26
|
+
"json_object",
|
|
27
|
+
"json_schema",
|
|
28
|
+
"reasoning",
|
|
29
|
+
"vision"
|
|
30
|
+
];
|
|
31
|
+
var EMBER_1_0 = {
|
|
32
|
+
name: "muse-ember-1.0",
|
|
33
|
+
context_window: 1048576,
|
|
34
|
+
max_completion_tokens: 524288,
|
|
35
|
+
pricing: {
|
|
36
|
+
input: {
|
|
37
|
+
normal: .1,
|
|
38
|
+
cached: .004
|
|
39
|
+
},
|
|
40
|
+
output: { normal: .5 }
|
|
41
|
+
},
|
|
42
|
+
supports: {
|
|
43
|
+
input: ["text", "image"],
|
|
44
|
+
output: ["text"],
|
|
45
|
+
endpoints: ["chat"],
|
|
46
|
+
features: [...FEATURES],
|
|
47
|
+
tools: []
|
|
48
|
+
},
|
|
49
|
+
reasoning: EFFORT_MINIMAL_TO_MAX
|
|
50
|
+
};
|
|
51
|
+
var WONDER_1_0 = {
|
|
52
|
+
name: "muse-wonder-1.0",
|
|
53
|
+
context_window: 1048576,
|
|
54
|
+
max_completion_tokens: 131072,
|
|
55
|
+
pricing: {
|
|
56
|
+
input: {
|
|
57
|
+
normal: 4,
|
|
58
|
+
cached: .2
|
|
59
|
+
},
|
|
60
|
+
output: { normal: 20 }
|
|
61
|
+
},
|
|
62
|
+
supports: {
|
|
63
|
+
input: ["text", "image"],
|
|
64
|
+
output: ["text"],
|
|
65
|
+
endpoints: ["chat"],
|
|
66
|
+
features: [...FEATURES],
|
|
67
|
+
tools: []
|
|
68
|
+
},
|
|
69
|
+
reasoning: EFFORT_MINIMAL_TO_MAX
|
|
70
|
+
};
|
|
71
|
+
var SPARK_1_3 = {
|
|
72
|
+
name: "muse-spark-1.3",
|
|
73
|
+
context_window: 1048576,
|
|
74
|
+
max_completion_tokens: 131072,
|
|
75
|
+
pricing: {
|
|
76
|
+
input: {
|
|
77
|
+
normal: 1.25,
|
|
78
|
+
cached: .15
|
|
79
|
+
},
|
|
80
|
+
output: { normal: 4.25 }
|
|
81
|
+
},
|
|
82
|
+
supports: {
|
|
83
|
+
input: ["text", "image"],
|
|
84
|
+
output: ["text"],
|
|
85
|
+
endpoints: ["chat"],
|
|
86
|
+
features: [...FEATURES],
|
|
87
|
+
tools: []
|
|
88
|
+
},
|
|
89
|
+
reasoning: EFFORT_MINIMAL_TO_MAX
|
|
90
|
+
};
|
|
91
|
+
var SPARK_1_3_CONTRIBUTOR = {
|
|
92
|
+
name: "muse-spark-1.3-contributor",
|
|
93
|
+
context_window: 1048576,
|
|
94
|
+
max_completion_tokens: 131072,
|
|
95
|
+
pricing: {
|
|
96
|
+
input: {
|
|
97
|
+
normal: .1,
|
|
98
|
+
cached: .002
|
|
99
|
+
},
|
|
100
|
+
output: { normal: .2 }
|
|
101
|
+
},
|
|
102
|
+
supports: {
|
|
103
|
+
input: ["text", "image"],
|
|
104
|
+
output: ["text"],
|
|
105
|
+
endpoints: ["chat"],
|
|
106
|
+
features: [...FEATURES],
|
|
107
|
+
tools: []
|
|
108
|
+
},
|
|
109
|
+
reasoning: EFFORT_MINIMAL_TO_XHIGH
|
|
110
|
+
};
|
|
111
|
+
var SPARK_1_2 = {
|
|
112
|
+
name: "muse-spark-1.2",
|
|
113
|
+
context_window: 1048576,
|
|
114
|
+
max_completion_tokens: 131072,
|
|
115
|
+
pricing: {
|
|
116
|
+
input: {
|
|
117
|
+
normal: 1.25,
|
|
118
|
+
cached: .15
|
|
119
|
+
},
|
|
120
|
+
output: { normal: 4.25 }
|
|
121
|
+
},
|
|
122
|
+
supports: {
|
|
123
|
+
input: ["text", "image"],
|
|
124
|
+
output: ["text"],
|
|
125
|
+
endpoints: ["chat"],
|
|
126
|
+
features: [...FEATURES],
|
|
127
|
+
tools: []
|
|
128
|
+
},
|
|
129
|
+
reasoning: EFFORT_MINIMAL_TO_XHIGH
|
|
130
|
+
};
|
|
131
|
+
var SPARK_1_2_CONTRIBUTOR = {
|
|
132
|
+
name: "muse-spark-1.2-contributor",
|
|
133
|
+
context_window: 1048576,
|
|
134
|
+
max_completion_tokens: 131072,
|
|
135
|
+
pricing: {
|
|
136
|
+
input: {
|
|
137
|
+
normal: .1,
|
|
138
|
+
cached: .002
|
|
139
|
+
},
|
|
140
|
+
output: { normal: .2 }
|
|
141
|
+
},
|
|
142
|
+
supports: {
|
|
143
|
+
input: ["text", "image"],
|
|
144
|
+
output: ["text"],
|
|
145
|
+
endpoints: ["chat"],
|
|
146
|
+
features: [...FEATURES],
|
|
147
|
+
tools: []
|
|
148
|
+
},
|
|
149
|
+
reasoning: EFFORT_MINIMAL_TO_XHIGH
|
|
150
|
+
};
|
|
151
|
+
var SPARK_1_1 = {
|
|
152
|
+
name: "muse-spark-1.1",
|
|
153
|
+
context_window: 1048576,
|
|
154
|
+
max_completion_tokens: 32768,
|
|
155
|
+
pricing: {
|
|
156
|
+
input: {
|
|
157
|
+
normal: 1.25,
|
|
158
|
+
cached: .15
|
|
159
|
+
},
|
|
160
|
+
output: { normal: 4.25 }
|
|
161
|
+
},
|
|
162
|
+
supports: {
|
|
163
|
+
input: ["text", "image"],
|
|
164
|
+
output: ["text"],
|
|
165
|
+
endpoints: ["chat"],
|
|
166
|
+
features: [...FEATURES],
|
|
167
|
+
tools: []
|
|
168
|
+
},
|
|
169
|
+
reasoning: EFFORT_MINIMAL_TO_XHIGH
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* All supported Muse chat model identifiers.
|
|
173
|
+
*/
|
|
174
|
+
var MUSE_CHAT_MODELS = [
|
|
175
|
+
EMBER_1_0.name,
|
|
176
|
+
WONDER_1_0.name,
|
|
177
|
+
SPARK_1_3.name,
|
|
178
|
+
SPARK_1_3_CONTRIBUTOR.name,
|
|
179
|
+
SPARK_1_2.name,
|
|
180
|
+
SPARK_1_2_CONTRIBUTOR.name,
|
|
181
|
+
SPARK_1_1.name
|
|
182
|
+
];
|
|
183
|
+
/**
|
|
184
|
+
* Runtime map from chat model name to its supported input modalities, for the
|
|
185
|
+
* text adapter's `inputModalities`. `satisfies` keeps it equal to
|
|
186
|
+
* {@link MuseModelInputModalitiesByName}. An unknown name gives `undefined`.
|
|
187
|
+
*/
|
|
188
|
+
var MUSE_MODEL_INPUT_MODALITIES = {
|
|
189
|
+
[EMBER_1_0.name]: EMBER_1_0.supports.input,
|
|
190
|
+
[WONDER_1_0.name]: WONDER_1_0.supports.input,
|
|
191
|
+
[SPARK_1_3.name]: SPARK_1_3.supports.input,
|
|
192
|
+
[SPARK_1_3_CONTRIBUTOR.name]: SPARK_1_3_CONTRIBUTOR.supports.input,
|
|
193
|
+
[SPARK_1_2.name]: SPARK_1_2.supports.input,
|
|
194
|
+
[SPARK_1_2_CONTRIBUTOR.name]: SPARK_1_2_CONTRIBUTOR.supports.input,
|
|
195
|
+
[SPARK_1_1.name]: SPARK_1_1.supports.input
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Runtime map from chat model name to its reasoning data, for the text
|
|
199
|
+
* adapter. An unknown name gives `undefined`: the adapter sends no reasoning
|
|
200
|
+
* field.
|
|
201
|
+
*/
|
|
202
|
+
var MUSE_MODEL_REASONING = {
|
|
203
|
+
[EMBER_1_0.name]: EMBER_1_0.reasoning,
|
|
204
|
+
[WONDER_1_0.name]: WONDER_1_0.reasoning,
|
|
205
|
+
[SPARK_1_3.name]: SPARK_1_3.reasoning,
|
|
206
|
+
[SPARK_1_3_CONTRIBUTOR.name]: SPARK_1_3_CONTRIBUTOR.reasoning,
|
|
207
|
+
[SPARK_1_2.name]: SPARK_1_2.reasoning,
|
|
208
|
+
[SPARK_1_2_CONTRIBUTOR.name]: SPARK_1_2_CONTRIBUTOR.reasoning,
|
|
209
|
+
[SPARK_1_1.name]: SPARK_1_1.reasoning
|
|
210
|
+
};
|
|
211
|
+
//#endregion
|
|
212
|
+
export { MUSE_CHAT_MODELS, MUSE_MODEL_INPUT_MODALITIES, MUSE_MODEL_REASONING };
|
|
213
|
+
|
|
214
|
+
//# sourceMappingURL=model-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-meta.js","names":[],"sources":["../../src/model-meta.ts"],"sourcesContent":["import type { Modality, ModelReasoning } from '@tanstack/ai'\nimport type { ModelReasoningCapability } from '@tanstack/ai/adapter-internals'\nimport type { MuseTextProviderOptions } from './text/text-provider-options'\n\n// Model data below is from Meta's official Model API docs (dev.meta.ai):\n// \"Pricing and rate limits\", \"Choose a model\", and the per-model pages,\n// checked 2026-11-11. Prices are USD per 1M tokens, Standard mode unless the\n// model id says `-contributor`. Every reasoning model on the API has a\n// 1,048,576-token context window. Muse Glimmer is an open-weight,\n// self-hosted model — it is NOT served by the Model API and is deliberately\n// absent here.\n\n// Reasoning shapes: the levels a model has for `chat({ reasoning })`, and the\n// provider value to send for each. Each model points at one of them.\nconst EFFORT_MINIMAL_TO_MAX = {\n levels: {\n minimal: 'minimal',\n low: 'low',\n medium: 'medium',\n high: 'high',\n xhigh: 'xhigh',\n max: 'max',\n },\n budget: false,\n} as const\nconst EFFORT_MINIMAL_TO_XHIGH = {\n levels: {\n minimal: 'minimal',\n low: 'low',\n medium: 'medium',\n high: 'high',\n xhigh: 'xhigh',\n },\n budget: false,\n} as const\n\n/**\n * Internal metadata structure describing a Muse model's capabilities and\n * pricing.\n */\ninterface ModelMeta<TProviderOptions = unknown> {\n name: string\n context_window?: number\n max_completion_tokens?: number\n pricing: {\n input?: { normal: number; cached?: number }\n output?: { normal: number }\n }\n supports: {\n input: Array<'text' | 'image'>\n output: Array<'text'>\n endpoints: Array<'chat'>\n features: Array<\n | 'streaming'\n | 'tools'\n | 'json_object'\n | 'json_schema'\n | 'reasoning'\n | 'vision'\n >\n tools?: ReadonlyArray<never>\n }\n /** Type-level description of which provider options this model supports. */\n providerOptions?: TProviderOptions\n /** The model's data for `chat({ reasoning })`. None: it does not reason. */\n reasoning?: ModelReasoning\n}\n\nconst FEATURES = [\n 'streaming',\n 'tools',\n 'json_object',\n 'json_schema',\n 'reasoning',\n 'vision',\n] as const\n\n// Ember pricing is the ≤200K-input-token tier; requests over 200K input\n// tokens bill at 3x ($0.30 / $0.012 cached / $1.50) for the whole request.\nconst EMBER_1_0 = {\n name: 'muse-ember-1.0',\n context_window: 1_048_576,\n max_completion_tokens: 524_288,\n pricing: {\n input: { normal: 0.1, cached: 0.004 },\n output: { normal: 0.5 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: [...FEATURES],\n tools: [] as const,\n },\n reasoning: EFFORT_MINIMAL_TO_MAX,\n} as const satisfies ModelMeta<MuseTextProviderOptions>\n\nconst WONDER_1_0 = {\n name: 'muse-wonder-1.0',\n context_window: 1_048_576,\n max_completion_tokens: 131_072,\n pricing: {\n input: { normal: 4, cached: 0.2 },\n output: { normal: 20 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: [...FEATURES],\n tools: [] as const,\n },\n reasoning: EFFORT_MINIMAL_TO_MAX,\n} as const satisfies ModelMeta<MuseTextProviderOptions>\n\nconst SPARK_1_3 = {\n name: 'muse-spark-1.3',\n context_window: 1_048_576,\n max_completion_tokens: 131_072,\n pricing: {\n input: { normal: 1.25, cached: 0.15 },\n output: { normal: 4.25 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: [...FEATURES],\n tools: [] as const,\n },\n // Spark 1.3 is the only Spark that accepts `max` effort.\n reasoning: EFFORT_MINIMAL_TO_MAX,\n} as const satisfies ModelMeta<MuseTextProviderOptions>\n\nconst SPARK_1_3_CONTRIBUTOR = {\n name: 'muse-spark-1.3-contributor',\n context_window: 1_048_576,\n max_completion_tokens: 131_072,\n pricing: {\n input: { normal: 0.1, cached: 0.002 },\n output: { normal: 0.2 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: [...FEATURES],\n tools: [] as const,\n },\n // `max` is not available on the Contributor variant.\n reasoning: EFFORT_MINIMAL_TO_XHIGH,\n} as const satisfies ModelMeta<MuseTextProviderOptions>\n\nconst SPARK_1_2 = {\n name: 'muse-spark-1.2',\n context_window: 1_048_576,\n max_completion_tokens: 131_072,\n pricing: {\n input: { normal: 1.25, cached: 0.15 },\n output: { normal: 4.25 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: [...FEATURES],\n tools: [] as const,\n },\n reasoning: EFFORT_MINIMAL_TO_XHIGH,\n} as const satisfies ModelMeta<MuseTextProviderOptions>\n\nconst SPARK_1_2_CONTRIBUTOR = {\n name: 'muse-spark-1.2-contributor',\n context_window: 1_048_576,\n max_completion_tokens: 131_072,\n pricing: {\n input: { normal: 0.1, cached: 0.002 },\n output: { normal: 0.2 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: [...FEATURES],\n tools: [] as const,\n },\n reasoning: EFFORT_MINIMAL_TO_XHIGH,\n} as const satisfies ModelMeta<MuseTextProviderOptions>\n\nconst SPARK_1_1 = {\n name: 'muse-spark-1.1',\n context_window: 1_048_576,\n max_completion_tokens: 32_768,\n pricing: {\n input: { normal: 1.25, cached: 0.15 },\n output: { normal: 4.25 },\n },\n supports: {\n input: ['text', 'image'],\n output: ['text'],\n endpoints: ['chat'],\n features: [...FEATURES],\n tools: [] as const,\n },\n reasoning: EFFORT_MINIMAL_TO_XHIGH,\n} as const satisfies ModelMeta<MuseTextProviderOptions>\n\n/**\n * All supported Muse chat model identifiers.\n */\nexport const MUSE_CHAT_MODELS = [\n EMBER_1_0.name,\n WONDER_1_0.name,\n SPARK_1_3.name,\n SPARK_1_3_CONTRIBUTOR.name,\n SPARK_1_2.name,\n SPARK_1_2_CONTRIBUTOR.name,\n SPARK_1_1.name,\n] as const\n\n/**\n * Union type of all supported Muse chat model names.\n */\nexport type MuseChatModels = (typeof MUSE_CHAT_MODELS)[number]\n\n/**\n * Type-only map from Muse chat model name to its supported input modalities.\n */\nexport type MuseModelInputModalitiesByName = {\n [EMBER_1_0.name]: typeof EMBER_1_0.supports.input\n [WONDER_1_0.name]: typeof WONDER_1_0.supports.input\n [SPARK_1_3.name]: typeof SPARK_1_3.supports.input\n [SPARK_1_3_CONTRIBUTOR.name]: typeof SPARK_1_3_CONTRIBUTOR.supports.input\n [SPARK_1_2.name]: typeof SPARK_1_2.supports.input\n [SPARK_1_2_CONTRIBUTOR.name]: typeof SPARK_1_2_CONTRIBUTOR.supports.input\n [SPARK_1_1.name]: typeof SPARK_1_1.supports.input\n}\n\n/**\n * Runtime map from chat model name to its supported input modalities, for the\n * text adapter's `inputModalities`. `satisfies` keeps it equal to\n * {@link MuseModelInputModalitiesByName}. An unknown name gives `undefined`.\n */\nexport const MUSE_MODEL_INPUT_MODALITIES: Readonly<\n Record<string, ReadonlyArray<Modality>>\n> = {\n [EMBER_1_0.name]: EMBER_1_0.supports.input,\n [WONDER_1_0.name]: WONDER_1_0.supports.input,\n [SPARK_1_3.name]: SPARK_1_3.supports.input,\n [SPARK_1_3_CONTRIBUTOR.name]: SPARK_1_3_CONTRIBUTOR.supports.input,\n [SPARK_1_2.name]: SPARK_1_2.supports.input,\n [SPARK_1_2_CONTRIBUTOR.name]: SPARK_1_2_CONTRIBUTOR.supports.input,\n [SPARK_1_1.name]: SPARK_1_1.supports.input,\n} satisfies MuseModelInputModalitiesByName\n\n/**\n * Type-only map from Muse chat model name to its provider options type.\n */\nexport type MuseChatModelProviderOptionsByName = {\n [K in (typeof MUSE_CHAT_MODELS)[number]]: MuseTextProviderOptions\n}\n\n/**\n * Type-only map from Muse chat model name to its supported provider tools.\n * Muse exposes no provider-specific tool factories, so every model gets an\n * empty tuple. This makes passing another provider's ProviderTool to a Muse\n * adapter a compile-time type error.\n */\nexport type MuseChatModelToolCapabilitiesByName = {\n [EMBER_1_0.name]: typeof EMBER_1_0.supports.tools\n [WONDER_1_0.name]: typeof WONDER_1_0.supports.tools\n [SPARK_1_3.name]: typeof SPARK_1_3.supports.tools\n [SPARK_1_3_CONTRIBUTOR.name]: typeof SPARK_1_3_CONTRIBUTOR.supports.tools\n [SPARK_1_2.name]: typeof SPARK_1_2.supports.tools\n [SPARK_1_2_CONTRIBUTOR.name]: typeof SPARK_1_2_CONTRIBUTOR.supports.tools\n [SPARK_1_1.name]: typeof SPARK_1_1.supports.tools\n}\n\n/**\n * Resolves the provider options type for a specific Muse model.\n */\nexport type ResolveProviderOptions<TModel extends string> =\n TModel extends keyof MuseChatModelProviderOptionsByName\n ? MuseChatModelProviderOptionsByName[TModel]\n : MuseTextProviderOptions\n\n/**\n * Resolve input modalities for a specific model. If the model has explicit\n * modalities in the map, use those; otherwise use text only.\n */\nexport type ResolveInputModalities<TModel extends string> =\n TModel extends keyof MuseModelInputModalitiesByName\n ? MuseModelInputModalitiesByName[TModel]\n : readonly ['text']\n\n// Reasoning\n//\n// Each model's `reasoning` field holds its data for `chat({ reasoning })`: the\n// levels it has, with the provider value for each, and whether it takes a\n// thinking token budget.\n\nconst MUSE_REASONING = {\n [EMBER_1_0.name]: EMBER_1_0.reasoning,\n [WONDER_1_0.name]: WONDER_1_0.reasoning,\n [SPARK_1_3.name]: SPARK_1_3.reasoning,\n [SPARK_1_3_CONTRIBUTOR.name]: SPARK_1_3_CONTRIBUTOR.reasoning,\n [SPARK_1_2.name]: SPARK_1_2.reasoning,\n [SPARK_1_2_CONTRIBUTOR.name]: SPARK_1_2_CONTRIBUTOR.reasoning,\n [SPARK_1_1.name]: SPARK_1_1.reasoning,\n}\n\n/**\n * Each chat model's reasoning levels, and whether it takes a token budget, for\n * `chat({ reasoning })`. Derived from the `reasoning` field. A model that is\n * not here does not reason.\n */\nexport type MuseModelReasoningByName = {\n [K in keyof typeof MUSE_REASONING]: ModelReasoningCapability<\n (typeof MUSE_REASONING)[K]\n >\n}\n\n/**\n * Runtime map from chat model name to its reasoning data, for the text\n * adapter. An unknown name gives `undefined`: the adapter sends no reasoning\n * field.\n */\nexport const MUSE_MODEL_REASONING: Readonly<Record<string, ModelReasoning>> =\n MUSE_REASONING\n"],"mappings":"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"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Muse-specific provider options for text/chat models.
|
|
3
|
+
*
|
|
4
|
+
* Muse exposes an OpenAI-compatible Chat Completions endpoint, so these are
|
|
5
|
+
* the standard Chat Completions parameters. They are the values a caller can
|
|
6
|
+
* pass through `chat({ modelOptions })`.
|
|
7
|
+
*/
|
|
8
|
+
export interface MuseTextProviderOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Sampling temperature between 0 and 2. Higher values make the output more
|
|
11
|
+
* random; lower values make it more focused and deterministic.
|
|
12
|
+
*/
|
|
13
|
+
temperature?: number | null;
|
|
14
|
+
/**
|
|
15
|
+
* Nucleus sampling. The model considers the tokens with `top_p` probability
|
|
16
|
+
* mass. 0.1 means only the tokens in the top 10% are considered.
|
|
17
|
+
*/
|
|
18
|
+
top_p?: number | null;
|
|
19
|
+
/**
|
|
20
|
+
* The maximum number of tokens to generate in the chat completion. The total
|
|
21
|
+
* of input tokens and generated tokens is limited by the model's context
|
|
22
|
+
* window.
|
|
23
|
+
*/
|
|
24
|
+
max_completion_tokens?: number | null;
|
|
25
|
+
/**
|
|
26
|
+
* Number between -2.0 and 2.0. Positive values penalize new tokens by their
|
|
27
|
+
* frequency so far, so the model is less likely to repeat the same line.
|
|
28
|
+
*/
|
|
29
|
+
frequency_penalty?: number | null;
|
|
30
|
+
/**
|
|
31
|
+
* Number between -2.0 and 2.0. Positive values penalize new tokens that have
|
|
32
|
+
* already appeared, so the model is more likely to talk about new topics.
|
|
33
|
+
*/
|
|
34
|
+
presence_penalty?: number | null;
|
|
35
|
+
/**
|
|
36
|
+
* If set, the system makes a best effort to sample deterministically, so
|
|
37
|
+
* repeated requests with the same `seed` and parameters return the same
|
|
38
|
+
* result.
|
|
39
|
+
*/
|
|
40
|
+
seed?: number | null;
|
|
41
|
+
/**
|
|
42
|
+
* Up to 4 sequences where the API stops generating further tokens. The
|
|
43
|
+
* returned text does not contain the stop sequence.
|
|
44
|
+
*/
|
|
45
|
+
stop?: string | null | Array<string>;
|
|
46
|
+
/** Whether to enable parallel function calling during tool use. */
|
|
47
|
+
parallel_tool_calls?: boolean | null;
|
|
48
|
+
/**
|
|
49
|
+
* A unique identifier for your end-user, which can help monitor and detect
|
|
50
|
+
* abuse.
|
|
51
|
+
*/
|
|
52
|
+
user?: string | null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* External provider options (what users pass in).
|
|
56
|
+
*/
|
|
57
|
+
export type ExternalTextProviderOptions = MuseTextProviderOptions;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createOpenAIClient } from '@tanstack/openai-base';
|
|
2
|
+
/**
|
|
3
|
+
* The options `createOpenAIClient` accepts. Derived from the base factory so
|
|
4
|
+
* the config type matches the exact `openai` copy the base resolves, rather
|
|
5
|
+
* than a second copy pulled in by a direct `openai` dependency.
|
|
6
|
+
*/
|
|
7
|
+
type OpenAIClientOptions = Parameters<typeof createOpenAIClient>[0];
|
|
8
|
+
export interface MuseClientConfig extends Omit<OpenAIClientOptions, 'apiKey'> {
|
|
9
|
+
apiKey: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Gets the Muse API key from environment variables.
|
|
13
|
+
*
|
|
14
|
+
* `MUSE_API_KEY` is the provider-scoped name, matching the repo's other
|
|
15
|
+
* adapters (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, …). Meta's own docs call
|
|
16
|
+
* the same key `MODEL_API_KEY`, so that name is accepted as a fallback.
|
|
17
|
+
*
|
|
18
|
+
* @throws Error if neither variable is found
|
|
19
|
+
*/
|
|
20
|
+
export declare function getMuseApiKeyFromEnv(): string;
|
|
21
|
+
/**
|
|
22
|
+
* Returns a Muse client config with the Meta Model API base URL applied
|
|
23
|
+
* when not already set. Meta serves Muse through an OpenAI-compatible
|
|
24
|
+
* endpoint at api.meta.ai, so the adapter drives it with the OpenAI SDK
|
|
25
|
+
* pointed at this base URL.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withMuseDefaults(config: MuseClientConfig): MuseClientConfig;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { getApiKeyFromEnv } from "@tanstack/ai-utils";
|
|
2
|
+
//#region src/utils/client.ts
|
|
3
|
+
/**
|
|
4
|
+
* Gets the Muse API key from environment variables.
|
|
5
|
+
*
|
|
6
|
+
* `MUSE_API_KEY` is the provider-scoped name, matching the repo's other
|
|
7
|
+
* adapters (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, …). Meta's own docs call
|
|
8
|
+
* the same key `MODEL_API_KEY`, so that name is accepted as a fallback.
|
|
9
|
+
*
|
|
10
|
+
* @throws Error if neither variable is found
|
|
11
|
+
*/
|
|
12
|
+
function getMuseApiKeyFromEnv() {
|
|
13
|
+
try {
|
|
14
|
+
return getApiKeyFromEnv("MUSE_API_KEY");
|
|
15
|
+
} catch {
|
|
16
|
+
try {
|
|
17
|
+
return getApiKeyFromEnv("MODEL_API_KEY");
|
|
18
|
+
} catch {
|
|
19
|
+
throw new Error("MUSE_API_KEY is required. Please set it in your environment variables or use the factory function with an explicit API key.");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns a Muse client config with the Meta Model API base URL applied
|
|
25
|
+
* when not already set. Meta serves Muse through an OpenAI-compatible
|
|
26
|
+
* endpoint at api.meta.ai, so the adapter drives it with the OpenAI SDK
|
|
27
|
+
* pointed at this base URL.
|
|
28
|
+
*/
|
|
29
|
+
function withMuseDefaults(config) {
|
|
30
|
+
return {
|
|
31
|
+
...config,
|
|
32
|
+
baseURL: config.baseURL || "https://api.meta.ai/v1"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { getMuseApiKeyFromEnv, withMuseDefaults };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../../../src/utils/client.ts"],"sourcesContent":["import { getApiKeyFromEnv } from '@tanstack/ai-utils'\nimport type { createOpenAIClient } from '@tanstack/openai-base'\n\n/**\n * The options `createOpenAIClient` accepts. Derived from the base factory so\n * the config type matches the exact `openai` copy the base resolves, rather\n * than a second copy pulled in by a direct `openai` dependency.\n */\ntype OpenAIClientOptions = Parameters<typeof createOpenAIClient>[0]\n\nexport interface MuseClientConfig extends Omit<OpenAIClientOptions, 'apiKey'> {\n apiKey: string\n}\n\n/**\n * Gets the Muse API key from environment variables.\n *\n * `MUSE_API_KEY` is the provider-scoped name, matching the repo's other\n * adapters (`ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, …). Meta's own docs call\n * the same key `MODEL_API_KEY`, so that name is accepted as a fallback.\n *\n * @throws Error if neither variable is found\n */\nexport function getMuseApiKeyFromEnv(): string {\n try {\n return getApiKeyFromEnv('MUSE_API_KEY')\n } catch {\n try {\n return getApiKeyFromEnv('MODEL_API_KEY')\n } catch {\n throw new Error(\n 'MUSE_API_KEY is required. Please set it in your environment variables or use the factory function with an explicit API key.',\n )\n }\n }\n}\n\n/**\n * Returns a Muse client config with the Meta Model API base URL applied\n * when not already set. Meta serves Muse through an OpenAI-compatible\n * endpoint at api.meta.ai, so the adapter drives it with the OpenAI SDK\n * pointed at this base URL.\n */\nexport function withMuseDefaults(config: MuseClientConfig): MuseClientConfig {\n return {\n ...config,\n baseURL: config.baseURL || 'https://api.meta.ai/v1',\n }\n}\n"],"mappings":";;;;;;;;;;;AAuBA,SAAgB,uBAA+B;CAC7C,IAAI;EACF,OAAO,iBAAiB,cAAc;CACxC,QAAQ;EACN,IAAI;GACF,OAAO,iBAAiB,eAAe;EACzC,QAAQ;GACN,MAAM,IAAI,MACR,6HACF;EACF;CACF;AACF;;;;;;;AAQA,SAAgB,iBAAiB,QAA4C;CAC3E,OAAO;EACL,GAAG;EACH,SAAS,OAAO,WAAW;CAC7B;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,72 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/ai-muse",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Muse adapter for TanStack AI chat, tool calling, and structured outputs.",
|
|
5
|
+
"author": "Tanner Linsley",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://tanstack.com/ai",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/TanStack/ai.git",
|
|
11
|
+
"directory": "packages/ai-muse"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/TanStack/ai/issues"
|
|
15
|
+
},
|
|
16
|
+
"funding": {
|
|
17
|
+
"type": "github",
|
|
18
|
+
"url": "https://github.com/sponsors/tannerlinsley"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"module": "./dist/esm/index.js",
|
|
22
|
+
"types": "./dist/esm/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/esm/index.d.ts",
|
|
26
|
+
"import": "./dist/esm/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./byok": {
|
|
29
|
+
"types": "./dist/esm/byok.d.ts",
|
|
30
|
+
"import": "./dist/esm/byok.js"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"src"
|
|
37
|
+
],
|
|
38
|
+
"keywords": [
|
|
39
|
+
"ai",
|
|
40
|
+
"ai-sdk",
|
|
41
|
+
"typescript",
|
|
42
|
+
"tanstack",
|
|
43
|
+
"muse",
|
|
44
|
+
"adapter",
|
|
45
|
+
"llm",
|
|
46
|
+
"chat",
|
|
47
|
+
"tool-calling",
|
|
48
|
+
"structured-outputs"
|
|
49
|
+
],
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
52
|
+
"vite": "^8.2.1"
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@tanstack/ai": "^1.4.0"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@tanstack/ai-utils": "^1.1.0",
|
|
59
|
+
"@tanstack/openai-base": "^1.0.4"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "vite build",
|
|
63
|
+
"clean": "premove ./build ./dist",
|
|
64
|
+
"lint:fix": "oxlint src --type-aware --fix",
|
|
65
|
+
"test:build": "publint --strict",
|
|
66
|
+
"test:oxlint": "oxlint src --type-aware",
|
|
67
|
+
"test:coverage": "vitest run --coverage --coverage.include='src/**' --coverage.reporter=text-summary --coverage.reporter=json-summary",
|
|
68
|
+
"test:lib": "vitest run",
|
|
69
|
+
"test:lib:dev": "pnpm test:lib --watch",
|
|
70
|
+
"test:types": "tsc"
|
|
71
|
+
}
|
|
6
72
|
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OpenAIBaseChatCompletionsTextAdapter,
|
|
3
|
+
createOpenAIClient,
|
|
4
|
+
} from '@tanstack/openai-base'
|
|
5
|
+
import {
|
|
6
|
+
MUSE_MODEL_INPUT_MODALITIES,
|
|
7
|
+
MUSE_MODEL_REASONING,
|
|
8
|
+
} from '../model-meta'
|
|
9
|
+
import { getMuseApiKeyFromEnv, withMuseDefaults } from '../utils/client'
|
|
10
|
+
import type { Modality } from '@tanstack/ai'
|
|
11
|
+
import type {
|
|
12
|
+
MUSE_CHAT_MODELS,
|
|
13
|
+
MuseChatModelToolCapabilitiesByName,
|
|
14
|
+
MuseModelReasoningByName,
|
|
15
|
+
ResolveInputModalities,
|
|
16
|
+
ResolveProviderOptions,
|
|
17
|
+
} from '../model-meta'
|
|
18
|
+
import type { MuseMessageMetadataByModality } from '../message-types'
|
|
19
|
+
import type { MuseClientConfig } from '../utils/client'
|
|
20
|
+
import type { OpenAIBaseTextAdapterOptions } from '@tanstack/openai-base'
|
|
21
|
+
|
|
22
|
+
/** The reasoning levels of a model, for `chat({ reasoning })`. `never`: none. */
|
|
23
|
+
type ResolveReasoning<TModel extends string> =
|
|
24
|
+
TModel extends keyof MuseModelReasoningByName
|
|
25
|
+
? MuseModelReasoningByName[TModel]
|
|
26
|
+
: never
|
|
27
|
+
|
|
28
|
+
type ResolveToolCapabilities<TModel extends string> =
|
|
29
|
+
TModel extends keyof MuseChatModelToolCapabilitiesByName
|
|
30
|
+
? NonNullable<MuseChatModelToolCapabilitiesByName[TModel]>
|
|
31
|
+
: readonly []
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for the Muse text adapter.
|
|
35
|
+
*/
|
|
36
|
+
export interface MuseTextConfig
|
|
37
|
+
extends MuseClientConfig, OpenAIBaseTextAdapterOptions {}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Re-export of the public provider options type.
|
|
41
|
+
*/
|
|
42
|
+
export type { ExternalTextProviderOptions as MuseTextProviderOptions } from '../text/text-provider-options'
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Muse Text (Chat) Adapter
|
|
46
|
+
*
|
|
47
|
+
* Tree-shakeable adapter for Muse chat/text completion. Muse exposes an
|
|
48
|
+
* OpenAI-compatible Chat Completions endpoint, so we drive it with an
|
|
49
|
+
* OpenAI-compatible client via a `baseURL` override. There are no Muse-only
|
|
50
|
+
* wire quirks, so the OpenAI Chat Completions base handles streaming, tools,
|
|
51
|
+
* reasoning, and structured output unchanged.
|
|
52
|
+
*/
|
|
53
|
+
export class MuseTextAdapter<
|
|
54
|
+
TModel extends (typeof MUSE_CHAT_MODELS)[number],
|
|
55
|
+
TProviderOptions extends Record<string, any> = ResolveProviderOptions<TModel>,
|
|
56
|
+
TInputModalities extends ReadonlyArray<Modality> =
|
|
57
|
+
ResolveInputModalities<TModel>,
|
|
58
|
+
TToolCapabilities extends ReadonlyArray<string> =
|
|
59
|
+
ResolveToolCapabilities<TModel>,
|
|
60
|
+
> extends OpenAIBaseChatCompletionsTextAdapter<
|
|
61
|
+
TModel,
|
|
62
|
+
TProviderOptions,
|
|
63
|
+
TInputModalities,
|
|
64
|
+
MuseMessageMetadataByModality,
|
|
65
|
+
TToolCapabilities,
|
|
66
|
+
ResolveReasoning<TModel>
|
|
67
|
+
> {
|
|
68
|
+
override readonly kind = 'text' as const
|
|
69
|
+
override readonly name = 'muse' as const
|
|
70
|
+
override readonly inputModalities = MUSE_MODEL_INPUT_MODALITIES[this.model]
|
|
71
|
+
|
|
72
|
+
constructor(config: MuseTextConfig, model: TModel) {
|
|
73
|
+
super(model, 'muse', createOpenAIClient(withMuseDefaults(config)), config)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
protected override modelReasoning(model: string) {
|
|
77
|
+
return MUSE_MODEL_REASONING[model]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Creates a Muse text adapter with an explicit API key.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* const adapter = createMuseText('muse-ember-1.0', 'muse_...');
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export function createMuseText<
|
|
90
|
+
TModel extends (typeof MUSE_CHAT_MODELS)[number],
|
|
91
|
+
>(
|
|
92
|
+
model: TModel,
|
|
93
|
+
apiKey: string,
|
|
94
|
+
config?: Omit<MuseTextConfig, 'apiKey'>,
|
|
95
|
+
): MuseTextAdapter<TModel> {
|
|
96
|
+
return new MuseTextAdapter({ apiKey, ...config }, model)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Creates a Muse text adapter with the API key from `MUSE_API_KEY`.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const adapter = museText('muse-ember-1.0');
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export function museText<TModel extends (typeof MUSE_CHAT_MODELS)[number]>(
|
|
108
|
+
model: TModel,
|
|
109
|
+
config?: Omit<MuseTextConfig, 'apiKey'>,
|
|
110
|
+
): MuseTextAdapter<TModel> {
|
|
111
|
+
const apiKey = getMuseApiKeyFromEnv()
|
|
112
|
+
return createMuseText(model, apiKey, config)
|
|
113
|
+
}
|
package/src/byok.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @tanstack/ai-muse
|
|
3
|
+
*
|
|
4
|
+
* Muse provider adapter for TanStack AI.
|
|
5
|
+
* Provides a tree-shakeable adapter for Muse's OpenAI-compatible Chat
|
|
6
|
+
* Completions endpoint, including the flagship `muse-ember-1.0` (Ember) model.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Text (Chat) adapter
|
|
10
|
+
export {
|
|
11
|
+
MuseTextAdapter,
|
|
12
|
+
createMuseText,
|
|
13
|
+
museText,
|
|
14
|
+
type MuseTextConfig,
|
|
15
|
+
type MuseTextProviderOptions,
|
|
16
|
+
} from './adapters/text'
|
|
17
|
+
|
|
18
|
+
// Types
|
|
19
|
+
export type {
|
|
20
|
+
MuseChatModels,
|
|
21
|
+
MuseChatModelProviderOptionsByName,
|
|
22
|
+
MuseChatModelToolCapabilitiesByName,
|
|
23
|
+
MuseModelInputModalitiesByName,
|
|
24
|
+
MuseModelReasoningByName,
|
|
25
|
+
ResolveProviderOptions,
|
|
26
|
+
ResolveInputModalities,
|
|
27
|
+
} from './model-meta'
|
|
28
|
+
export { MUSE_CHAT_MODELS } from './model-meta'
|
|
29
|
+
export type {
|
|
30
|
+
MuseTextMetadata,
|
|
31
|
+
MuseImageMetadata,
|
|
32
|
+
MuseAudioMetadata,
|
|
33
|
+
MuseVideoMetadata,
|
|
34
|
+
MuseDocumentMetadata,
|
|
35
|
+
MuseMessageMetadataByModality,
|
|
36
|
+
} from './message-types'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Muse message metadata types.
|
|
3
|
+
*
|
|
4
|
+
* Muse uses the OpenAI Chat Completions wire format, so these hold the
|
|
5
|
+
* provider-specific metadata a caller can attach to each content part. Muse
|
|
6
|
+
* has no extra per-part options today, so text is empty and image mirrors the
|
|
7
|
+
* standard `detail` control.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** Metadata for Muse text content parts. */
|
|
11
|
+
export interface MuseTextMetadata {}
|
|
12
|
+
|
|
13
|
+
/** Metadata for Muse image content parts. */
|
|
14
|
+
export interface MuseImageMetadata {
|
|
15
|
+
/**
|
|
16
|
+
* The detail level of the image.
|
|
17
|
+
* - 'auto': let the model decide based on image size and content
|
|
18
|
+
* - 'low': low resolution processing (faster, cheaper, less detail)
|
|
19
|
+
* - 'high': high resolution processing (slower, more expensive, more detail)
|
|
20
|
+
*
|
|
21
|
+
* @default 'auto'
|
|
22
|
+
*/
|
|
23
|
+
detail?: 'auto' | 'low' | 'high'
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** Metadata for Muse audio content parts. */
|
|
27
|
+
export interface MuseAudioMetadata {}
|
|
28
|
+
|
|
29
|
+
/** Metadata for Muse video content parts. */
|
|
30
|
+
export interface MuseVideoMetadata {}
|
|
31
|
+
|
|
32
|
+
/** Metadata for Muse document content parts. */
|
|
33
|
+
export interface MuseDocumentMetadata {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Map of modality types to their Muse-specific metadata types.
|
|
37
|
+
* Used for type inference when constructing multimodal messages.
|
|
38
|
+
*/
|
|
39
|
+
export interface MuseMessageMetadataByModality {
|
|
40
|
+
text: MuseTextMetadata
|
|
41
|
+
image: MuseImageMetadata
|
|
42
|
+
audio: MuseAudioMetadata
|
|
43
|
+
video: MuseVideoMetadata
|
|
44
|
+
document: MuseDocumentMetadata
|
|
45
|
+
}
|