Skip to content

Commit

Permalink
feat: added new openai models
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcadams committed Nov 8, 2023
1 parent 3895f4b commit 2d1cb18
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 24 deletions.
5 changes: 5 additions & 0 deletions .changeset/early-bees-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"hopfield": patch
---

**Feature:** added new model versions from latest OpenAI release.
3 changes: 1 addition & 2 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentSize": 2,
"indentWidth": 2,
"lineWidth": 80
},
"linter": {
Expand All @@ -30,7 +30,6 @@
"noUnusedVariables": "error"
},
"nursery": {
"useExhaustiveDependencies": "error",
"useGroupedTypeImport": "off"
},
"performance": {
Expand Down
Binary file modified bun.lockb
Binary file not shown.
3 changes: 2 additions & 1 deletion examples/bun/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"typescript": "^5.0.0"
},
"dependencies": {
"hopfield": "workspace:*"
"hopfield": "workspace:*",
"openai": "4.16.1"
}
}
3 changes: 2 additions & 1 deletion examples/cloudflare-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"wrangler": "^3.0.0"
},
"dependencies": {
"hopfield": "workspace:*"
"hopfield": "workspace:*",
"openai": "4.16.1"
}
}
2 changes: 1 addition & 1 deletion examples/next-13/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@vercel/kv": "latest",
"hopfield": "workspace:*",
"next": "latest",
"openai": "4.11.1",
"openai": "4.16.1",
"react": "latest",
"react-dom": "latest",
"zod": "latest"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"fs-extra": "^11.1.1",
"json-schema": "^0.4.0",
"json-schema-deref-sync": "^0.14.0",
"openai": "4.11.1",
"openai": "4.16.1",
"rimraf": "^5.0.5",
"simple-git-hooks": "^2.9.0",
"size-limit": "^9.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export type AnyBaseHopfieldFunction = BaseHopfieldFunction<
type FunctionProperty<
T extends AnyBaseHopfieldFunction,
K extends keyof T,
> = T extends { [P in K]: infer N } ? N : never;
> = T extends { [_P in K]: infer N } ? N : never;

export type FunctionPropertyOrNever<
T extends AnyBaseHopfieldFunction[],
Expand Down Expand Up @@ -264,7 +264,7 @@ export abstract class BaseHopfieldFunction<
return {
name: this.name,
description: this.description,
parameters: zodToJsonSchema(this.parameters, {
parameters: zodToJsonSchema(this.parameters as any, {
$refStrategy: 'none',
onParseDef,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const TEST_TIMEOUT = 8_000;
const hopfield = hop.client(openai).provider(openAIClient);

// change the model here to see performance diff
const hopfieldChat = hopfield.chat('gpt-4-0613');
const hopfieldChat = hopfield.chat('gpt-3.5-turbo-0613');

const classifyMessage = hopfield.function({
name: 'classifyMessage',
Expand Down
12 changes: 9 additions & 3 deletions src/openai/models.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
export const openAIChatModelNames = [
'gpt-3.5-turbo-0613',
'gpt-3.5-turbo-16k-0613',
'gpt-4-0314' /** @deprecated Legacy model, to be discontinued Jun 13, 2024 */,
'gpt-4-0613',
'gpt-4-32k-0314' /** @deprecated Legacy model, to be discontinued Jun 13, 2024 */,
'gpt-4-32k-0613',
'gpt-3.5-turbo-0301' /** @deprecated Legacy model, to be discontinued Jun 13, 2024 */,
'gpt-3.5-turbo-0613' /** @deprecated Legacy model, will be replaced by gpt-3.5-turbo-1106 on Dec 11, 2023 */,
'gpt-3.5-turbo-1106',
'gpt-3.5-turbo-16k-0613' /** @deprecated Will be replaced by gpt-3.5-turbo-1106 on Dec 11, 2023 */,
'gpt-4-1106-preview',
] as const;

/**
Expand All @@ -13,8 +18,9 @@ export const openAIChatModelNames = [
export type OpenAIChatModelName = typeof openAIChatModelNames[number];

export const openAIChatModelNamesWithFunctionCalling = [
'gpt-3.5-turbo-0613',
'gpt-4-0613',
'gpt-4-32k-0613',
'gpt-3.5-turbo-1106',
] as const;

export const defaultOpenAIChatModelName =
Expand Down
14 changes: 3 additions & 11 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@
"!**/*.bench.ts",
"!tsconfig.build.json"
],
"keywords": [
"ai",
"llm",
"openai",
"gpt",
"ai-tools"
],
"keywords": ["ai", "llm", "openai", "gpt", "ai-tools"],
"license": "MIT",
"peerDependenciesMeta": {
"openai": {
Expand All @@ -53,14 +47,12 @@
"types": "./_types/index.d.ts",
"typesVersions": {
"*": {
"openai": [
"./_types/openai/index.d.ts"
]
"openai": ["./_types/openai/index.d.ts"]
}
},
"typings": "./_types/index.d.ts",
"dependencies": {
"zod": "^3.22.3",
"zod": "^3.22.4",
"zod-to-json-schema": "^3.21.4"
}
}
2 changes: 1 addition & 1 deletion src/type-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export type OneOf<
Union extends object,
AllKeys extends KeyofUnion<Union> = KeyofUnion<Union>,
> = Union extends infer Item
? Pretty<Item & { [K in Exclude<AllKeys, keyof Item>]?: never }>
? Pretty<Item & { [_K in Exclude<AllKeys, keyof Item>]?: never }>
: never;
type KeyofUnion<T> = T extends T ? keyof T : never;

Expand Down

1 comment on commit 2d1cb18

@vercel
Copy link

@vercel vercel bot commented on 2d1cb18 Nov 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.