diff --git a/src/model/chat.ts b/src/model/chat.ts index 014731e..55c3df6 100644 --- a/src/model/chat.ts +++ b/src/model/chat.ts @@ -2,7 +2,7 @@ import type { SetOptional } from 'type-fest'; import type { ModelArgs } from './model.js'; import type { Model } from './types.js'; import { calculateCost } from './utils/calculate-cost.js'; -import { createOpenAiClient } from './clients/openai.js'; +import { createOpenAIClient } from './clients/openai.js'; import { AbstractModel } from './model.js'; import { deepMerge } from './utils/helpers.js'; @@ -29,7 +29,7 @@ export class ChatModel extends AbstractModel< constructor(args?: ChatModelArgs) { let { client, params, ...rest } = args ?? {}; // Add a default client if none is provided - client = client ?? createOpenAiClient(); + client = client ?? createOpenAIClient(); // Set default model if no params are provided params = params ?? { model: 'gpt-3.5-turbo' }; super({ client, params, ...rest }); diff --git a/src/model/clients/openai.ts b/src/model/clients/openai.ts index ed9b771..73aa8d9 100644 --- a/src/model/clients/openai.ts +++ b/src/model/clients/openai.ts @@ -5,7 +5,7 @@ import { OpenAIClient } from 'openai-fetch'; const cachedClients = new Map(); /** Create a new openai-fetch OpenAIClient. */ -export function createOpenAiClient( +export function createOpenAIClient( /** Options to pass to the OpenAI client. */ opts?: ConstructorParameters[0], /** Force a new client to be created. */ diff --git a/src/model/completion.ts b/src/model/completion.ts index 4f52433..78b334d 100644 --- a/src/model/completion.ts +++ b/src/model/completion.ts @@ -2,7 +2,7 @@ import type { SetOptional } from 'type-fest'; import type { ModelArgs } from './model.js'; import type { Model } from './types.js'; import { calculateCost } from './utils/calculate-cost.js'; -import { createOpenAiClient } from './clients/openai.js'; +import { createOpenAIClient } from './clients/openai.js'; import { AbstractModel } from './model.js'; export type CompletionModelArgs = SetOptional< @@ -28,7 +28,7 @@ export class CompletionModel extends AbstractModel< constructor(args?: CompletionModelArgs) { let { client, params, ...rest } = args ?? {}; // Add a default client if none is provided - client = client ?? createOpenAiClient(); + client = client ?? createOpenAIClient(); // Set default model if no params are provided params = params ?? { model: 'gpt-3.5-turbo-instruct' }; super({ client, params, ...rest }); diff --git a/src/model/embedding.ts b/src/model/embedding.ts index 1038d2f..900976e 100644 --- a/src/model/embedding.ts +++ b/src/model/embedding.ts @@ -4,7 +4,7 @@ import type { SetOptional } from 'type-fest'; import type { ModelArgs } from './model.js'; import type { Model } from './types.js'; import { calculateCost } from './utils/calculate-cost.js'; -import { createOpenAiClient } from './clients/openai.js'; +import { createOpenAIClient } from './clients/openai.js'; import { AbstractModel } from './model.js'; import { deepMerge } from './utils/helpers.js'; @@ -46,7 +46,7 @@ export class EmbeddingModel extends AbstractModel< /** Doesn't accept OpenAIClient because retry needs to be handled at the model level. */ constructor(args?: EmbeddingModelArgs) { let { client, params, ...rest } = args || {}; - client = client || createOpenAiClient(); + client = client || createOpenAIClient(); params = params || { model: 'text-embedding-ada-002' }; super({ client, params, ...rest }); const interval = DEFAULTS.throttleInterval; diff --git a/src/model/index.ts b/src/model/index.ts index 8427748..d44bf1b 100644 --- a/src/model/index.ts +++ b/src/model/index.ts @@ -16,6 +16,6 @@ export type { SparseVectorModelArgs } from './sparse-vector.js'; export { SparseVectorModel } from './sparse-vector.js'; export { calculateCost } from './utils/calculate-cost.js'; -export { createOpenAiClient } from './clients/openai.js'; +export { createOpenAIClient } from './clients/openai.js'; export { createTokenizer } from './utils/tokenizer.js'; export { getModelMemoryCache } from './utils/memory-cache.js'; diff --git a/src/prompt/functions/ai-function.test.ts b/src/prompt/functions/ai-function.test.ts index 94ce05b..67aa6a9 100644 --- a/src/prompt/functions/ai-function.test.ts +++ b/src/prompt/functions/ai-function.test.ts @@ -1,8 +1,8 @@ import { describe, expect, it } from 'vitest'; import { z } from 'zod'; -import { createAiFunction } from './ai-function.js'; +import { createAIFunction } from './ai-function.js'; -const fullName = createAiFunction( +const fullName = createAIFunction( { name: 'fullName', description: 'Returns the full name of a person.', @@ -16,7 +16,7 @@ const fullName = createAiFunction( } ); -describe('createAiFunction()', () => { +describe('createAIFunction()', () => { it('exposes OpenAI function calling spec', () => { expect(fullName.spec.name).toEqual('fullName'); expect(fullName.spec.description).toEqual( diff --git a/src/prompt/functions/ai-function.ts b/src/prompt/functions/ai-function.ts index 2680e3e..2cb0eb6 100644 --- a/src/prompt/functions/ai-function.ts +++ b/src/prompt/functions/ai-function.ts @@ -13,7 +13,7 @@ import { cleanString } from '../utils/message.js'; * The `spec` property of the returned function is the spec for adding the * function to the OpenAI API `functions` property. */ -export function createAiFunction< +export function createAIFunction< Schema extends z.ZodObject, Return extends any >( @@ -27,7 +27,7 @@ export function createAiFunction< }, /** Implementation of the function to call with the parsed arguments. */ implementation: (params: z.infer) => Promise -): Prompt.AiFunction { +): Prompt.AIFunction { /** Parse the arguments string, optionally reading from a message. */ const parseArgs = (input: string | Prompt.Msg) => { if (typeof input === 'string') { diff --git a/src/prompt/index.ts b/src/prompt/index.ts index 4b5e4a9..f0b64a2 100644 --- a/src/prompt/index.ts +++ b/src/prompt/index.ts @@ -1,7 +1,7 @@ export type { Prompt } from './types.js'; export { Msg } from './utils/message.js'; -export { createAiFunction } from './functions/ai-function.js'; +export { createAIFunction } from './functions/ai-function.js'; export { extractJsonObject } from './functions/extract-json.js'; export { extractZodObject } from './functions/extract-zod-object.js'; export { zodToJsonSchema } from './functions/zod-to-json.js'; diff --git a/src/prompt/types.ts b/src/prompt/types.ts index ea19edb..5e913aa 100644 --- a/src/prompt/types.ts +++ b/src/prompt/types.ts @@ -23,7 +23,7 @@ export namespace Prompt { /** * A function meant to be used with OpenAI function calling. */ - export interface AiFunction< + export interface AIFunction< Schema extends z.ZodObject = z.ZodObject, Return extends any = any > {