83 lines
1.5 KiB
TypeScript
83 lines
1.5 KiB
TypeScript
import { DataContent } from './data-content';
|
|
|
|
/**
|
|
Text content part of a prompt. It contains a string of text.
|
|
*/
|
|
export interface TextPart {
|
|
type: 'text';
|
|
|
|
/**
|
|
The text content.
|
|
*/
|
|
text: string;
|
|
}
|
|
|
|
/**
|
|
Image content part of a prompt. It contains an image.
|
|
*/
|
|
export interface ImagePart {
|
|
type: 'image';
|
|
|
|
/**
|
|
Image data. Can either be:
|
|
|
|
- data: a base64-encoded string, a Uint8Array, an ArrayBuffer, or a Buffer
|
|
- URL: a URL that points to the image
|
|
*/
|
|
image: DataContent | URL;
|
|
|
|
/**
|
|
Optional mime type of the image.
|
|
*/
|
|
mimeType?: string;
|
|
}
|
|
|
|
/**
|
|
Tool call content part of a prompt. It contains a tool call (usually generated by the AI model).
|
|
*/
|
|
export interface ToolCallPart {
|
|
type: 'tool-call';
|
|
|
|
/**
|
|
ID of the tool call. This ID is used to match the tool call with the tool result.
|
|
*/
|
|
toolCallId: string;
|
|
|
|
/**
|
|
Name of the tool that is being called.
|
|
*/
|
|
toolName: string;
|
|
|
|
/**
|
|
Arguments of the tool call. This is a JSON-serializable object that matches the tool's input schema.
|
|
*/
|
|
args: unknown;
|
|
}
|
|
|
|
/**
|
|
Tool result content part of a prompt. It contains the result of the tool call with the matching ID.
|
|
*/
|
|
export interface ToolResultPart {
|
|
type: 'tool-result';
|
|
|
|
/**
|
|
ID of the tool call that this result is associated with.
|
|
*/
|
|
toolCallId: string;
|
|
|
|
/**
|
|
Name of the tool that generated this result.
|
|
*/
|
|
toolName: string;
|
|
|
|
/**
|
|
Result of the tool call. This is a JSON-serializable object.
|
|
*/
|
|
result: unknown;
|
|
|
|
/**
|
|
Optional flag if the result is an error or an error message.
|
|
*/
|
|
isError?: boolean;
|
|
}
|