UNPKG

@axiomhq/ai

Version:

Axiom AI SDK provides an API to wrap your AI calls with observability instrumentation.

1 lines 30.6 kB
{"version":3,"sources":["../src/bin.ts","../src/commands/push.ts","../src/transpiler.ts","../src/commands/pull.ts","../src/commands/run.ts","../src/evals/run-vitest.ts","../src/evals/reporter.ts","../src/evals/instrument.ts"],"sourcesContent":["#!/usr/bin/env node\n\n// Load environment variables using @next/env\nimport pkg from '@next/env';\nconst { loadEnvConfig } = pkg;\n\n// Load .env files from the current working directory\nloadEnvConfig(process.cwd());\n\nimport { Command } from 'commander';\nimport { loadPushCommand } from './commands/push';\nimport { loadPullCommand } from './commands/pull';\nimport { loadRunCommand } from './commands/run';\n\nconst program = new Command();\n\nprogram\n .name('axiom')\n .description(\"Axiom's CLI to manage your objects and run evals\")\n .version(__SDK_VERSION__);\n\nloadPushCommand(program);\nloadPullCommand(program);\nloadRunCommand(program);\n\nprogram.parse();\n","import { Command } from 'commander';\nimport {\n loadPromptModule,\n extractPromptFromModule,\n generatePromptFileFromApiResponse,\n} from '../transpiler';\nimport type { Prompt } from '../types';\nimport fs from 'node:fs/promises';\nimport readline from 'node:readline';\n\nasync function askConfirmation(message: string): Promise<boolean> {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n return new Promise((resolve) => {\n rl.question(`${message} (y/N): `, (answer) => {\n rl.close();\n resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');\n });\n });\n}\n\nexport const loadPushCommand = (program: Command) => {\n const push = new Command('push')\n .description('Push a new version of an object')\n .argument(\n '<object>',\n 'The object to push, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--prod', 'Adds the production tag to the prompt')\n .option('--yes', 'Automatically confirm overwriting the file with server response')\n .action(async (filePath: string, options: { yes?: boolean; prod?: boolean }) => {\n let content: Prompt | null = null;\n if (!filePath.endsWith('.prompt.ts')) {\n console.error('Prompt files must end with .prompt.ts');\n process.exit(1);\n }\n\n try {\n const moduleContent = await loadPromptModule(filePath);\n const promptData = extractPromptFromModule(moduleContent, filePath);\n\n content = promptData;\n\n console.log(`Transpiled prompt: ${promptData.name} (${promptData.slug})`);\n } catch (error) {\n console.error('Failed to transpile prompt file:', error);\n process.exit(1);\n }\n\n if (!content) {\n console.error('No content found');\n process.exit(1);\n }\n\n let shouldProceed = options.yes;\n if (!shouldProceed) {\n shouldProceed = await askConfirmation(\n `This will push \"${content.name}\" to Axiom and overwrite ${filePath}, are you sure you want to continue?`,\n );\n }\n\n if (!shouldProceed) {\n console.log('Push operation cancelled.');\n process.exit(0);\n }\n\n try {\n const response = await fetch(`${process.env.AXIOM_URL}/v1/prompts`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n body: JSON.stringify({\n ...content,\n tags: options.yes ? ['production'] : [],\n }),\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n console.log(\n `Successfully pushed prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`,\n );\n console.log(`Version: ${apiResponse.version.version}`);\n\n const updatedTsContent = generatePromptFileFromApiResponse(apiResponse);\n\n await fs.writeFile(filePath, updatedTsContent, 'utf-8');\n\n console.log(`Successfully updated ${filePath}`);\n } catch (error) {\n console.error('Failed to push prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(push);\n};\n","import { build } from 'esbuild';\nimport os from 'node:os';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { basename } from 'node:path';\nimport type { Prompt } from './types';\n\nexport async function loadPromptModule(filePath: string) {\n const result = await build({\n entryPoints: [filePath],\n bundle: true,\n write: false,\n platform: 'node',\n format: 'esm',\n target: ['node18'],\n sourcemap: false,\n external: [\n // Only Node.js built-ins should be external\n 'fs',\n 'fs/promises',\n 'node:fs',\n 'node:fs/promises',\n 'readline',\n 'node:readline',\n 'path',\n 'node:path',\n 'os',\n 'node:os',\n 'url',\n 'node:url',\n 'util',\n 'node:util',\n 'crypto',\n 'node:crypto',\n 'events',\n 'node:events',\n 'stream',\n 'node:stream',\n 'buffer',\n 'node:buffer',\n 'process',\n 'node:process',\n ],\n });\n\n const code = result.outputFiles[0].text;\n\n // Create a unique temporary file\n const tempDir = os.tmpdir();\n const tempFileName = `axiom-ai-prompt-${Date.now()}-${Math.random().toString(36).substring(2)}.mjs`;\n const tempFilePath = path.join(tempDir, tempFileName);\n\n try {\n // Write the bundled code to temporary file\n await fs.writeFile(tempFilePath, code, 'utf-8');\n\n // Dynamically import the temporary module\n const moduleUrl = `file://${tempFilePath}`;\n const module = await import(moduleUrl);\n\n return module.default || module;\n } finally {\n // Clean up the temporary file\n try {\n await fs.unlink(tempFilePath);\n } catch (error) {\n // Ignore cleanup errors - temp files will be cleaned up by OS eventually\n console.warn(`Failed to clean up temporary file ${tempFilePath}:`, error);\n }\n }\n}\n\n/**\n * Convert TypeBox arguments to JSON Schema format expected by the API\n */\nfunction convertTypeBoxArgumentsToJsonSchema(arguments_: Record<string, any>): any {\n if (!arguments_ || typeof arguments_ !== 'object') {\n return {\n type: 'object',\n properties: {},\n required: [],\n additionalProperties: false,\n };\n }\n\n const properties: Record<string, any> = {};\n const required: string[] = [];\n\n for (const [key, value] of Object.entries(arguments_)) {\n if (value && typeof value === 'object' && value.type) {\n // This is a TypeBox schema object that has been serialized\n properties[key] = {\n type: value.type,\n ...(value.description && { description: value.description }),\n ...(value.enum && { enum: value.enum }),\n ...(value.items && { items: value.items }),\n ...(value.properties && { properties: value.properties }),\n ...(value.required && { required: value.required }),\n };\n\n // For now, treat all arguments as required (this matches the existing behavior)\n // In the future, we could detect Type.Optional() usage\n required.push(key);\n }\n }\n\n return {\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n };\n}\n\nexport function extractPromptFromModule(moduleContent: any, filePath: string): Prompt {\n // Generate ID from file path if not provided\n const fileBaseName = basename(filePath, '.ts'); // Remove .ts extension\n const defaultId = fileBaseName.toLowerCase().replace(/[^a-z0-9]/g, '-');\n\n // Convert TypeBox arguments to JSON Schema format\n const convertedArguments = convertTypeBoxArgumentsToJsonSchema(moduleContent.arguments);\n\n // Extract and validate required fields from the module content\n const prompt: Prompt = {\n name: moduleContent.name || 'Untitled Prompt',\n slug: moduleContent.slug || defaultId,\n messages: moduleContent.messages || [],\n model: moduleContent.model,\n options: moduleContent.options,\n arguments: convertedArguments,\n id: moduleContent.id || defaultId,\n version: moduleContent.version || '1.0.0',\n // Optional fields from API response\n ...(moduleContent.promptId && { promptId: moduleContent.promptId }),\n ...(moduleContent.description && { description: moduleContent.description }),\n };\n\n // Validate required fields\n if (!prompt.name) {\n throw new Error('Prompt must have a name');\n }\n if (!prompt.slug) {\n throw new Error('Prompt must have a slug');\n }\n if (!Array.isArray(prompt.messages)) {\n throw new Error('Prompt messages must be an array');\n }\n\n if (!prompt.model) {\n throw new Error('Prompt must have a model');\n }\n\n return prompt;\n}\n\n/**\n * Transform JSON Schema to TypeBox/Template validator format\n */\nexport function transformJsonSchemaToTypeBox(schema: any): string {\n if (schema.type === 'string') {\n if (schema.enum && Array.isArray(schema.enum)) {\n // Handle enum as Union of Literals\n const literals = schema.enum.map((value: string) => `Type.Literal('${value}')`).join(', ');\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Union([${literals}]${options})`;\n } else {\n // Regular string\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.String(${options})`;\n }\n }\n\n if (schema.type === 'number' || schema.type === 'integer') {\n const typeMethod = schema.type === 'integer' ? 'Integer' : 'Number';\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.${typeMethod}(${options})`;\n }\n\n if (schema.type === 'boolean') {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Boolean(${options})`;\n }\n\n if (schema.type === 'array') {\n const itemsType = schema.items ? transformJsonSchemaToTypeBox(schema.items) : 'Type.String()';\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Array(${itemsType}${options})`;\n }\n\n if (schema.type === 'object') {\n if (schema.properties) {\n const props = Object.entries(schema.properties)\n .map(([key, value]: [string, any]) => {\n const isRequired = schema.required && schema.required.includes(key);\n const propType = transformJsonSchemaToTypeBox(value);\n return ` ${key}: ${isRequired ? propType : `Type.Optional(${propType})`}`;\n })\n .join(',\\n');\n\n const options = schema.description ? `, { description: '${schema.description}' }` : '';\n return `Type.Object({\\n${props}\\n }${options})`;\n } else {\n const options = schema.description ? `{ description: '${schema.description}' }` : '';\n return `Type.Object({}${options ? `, ${options}` : ''})`;\n }\n }\n\n // Fallback for unknown types\n return 'Type.String()';\n}\n\n/**\n * Generate TypeScript prompt file content from API response\n */\nexport function generatePromptFileFromApiResponse(apiResponse: any): string {\n const { prompt, version } = apiResponse;\n const { data, options } = version;\n\n // Transform arguments from JSON Schema to TypeBox format\n let argumentsCode = '{}';\n if (data.arguments && data.arguments.properties) {\n const argEntries = Object.entries(data.arguments.properties)\n .map(([key, schema]: [string, any]) => {\n const isRequired = data.arguments.required && data.arguments.required.includes(key);\n const typeCode = transformJsonSchemaToTypeBox(schema);\n return ` ${key}: ${isRequired ? typeCode : `Type.Optional(${typeCode})`}`;\n })\n .join(',\\n');\n\n if (argEntries) {\n argumentsCode = `{\\n${argEntries}\\n }`;\n }\n }\n\n // Generate the TypeScript file content\n return `import { Type } from '@axiomhq/ai';\n\nexport default {\n name: '${prompt.name}',\n slug: '${prompt.slug}',\n description: '${prompt.description || ''}',\n messages: [${data.messages\n .map(\n (msg: any) => `\n {\n role: '${msg.role}',\n content: '${msg.content.replace(/'/g, \"\\\\'\")}',\n }`,\n )\n .join(',')}\n ],\n model: '${data.model || 'gpt-4'}',\n options: {\n${\n options\n ? Object.entries(options)\n .map(([key, value]) => ` ${key}: ${value}`)\n .join(',\\n')\n : ''\n}\n },\n arguments: ${argumentsCode},\n version: '${version.version}',\n promptId: '${prompt.promptId}',\n};\n`;\n}\n","import { Command } from 'commander';\nimport { generatePromptFileFromApiResponse } from '../transpiler';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\n\nexport const loadPullCommand = (program: Command) => {\n const pull = new Command('pull')\n .description('Pull a version of an object')\n .argument(\n '<slug>',\n 'The object to pull, could be a prompt, en eval, a monitor, a dashboard, etc.',\n )\n .option('--version <version>', 'The version to pull, default: latest', 'latest')\n .option('--output <path>', 'Output file path (optional, defaults to <slug>.prompt.ts)')\n .action(async (slug: string, options: { version: string; output?: string }) => {\n try {\n console.log(`Pulling prompt: ${slug} (version: ${options.version})`);\n\n const url = `${process.env.AXIOM_URL}/v1/prompts/${slug}`;\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`,\n 'Content-Type': 'application/json',\n 'x-axiom-client': 'axiom-ai-cli',\n 'x-axiom-check': 'good',\n },\n });\n\n if (!response.ok) {\n try {\n const errorText = await response.clone().json();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(JSON.stringify(errorText, null, 2));\n process.exit(1);\n } catch (_error) {\n const errorText = await response.clone().text();\n console.error(`Failed to fetch prompt: ${response.status} ${response.statusText}`);\n console.error(errorText);\n process.exit(1);\n }\n }\n\n const apiResponse = await response.json();\n\n const tsContent = generatePromptFileFromApiResponse(apiResponse);\n\n const outputPath = options.output || `${slug}.prompt.ts`;\n const fullPath = path.resolve(outputPath);\n\n await fs.writeFile(fullPath, tsContent, 'utf-8');\n\n console.log(`Successfully generated prompt file: ${fullPath}`);\n console.log(`Prompt: ${apiResponse.prompt.name} (${apiResponse.prompt.slug})`);\n console.log(`Version: ${apiResponse.version.version}`);\n } catch (error) {\n console.error('Failed to pull prompt:', error);\n process.exit(1);\n }\n });\n\n program.addCommand(pull);\n};\n","import { Command } from 'commander';\nimport { runVitest } from '../evals/run-vitest';\n\nexport const loadRunCommand = (program: Command) => {\n return program.addCommand(\n new Command('run')\n .description('run evals locally')\n .argument('<path>', 'Path to an eval test file, should be in the form of name.eval.ts')\n .action(async (file: string) => {\n if (!process.env.AXIOM_URL || !process.env.AXIOM_TOKEN || !process.env.AXIOM_DATASET) {\n throw new Error('AXIOM_URL, AXIOM_TOKEN, and AXIOM_DATASET must be set');\n }\n await runVitest(file);\n }),\n );\n};\n","import { createVitest, registerConsoleShortcuts } from 'vitest/node';\nimport { AxiomReporter } from './reporter';\nimport { flush } from './instrument';\n\nexport const runVitest = async (file: string) => {\n const vi = await createVitest('test', {\n // root: process.cwd(),\n mode: 'test',\n include: [file ? file : '**/*.eval.ts'],\n reporters: ['verbose', new AxiomReporter()],\n environment: 'node',\n browser: undefined,\n });\n\n await vi.start();\n\n const dispose = registerConsoleShortcuts(vi, process.stdin, process.stdout);\n\n if (!vi.shouldKeepServer()) {\n dispose();\n await flush();\n await vi.close();\n process.exit(0);\n }\n\n await flush();\n};\n","import type { SerializedError } from 'vitest';\nimport type { Reporter, TestModule, TestRunEndReason, TestSuite } from 'vitest/node.js';\nimport type { TaskMeta } from 'vitest/index.cjs';\nimport type { EvalReport } from './eval';\n\n/**\n * Custom Vitest reporter for Axiom AI evaluations.\n *\n * This reporter collects evaluation results and scores from tests\n * and processes them for further analysis and reporting.\n *\n * @experimental This API is experimental and may change in future versions.\n */\nexport class AxiomReporter implements Reporter {\n onTestSuiteReady(_testSuite: TestSuite) {}\n\n onTestSuiteResult(testSuite: TestSuite) {\n for (const test of testSuite.children.array()) {\n if (test.type !== 'test') continue;\n const testMeta = test.meta() as TaskMeta & { eval: EvalReport };\n\n if (!testMeta.eval) {\n return;\n }\n\n // build scores array\n const scores: { name: string; score: number }[] = [];\n for (const s of Object.entries(testMeta.eval.scores)) {\n scores.push({ name: s[1].name, score: s[1].score });\n }\n }\n }\n\n async onTestRunEnd(\n _testModules: ReadonlyArray<TestModule>,\n _errors: ReadonlyArray<SerializedError>,\n _reason: TestRunEndReason,\n ) {}\n}\n","import { BatchSpanProcessor, NodeTracerProvider } from '@opentelemetry/sdk-trace-node';\nimport { resourceFromAttributes } from '@opentelemetry/resources';\nimport { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http';\nimport { trace, type Context, type SpanOptions } from '@opentelemetry/api';\n\nconst collectorOptions = {\n url: process.env.AXIOM_URL\n ? `${process.env.AXIOM_URL}/v1/traces`\n : 'https://api.axiom.co/v1/traces', // Axiom API endpoint for trace data\n headers: {\n Authorization: `Bearer ${process.env.AXIOM_TOKEN}`, // Replace API_TOKEN with your actual API token\n 'X-Axiom-Dataset': process.env.AXIOM_DATASET || '', // Replace DATASET_NAME with your dataset\n },\n concurrencyLimit: 10, // an optional limit on pending requests\n};\n\n// export const consoleExporter = new ConsoleSpanExporter()\nexport const exporter = new OTLPTraceExporter(collectorOptions);\n\nconst processor = new BatchSpanProcessor(exporter, {\n maxQueueSize: 2048,\n maxExportBatchSize: 512,\n scheduledDelayMillis: 5000,\n exportTimeoutMillis: 30000,\n});\n\nconst provider = new NodeTracerProvider({\n resource: resourceFromAttributes({\n ['service.name']: 'axiom-ai',\n ['service.version']: __SDK_VERSION__,\n }),\n spanProcessors: [processor],\n});\n\nprovider.register();\n\n// Create a shared tracer instance\nconst tracer = trace.getTracer('axiom-ai', __SDK_VERSION__);\n\nexport const flush = async () => {\n await provider.forceFlush();\n};\n\nexport const startSpan = (name: string, opts: SpanOptions, context?: Context) => {\n return tracer.startSpan(name, opts, context);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,iBAAgB;AAMhB,IAAAA,oBAAwB;;;ACTxB,uBAAwB;;;ACAxB,qBAAsB;AACtB,qBAAe;AACf,sBAAe;AACf,uBAAiB;AACjB,IAAAC,oBAAyB;AAGzB,eAAsB,iBAAiB,UAAkB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AAc,CAAC;AAAA,IAC1C,aAAa;AAAA,IACb,SAAS;AAAA,EACX,CAAC;AAED,QAAM,GAAG,MAAM;AAEf,QAAM,cAAU,sCAAyB,IAAI,QAAQ,OAAO,QAAQ,MAAM;AAE1E,MAAI,CAAC,GAAG,iBAAiB,GAAG;AAC1B,YAAQ;AACR,UAAM,MAAM;AACZ,UAAM,GAAG,MAAM;AACf,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,MAAM;AACd;;;ADvBO,IAAM,iBAAiB,CAACC,aAAqB;AAClD,SAAOA,SAAQ;AAAA,IACb,IAAI,0BAAQ,KAAK,EACd,YAAY,mBAAmB,EAC/B,SAAS,UAAU,kEAAkE,EACrF,OAAO,OAAO,SAAiB;AAC9B,UAAI,CAAC,QAAQ,IAAI,aAAa,CAAC,QAAQ,IAAI,eAAe,CAAC,QAAQ,IAAI,eAAe;AACpF,cAAM,IAAI,MAAM,uDAAuD;AAAA,MACzE;AACA,YAAM,UAAU,IAAI;AAAA,IACtB,CAAC;AAAA,EACL;AACF;;;AJXA,IAAM,EAAE,cAAc,IAAI,WAAAC;AAG1B,cAAc,QAAQ,IAAI,CAAC;AAO3B,IAAM,UAAU,IAAI,0BAAQ;AAE5B,QACG,KAAK,OAAO,EACZ,YAAY,kDAAkD,EAC9D,QAAQ,OAAe;AAE1B,gBAAgB,OAAO;AACvB,gBAAgB,OAAO;AACvB,eAAe,OAAO;AAEtB,QAAQ,MAAM;","names":["import_commander","import_node_path","os","path","fs","module","import_promises","readline","resolve","program","fs","import_commander","fs","path","program","import_commander","program","pkg"]}