@ui-tars/sdk
Version:
A powerful cross-platform(ANY device/platform) toolkit for building GUI automation agents for UI-TARS
65 lines • 2.37 kB
TypeScript
import { ChatCompletionMessageParam } from 'openai/resources/chat/completions';
import { Conversation, Message } from '@ui-tars/shared/types';
import { type Factors } from './constants';
import { ResponseInput, ResponseInputItem } from 'openai/resources/responses/responses.js';
/**
* Parse box string to screen coordinates
*
* e.g. '[0.131,0.25,0.131,0.25]' 2560x1440 -> { x: 335.36, y: 360 }
*
* @param boxStr box string
* @param screenWidth screen width
* @param screenHeight screen height
* @param factors scaling factor, the training space of the target model.
* @returns screen coordinates
*/
export declare const parseBoxToScreenCoords: ({ boxStr, screenWidth, screenHeight, factors, }: {
boxStr: string;
screenWidth: number;
screenHeight: number;
factors?: Factors;
}) => {
x: null;
y: null;
} | {
x: number;
y: number;
};
export declare const processVlmParams: (conversations: Message[], images: string[], maxImageLength?: number) => {
images: string[];
conversations: Message[];
};
export declare const toVlmModelFormat: ({ historyMessages, conversations, systemPrompt, }: {
historyMessages: Message[];
conversations: Conversation[];
systemPrompt: string;
}) => {
conversations: Message[];
images: string[];
};
export declare const getSummary: (prediction: string) => string;
/**
* convert conversations to OpenAI ChatCompletionMessageParam
* @param conversations conversations
* @param images images
* @returns OpenAI ChatCompletionMessageParam
*/
export declare const convertToOpenAIMessages: ({ conversations, images, }: {
conversations: Message[];
images: string[];
}) => Array<ChatCompletionMessageParam>;
export declare function replaceBase64Prefix(base64: string): string;
export declare function preprocessResizeImage(image_base64: string, maxPixels: number): Promise<string>;
/**
* convert ChatCompletionMessageParam to Response API input
* @param messages messages
* @returns Response API input
*/
export declare const convertToResponseApiInput: (messages: ChatCompletionMessageParam[]) => ResponseInput;
/**
* check if the message is an image message
* @param c message
* @returns true if the message is an image message
*/
export declare const isMessageImage: (c: ChatCompletionMessageParam | ResponseInputItem) => boolean;
//# sourceMappingURL=utils.d.ts.map