UNPKG

@aihubmix/ai-sdk-provider

Version:

<div align="center"> <a href="README.md">πŸ‡ΊπŸ‡Έ English</a> | <a href="README.zh.md">πŸ‡¨πŸ‡³ δΈ­ζ–‡</a> | <a href="README.ja.md">πŸ‡―πŸ‡΅ ζ—₯本θͺž</a> </div>

231 lines (225 loc) β€’ 8.46 kB
import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3, TranscriptionModelV3, SpeechModelV3 } from '@ai-sdk/provider'; import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils'; import { FetchFunction } from '@ai-sdk/provider-utils'; declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactory<{}, { /** * Filters for the search. */ filters?: { /** * Allowed domains for the search. * If not provided, all domains are allowed. * Subdomains of the provided domains are allowed as well. */ allowedDomains?: string[]; }; /** * Search context size to use for the web search. * - high: Most comprehensive context, highest cost, slower response * - medium: Balanced context, cost, and latency (default) * - low: Least context, lowest cost, fastest response */ searchContextSize?: "low" | "medium" | "high"; /** * User location information to provide geographically relevant search results. */ userLocation?: { /** * Type of location (always 'approximate') */ type: "approximate"; /** * Two-letter ISO country code (e.g., 'US', 'GB') */ country?: string; /** * City name (free text, e.g., 'Minneapolis') */ city?: string; /** * Region name (free text, e.g., 'Minnesota') */ region?: string; /** * IANA timezone (e.g., 'America/Chicago') */ timezone?: string; }; }>; /** * A filter used to compare a specified attribute key to a given value using a defined comparison operation. */ type OpenAIResponsesFileSearchToolComparisonFilter = { /** * The key to compare against the value. */ key: string; /** * Specifies the comparison operator: eq, ne, gt, gte, lt, lte. */ type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte'; /** * The value to compare against the attribute key; supports string, number, or boolean types. */ value: string | number | boolean; }; /** * Combine multiple filters using and or or. */ type OpenAIResponsesFileSearchToolCompoundFilter = { /** * Type of operation: and or or. */ type: 'and' | 'or'; /** * Array of filters to combine. Items can be ComparisonFilter or CompoundFilter. */ filters: Array<OpenAIResponsesFileSearchToolComparisonFilter | OpenAIResponsesFileSearchToolCompoundFilter>; }; declare const aihubmixTools: { /** * The Code Interpreter tool allows models to write and run Python code in a * sandboxed environment to solve complex problems in domains like data analysis, * coding, and math. * * @param container - The container to use for the code interpreter. * * Must have name `code_interpreter`. */ codeInterpreter: (args?: { container?: string | { fileIds?: string[]; }; }) => _ai_sdk_provider_utils.Tool<{ code?: string | null; containerId: string; }, { outputs?: Array<{ type: "logs"; logs: string; } | { type: "image"; url: string; }> | null; }>; /** * File search is a tool available in the Responses API. It enables models to * retrieve information in a knowledge base of previously uploaded files through * semantic and keyword search. * * Must have name `file_search`. * * @param vectorStoreIds - The vector store IDs to use for the file search. * @param maxNumResults - The maximum number of results to return. * @param ranking - The ranking options to use for the file search. * @param filters - The filters to use for the file search. */ fileSearch: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, { queries: string[]; results: null | { attributes: Record<string, unknown>; fileId: string; filename: string; score: number; text: string; }[]; }, { vectorStoreIds: string[]; maxNumResults?: number; ranking?: { ranker?: string; scoreThreshold?: number; }; filters?: OpenAIResponsesFileSearchToolComparisonFilter | OpenAIResponsesFileSearchToolCompoundFilter; }>; /** * The image generation tool allows you to generate images using a text prompt, * and optionally image inputs. It leverages the GPT Image model, * and automatically optimizes text inputs for improved performance. * * Must have name `image_generation`. * * @param size - Image dimensions (e.g., 1024x1024, 1024x1536) * @param quality - Rendering quality (e.g. low, medium, high) * @param format - File output format * @param compression - Compression level (0-100%) for JPEG and WebP formats * @param background - Transparent or opaque */ imageGeneration: (args?: { background?: "auto" | "opaque" | "transparent"; inputFidelity?: "low" | "high"; inputImageMask?: { fileId?: string; imageUrl?: string; }; model?: string; moderation?: "auto"; outputCompression?: number; outputFormat?: "png" | "jpeg" | "webp"; quality?: "auto" | "low" | "medium" | "high"; size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024"; }) => _ai_sdk_provider_utils.Tool<{}, { result: string; }>; /** * Web search allows models to access up-to-date information from the internet * and provide answers with sourced citations. * * Must have name `web_search_preview`. * * @param searchContextSize - The search context size to use for the web search. * @param userLocation - The user location to use for the web search. * * @deprecated Use `webSearch` instead. */ webSearchPreview: _ai_sdk_provider_utils.ProviderToolFactory<{}, { searchContextSize?: "low" | "medium" | "high"; userLocation?: { type: "approximate"; country?: string; city?: string; region?: string; timezone?: string; }; }>; /** * Web search allows models to access up-to-date information from the internet * and provide answers with sourced citations. * * Must have name `web_search`. * * @param filters - The filters to use for the web search. * @param searchContextSize - The search context size to use for the web search. * @param userLocation - The user location to use for the web search. */ webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, unknown>; }; interface OpenAIProviderSettings { [key: string]: unknown; } interface AihubmixProvider extends ProviderV3 { (deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV3; readonly specificationVersion: 'v3'; languageModel(deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV3; chat(deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV3; responses(deploymentId: string): LanguageModelV3; completion(deploymentId: string, settings?: OpenAIProviderSettings): LanguageModelV3; embedding(deploymentId: string, settings?: OpenAIProviderSettings): EmbeddingModelV3; embeddingModel(modelId: string): EmbeddingModelV3; image(deploymentId: string, settings?: OpenAIProviderSettings): ImageModelV3; imageModel(modelId: string): ImageModelV3; textEmbedding(deploymentId: string, settings?: OpenAIProviderSettings): EmbeddingModelV3; textEmbeddingModel(deploymentId: string, settings?: OpenAIProviderSettings): EmbeddingModelV3; transcription(deploymentId: string): TranscriptionModelV3; speech(deploymentId: string): SpeechModelV3; speechModel(deploymentId: string): SpeechModelV3; tools: typeof aihubmixTools; } interface AihubmixProviderSettings { apiKey?: string; fetch?: FetchFunction; compatibility?: 'strict' | 'compatible'; } declare function createAihubmix(options?: AihubmixProviderSettings): AihubmixProvider; declare const aihubmix: AihubmixProvider; export { type AihubmixProvider, type AihubmixProviderSettings, aihubmix, createAihubmix };