vantedge-ai-sdk
Version:
VantEdge AI SDK provider for AI SDK
73 lines (66 loc) • 2.87 kB
text/typescript
import { LanguageModelV1, EmbeddingModelV1, ImageModelV1 } from '@ai-sdk/provider';
import { FetchFunction } from '@ai-sdk/provider-utils';
import { OpenAICompatibleChatSettings, OpenAICompatibleCompletionSettings, OpenAICompatibleEmbeddingSettings, OpenAICompatibleImageSettings } from '@ai-sdk/openai-compatible';
type VantEdgeAIChatModelId = 'vantedgeai/chat-model-1' | 'vantedgeai/chat-model-2' | (string & {});
interface VantEdgeAIChatSettings extends OpenAICompatibleChatSettings {
threadId?: string;
}
type VantEdgeAICompletionModelId = 'vantedgeai/completion-model-1' | 'vantedgeai/completion-model-2' | (string & {});
interface VantEdgeAICompletionSettings extends OpenAICompatibleCompletionSettings {
threadId?: string;
}
type VantEdgeAIEmbeddingModelId = 'vantedgeai/embedding-model-1' | 'vantedgeai/embedding-model-2' | (string & {});
interface VantEdgeAIEmbeddingSettings extends OpenAICompatibleEmbeddingSettings {
}
type VantEdgeAIImageModelId = 'vantedgeai/image-model-1' | 'vantedgeai/image-model-2' | (string & {});
interface VantEdgeAIImageSettings extends OpenAICompatibleImageSettings {
}
interface VantEdgeAIProviderSettings {
/**
VantEdgeAI API key.
*/
apiKey?: string;
/**
Base URL for the API calls.
*/
baseURL?: string;
/**
Custom headers to include in the requests.
*/
headers?: Record<string, string>;
/**
Optional custom url query parameters to include in request urls.
*/
queryParams?: Record<string, string>;
/**
Custom fetch implementation. You can use it as a middleware to intercept requests,
or to provide a custom fetch implementation for e.g. testing.
*/
fetch?: FetchFunction;
}
interface VantEdgeAIProvider {
/**
Creates a model for text generation.
*/
(modelId: VantEdgeAIChatModelId, settings?: VantEdgeAIChatSettings): LanguageModelV1;
/**
Creates a chat model for text generation.
*/
chatModel(modelId: VantEdgeAIChatModelId, settings?: VantEdgeAIChatSettings): LanguageModelV1;
/**
Creates a completion model for text generation.
*/
completionModel(modelId: VantEdgeAICompletionModelId, settings?: VantEdgeAICompletionSettings): LanguageModelV1;
/**
Creates a text embedding model for text generation.
*/
textEmbeddingModel(modelId: VantEdgeAIEmbeddingModelId, settings?: VantEdgeAIEmbeddingSettings): EmbeddingModelV1<string>;
/**
Creates an image model for image generation.
*/
imageModel(modelId: VantEdgeAIImageModelId, settings?: VantEdgeAIImageSettings): ImageModelV1;
}
declare function setGlobalThreadId(threadId: string): void;
declare function createVantEdgeAI(options?: VantEdgeAIProviderSettings): VantEdgeAIProvider;
declare const vantedgeai: VantEdgeAIProvider;
export { type VantEdgeAIProvider, type VantEdgeAIProviderSettings, createVantEdgeAI, setGlobalThreadId, vantedgeai };