diff --git a/python/src/aiconfig/__init__.py b/python/src/aiconfig/__init__.py index 19e20da94..e225f40e3 100644 --- a/python/src/aiconfig/__init__.py +++ b/python/src/aiconfig/__init__.py @@ -17,6 +17,7 @@ AIConfig, ConfigMetadata, ExecuteResult, + AttachmentDataWithStringValue, JSONObject, ModelMetadata, Output, diff --git a/python/src/aiconfig/schema.py b/python/src/aiconfig/schema.py index 70f910304..d730c7578 100644 --- a/python/src/aiconfig/schema.py +++ b/python/src/aiconfig/schema.py @@ -79,6 +79,15 @@ class OutputDataWithToolCallsValue(BaseModel): OutputDataWithToolCallsValue, ] +class AttachmentDataWithStringValue(BaseModel): + """ + This represents the attachment data that is stored as a string, but we use + both the `kind` field here and the `mime_type` in Attachment to convert + the string into the input format we want. + """ + + kind: Literal["file_uri", "base64"] + value: str class ExecuteResult(BaseModel): """ @@ -152,7 +161,7 @@ class Attachment(BaseModel): """ # The data representing the attachment - data: Any + data: Union[AttachmentDataWithStringValue, str, Any] # The MIME type of the result. If not specified, the MIME type will be assumed to be text/plain mime_type: Optional[str] = None # Output metadata diff --git a/typescript/types.ts b/typescript/types.ts index e648be63f..e2b724d7e 100644 --- a/typescript/types.ts +++ b/typescript/types.ts @@ -72,11 +72,22 @@ export type SchemaVersion = | "v1" | "latest"; +/** + * This represents the attachment data that is stored as a string, but we use + * both the `kind` field here and the `mime_type` in Attachment to convert + * the string into the input format we want. + */ +type AttachmentDataWithStringValue = { + kind: "file_uri" | "base64"; + value: string; +}; + + export type Attachment = { /** * The data representing the attachment */ - data: JSONValue; + data: JSONValue | AttachmentDataWithStringValue; /** * The MIME type of the result. If not specified, the MIME type will be