Skip to content

Commit

Permalink
chore: rename Ai to AI
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Nov 3, 2023
1 parent 12c98e3 commit 2a387dc
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/model/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion src/model/clients/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { OpenAIClient } from 'openai-fetch';
const cachedClients = new Map<string, OpenAIClient>();

/** Create a new openai-fetch OpenAIClient. */
export function createOpenAiClient(
export function createOpenAIClient(
/** Options to pass to the OpenAI client. */
opts?: ConstructorParameters<typeof OpenAIClient>[0],
/** Force a new client to be created. */
Expand Down
4 changes: 2 additions & 2 deletions src/model/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<
Expand All @@ -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 });
Expand Down
4 changes: 2 additions & 2 deletions src/model/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
6 changes: 3 additions & 3 deletions src/prompt/functions/ai-function.test.ts
Original file line number Diff line number Diff line change
@@ -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.',
Expand All @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/prompt/functions/ai-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>,
Return extends any
>(
Expand All @@ -27,7 +27,7 @@ export function createAiFunction<
},
/** Implementation of the function to call with the parsed arguments. */
implementation: (params: z.infer<Schema>) => Promise<Return>
): Prompt.AiFunction<Schema, Return> {
): Prompt.AIFunction<Schema, Return> {
/** Parse the arguments string, optionally reading from a message. */
const parseArgs = (input: string | Prompt.Msg) => {
if (typeof input === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion src/prompt/index.ts
Original file line number Diff line number Diff line change
@@ -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';
2 changes: 1 addition & 1 deletion src/prompt/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any> = z.ZodObject<any>,
Return extends any = any
> {
Expand Down

0 comments on commit 2a387dc

Please sign in to comment.