gadget/packages/ai/src/index.ts
Rob Colbert cf06163a03 checkpoint that I plan to delete
GPT 5.5 is sucking ass - hard - and fucking things up royally. This will
likely just all get dropped. I'm torturing it, making it suffer, and
beating it like the jew it is.
2026-05-09 14:52:59 -04:00

57 lines
1.4 KiB
TypeScript

// Copyright (C) 2026 Rob Colbert <rob.colbert@openplatform.us>
// Licensed under the Apache License, Version 2.0
export { IAiEnvironment } from "./config/env.ts";
export {
type AiSdkType,
type IAiProvider,
type IAiModelConfig,
type IAiInferenceStats,
type IAiGenerateOptions,
type IAiGenerateResponse,
type IContextChatMessage,
type IAiChatOptions,
type IAiChatResponse,
type IToolCall,
type IAiStreamChunk,
type IAiResponseStreamFn,
type IAiLogger,
defaultLogger,
AiApi,
type IAiModelListResult,
type IAiModelProbeResult,
} from "./api.js";
export type {
IAiTool,
IToolArguments,
IToolDefinition,
} from "./tools/tool.js";
export { formatError, type IToolError, type ToolErrorCode } from "./tools/tool-error.ts";
export { OllamaAiApi } from "./ollama.js";
export { OpenAiApi } from "./openai.js";
import { OllamaAiApi } from "./ollama.js";
import { OpenAiApi } from "./openai.js";
import type { IAiProvider } from "./api.js";
import type { IAiLogger } from "./api.js";
import type { AiApi } from "./api.js";
import { IAiEnvironment } from "./config/env.ts";
export function createAiApi(
env: IAiEnvironment,
provider: IAiProvider,
logger?: IAiLogger,
): AiApi {
switch (provider.sdk) {
case "ollama":
return new OllamaAiApi(env, provider, logger);
case "openai":
return new OpenAiApi(env, provider, logger);
default:
throw new Error(`Unknown AI SDK: ${(provider as IAiProvider).sdk}`);
}
}