Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sdk] 1/n Standardize Input Schema - Input Attachment Data #929

Merged
merged 1 commit into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions python/src/aiconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
AIConfig,
ConfigMetadata,
ExecuteResult,
AttachmentDataWithStringValue,
JSONObject,
ModelMetadata,
Output,
Expand Down
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 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
Copy link
Member Author

@Ankush-lastmile Ankush-lastmile Jan 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type and code is pretty much a duplicate of

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

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

Should this be merged into one type and abstracted? My take on that is no because That would reduce the explicitness and readability of this addition, but unsure what's right here.


class ExecuteResult(BaseModel):
"""
Expand Down Expand Up @@ -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
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 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
Expand Down