Skip to content

Commit

Permalink
[sdk] 1/n Standardize Input Schema - Input Attachment Data
Browse files Browse the repository at this point in the history
Starting point of standardizing Input Schema for prompts

This diff introduces the type `AttachmentDataWithStringValue` to python and typescript sdk which will allow attachments to have structure as well as validation in python (pydantic validation).
  • Loading branch information
Ankush Pala [email protected] committed Jan 15, 2024
1 parent d0810e7 commit ec4c86d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 10 additions & 1 deletion python/src/aiconfig/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ class OutputDataWithToolCallsValue(BaseModel):
OutputDataWithToolCallsValue,
]

class AttachmentDataWithStringValue(BaseModel):
"""
This represents the input data that is storied as a string, but we use
both the `kind` field here and the `mime_type` to convert
the string into the input format we want.
"""

kind: Literal["file_uri", "base64"]
value: str

class ExecuteResult(BaseModel):
"""
Expand Down Expand Up @@ -152,7 +161,7 @@ class Attachment(BaseModel):
"""

# The data representing the attachment
data: Any
data: Union[AttachmentDataWithStringValue, 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
Expand Down
13 changes: 12 additions & 1 deletion typescript/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,22 @@ export type SchemaVersion =
| "v1"
| "latest";

/**
* This represents the input data that is storied as a string, but we use
* both the `kind` field here and the `mime_type` 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
Expand Down

0 comments on commit ec4c86d

Please sign in to comment.