graphlit-client
Version:
Graphlit API Client for TypeScript
154 lines (153 loc) • 3.93 kB
TypeScript
import { ConversationMessage } from "../generated/graphql-types.js";
/**
* OpenAI message format
*/
export interface OpenAIMessage {
role: "system" | "user" | "assistant" | "tool";
content?: string | Array<{
type: "text" | "image_url";
text?: string;
image_url?: {
url: string;
};
}>;
tool_calls?: Array<{
id: string;
type: "function";
function: {
name: string;
arguments: string;
};
}>;
tool_call_id?: string;
}
/**
* Anthropic message format
*/
export interface AnthropicMessage {
role: "user" | "assistant";
content: string | Array<{
type: "text" | "image" | "tool_use" | "tool_result";
text?: string;
source?: {
type: "base64";
media_type: string;
data: string;
};
id?: string;
name?: string;
input?: unknown;
tool_use_id?: string;
content?: string;
}>;
}
/**
* Google message format
*/
export interface GoogleMessage {
role: "user" | "model";
parts: Array<{
text?: string;
inlineData?: {
mimeType: string;
data: string;
};
functionCall?: {
name: string;
args: unknown;
};
functionResponse?: {
name: string;
response: unknown;
};
}>;
}
/**
* Format GraphQL conversation messages for OpenAI SDK
*/
export declare function formatMessagesForOpenAI(messages: ConversationMessage[]): OpenAIMessage[];
/**
* Format GraphQL conversation messages for Anthropic SDK
*/
export declare function formatMessagesForAnthropic(messages: ConversationMessage[]): {
system?: string;
messages: AnthropicMessage[];
};
/**
* Format GraphQL conversation messages for Google SDK
*/
export declare function formatMessagesForGoogle(messages: ConversationMessage[]): GoogleMessage[];
/**
* Cohere message format
* Note: For Cohere v7 SDK, messages are handled differently:
* - Current message is passed as 'message' parameter
* - Previous messages are passed as 'chatHistory' array
*/
export interface CohereMessage {
role: "USER" | "CHATBOT" | "SYSTEM" | "TOOL";
message: string;
tool_calls?: Array<{
id: string;
name: string;
parameters: Record<string, any>;
}>;
tool_results?: Array<{
call: {
name: string;
parameters: Record<string, any>;
};
outputs: Array<{
output: string;
}>;
}>;
}
/**
* Format GraphQL conversation messages for Cohere SDK
*/
export declare function formatMessagesForCohere(messages: ConversationMessage[]): CohereMessage[];
/**
* Mistral message format
*/
export interface MistralMessage {
role: "system" | "user" | "assistant" | "tool";
content: string | Array<{
type: "text" | "image_url";
text?: string;
image_url?: string;
}>;
tool_calls?: Array<{
id: string;
function: {
name: string;
arguments: string;
};
}>;
tool_call_id?: string;
}
/**
* Format GraphQL conversation messages for Mistral SDK
*/
export declare function formatMessagesForMistral(messages: ConversationMessage[]): MistralMessage[];
/**
* Bedrock Claude message format (similar to Anthropic)
*/
export interface BedrockMessage {
role: "user" | "assistant";
content: string | Array<{
type: "text" | "image";
text?: string;
image?: {
format: "png" | "jpeg" | "gif" | "webp";
source: {
bytes: string;
};
};
}>;
}
/**
* Format GraphQL conversation messages for Bedrock SDK (Claude models)
*/
export declare function formatMessagesForBedrock(messages: ConversationMessage[]): {
system?: string;
messages: BedrockMessage[];
};