Skip to content

Commit ba07d80

Browse files
authored
Merge pull request #252 from nathanArseneau/add-audio-content
Add audio content
2 parents 592c91f + 9f5b4bf commit ba07d80

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Diff for: src/types.ts

+22-2
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,23 @@ export const ImageContentSchema = z
666666
})
667667
.passthrough();
668668

669+
/**
670+
* An Audio provided to or from an LLM.
671+
*/
672+
export const AudioContentSchema = z
673+
.object({
674+
type: z.literal("audio"),
675+
/**
676+
* The base64-encoded audio data.
677+
*/
678+
data: z.string().base64(),
679+
/**
680+
* The MIME type of the audio. Different providers may support different audio types.
681+
*/
682+
mimeType: z.string(),
683+
})
684+
.passthrough();
685+
669686
/**
670687
* The contents of a resource, embedded into a prompt or tool call result.
671688
*/
@@ -685,6 +702,7 @@ export const PromptMessageSchema = z
685702
content: z.union([
686703
TextContentSchema,
687704
ImageContentSchema,
705+
AudioContentSchema,
688706
EmbeddedResourceSchema,
689707
]),
690708
})
@@ -753,7 +771,7 @@ export const ListToolsResultSchema = PaginatedResultSchema.extend({
753771
*/
754772
export const CallToolResultSchema = ResultSchema.extend({
755773
content: z.array(
756-
z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema]),
774+
z.union([TextContentSchema, ImageContentSchema, AudioContentSchema, EmbeddedResourceSchema]),
757775
),
758776
isError: z.boolean().default(false).optional(),
759777
});
@@ -877,7 +895,7 @@ export const ModelPreferencesSchema = z
877895
export const SamplingMessageSchema = z
878896
.object({
879897
role: z.enum(["user", "assistant"]),
880-
content: z.union([TextContentSchema, ImageContentSchema]),
898+
content: z.union([TextContentSchema, ImageContentSchema, AudioContentSchema]),
881899
})
882900
.passthrough();
883901

@@ -931,6 +949,7 @@ export const CreateMessageResultSchema = ResultSchema.extend({
931949
content: z.discriminatedUnion("type", [
932950
TextContentSchema,
933951
ImageContentSchema,
952+
AudioContentSchema
934953
]),
935954
});
936955

@@ -1195,6 +1214,7 @@ export type ListPromptsResult = Infer<typeof ListPromptsResultSchema>;
11951214
export type GetPromptRequest = Infer<typeof GetPromptRequestSchema>;
11961215
export type TextContent = Infer<typeof TextContentSchema>;
11971216
export type ImageContent = Infer<typeof ImageContentSchema>;
1217+
export type AudioContent = Infer<typeof AudioContentSchema>;
11981218
export type EmbeddedResource = Infer<typeof EmbeddedResourceSchema>;
11991219
export type PromptMessage = Infer<typeof PromptMessageSchema>;
12001220
export type GetPromptResult = Infer<typeof GetPromptResultSchema>;

0 commit comments

Comments
 (0)