From 07a275fea5ccdaaaf94b37252697f26ed3ab7cf8 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 9 Aug 2024 12:56:30 -0700 Subject: [PATCH] chore: bump openai (#1113) --- .changeset/two-readers-matter.md | 5 +++ packages/llamaindex/package.json | 2 +- packages/llamaindex/src/llm/openai.ts | 27 ++++++++---- pnpm-lock.yaml | 62 +++++++++++++++++++++------ 4 files changed, 75 insertions(+), 21 deletions(-) create mode 100644 .changeset/two-readers-matter.md diff --git a/.changeset/two-readers-matter.md b/.changeset/two-readers-matter.md new file mode 100644 index 0000000000..250f5dc028 --- /dev/null +++ b/.changeset/two-readers-matter.md @@ -0,0 +1,5 @@ +--- +"llamaindex": patch +--- + +chore: bump openai diff --git a/packages/llamaindex/package.json b/packages/llamaindex/package.json index b6a01d4349..138d91474a 100644 --- a/packages/llamaindex/package.json +++ b/packages/llamaindex/package.json @@ -55,7 +55,7 @@ "md-utils-ts": "^2.0.0", "mongodb": "^6.7.0", "notion-md-crawler": "^1.0.0", - "openai": "^4.52.5", + "openai": "^4.55.3", "papaparse": "^5.4.1", "pathe": "^1.1.2", "pg": "^8.12.0", diff --git a/packages/llamaindex/src/llm/openai.ts b/packages/llamaindex/src/llm/openai.ts index 9581d8eeb5..198fedd1dc 100644 --- a/packages/llamaindex/src/llm/openai.ts +++ b/packages/llamaindex/src/llm/openai.ts @@ -6,6 +6,7 @@ import type { ClientOptions as OpenAIClientOptions, } from "openai"; import { AzureOpenAI, OpenAI as OrigOpenAI } from "openai"; +import type { ChatModel } from "openai/resources/chat/chat"; import { type BaseTool, @@ -108,16 +109,24 @@ export const GPT4_MODELS = { "gpt-4o-2024-05-13": { contextWindow: 128000 }, "gpt-4o-mini": { contextWindow: 128000 }, "gpt-4o-mini-2024-07-18": { contextWindow: 128000 }, + "gpt-4o-2024-08-06": { contextWindow: 128000 }, + "gpt-4o-2024-09-14": { contextWindow: 128000 }, + "gpt-4o-2024-10-14": { contextWindow: 128000 }, + "gpt-4-0613": { contextWindow: 128000 }, + "gpt-4-turbo-2024-04-09": { contextWindow: 128000 }, + "gpt-4-0314": { contextWindow: 128000 }, + "gpt-4-32k-0314": { contextWindow: 32768 }, }; // NOTE we don't currently support gpt-3.5-turbo-instruct and don't plan to in the near future export const GPT35_MODELS = { - "gpt-3.5-turbo": { contextWindow: 4096 }, + "gpt-3.5-turbo": { contextWindow: 16385 }, "gpt-3.5-turbo-0613": { contextWindow: 4096 }, - "gpt-3.5-turbo-16k": { contextWindow: 16384 }, - "gpt-3.5-turbo-16k-0613": { contextWindow: 16384 }, - "gpt-3.5-turbo-1106": { contextWindow: 16384 }, - "gpt-3.5-turbo-0125": { contextWindow: 16384 }, + "gpt-3.5-turbo-16k": { contextWindow: 16385 }, + "gpt-3.5-turbo-16k-0613": { contextWindow: 16385 }, + "gpt-3.5-turbo-1106": { contextWindow: 16385 }, + "gpt-3.5-turbo-0125": { contextWindow: 16385 }, + "gpt-3.5-turbo-0301": { contextWindow: 16385 }, }; /** @@ -126,7 +135,7 @@ export const GPT35_MODELS = { export const ALL_AVAILABLE_OPENAI_MODELS = { ...GPT4_MODELS, ...GPT35_MODELS, -}; +} satisfies Record; export function isFunctionCallingModel(llm: LLM): llm is OpenAI { let model: string; @@ -157,8 +166,10 @@ export type OpenAIAdditionalChatOptions = Omit< >; export class OpenAI extends ToolCallLLM { - // Per completion OpenAI params - model: keyof typeof ALL_AVAILABLE_OPENAI_MODELS | string; + model: + | ChatModel + // string & {} is a hack to allow any string, but still give autocomplete + | (string & {}); temperature: number; topP: number; maxTokens?: number; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index edbd1be4ff..96574d0ef3 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -148,7 +148,7 @@ importers: version: 2.4.4 chromadb: specifier: ^1.8.1 - version: 1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.10.6(@aws-sdk/client-sso-oidc@3.613.0(@aws-sdk/client-sts@3.613.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.52.5(encoding@0.1.13)) + version: 1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.10.6(@aws-sdk/client-sso-oidc@3.613.0(@aws-sdk/client-sts@3.613.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.55.3(encoding@0.1.13)(zod@3.23.8)) commander: specifier: ^12.1.0 version: 12.1.0 @@ -272,7 +272,7 @@ importers: version: 1.1.0(@types/react@18.3.3)(react@18.3.1) ai: specifier: ^3.2.1 - version: 3.2.19(openai@4.52.5)(react@18.3.1)(svelte@4.2.18)(vue@3.4.31(typescript@5.5.3))(zod@3.23.8) + version: 3.2.19(openai@4.55.3(zod@3.23.8))(react@18.3.1)(svelte@4.2.18)(vue@3.4.31(typescript@5.5.3))(zod@3.23.8) class-variance-authority: specifier: ^0.7.0 version: 0.7.0 @@ -541,7 +541,7 @@ importers: version: 4.6.0 chromadb: specifier: 1.8.1 - version: 1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.10.6(@aws-sdk/client-sso-oidc@3.613.0(@aws-sdk/client-sts@3.613.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.52.5(encoding@0.1.13)) + version: 1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.10.6(@aws-sdk/client-sso-oidc@3.613.0(@aws-sdk/client-sts@3.613.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.55.3(encoding@0.1.13)(zod@3.23.8)) cohere-ai: specifier: 7.10.6 version: 7.10.6(@aws-sdk/client-sso-oidc@3.613.0(@aws-sdk/client-sts@3.613.0))(encoding@0.1.13) @@ -573,8 +573,8 @@ importers: specifier: ^1.0.0 version: 1.0.0(encoding@0.1.13) openai: - specifier: ^4.52.5 - version: 4.52.5(encoding@0.1.13) + specifier: ^4.55.3 + version: 4.55.3(encoding@0.1.13)(zod@3.23.8) papaparse: specifier: ^5.4.1 version: 5.4.1 @@ -684,7 +684,7 @@ importers: dependencies: ai: specifier: ^3.2.1 - version: 3.2.19(openai@4.52.5)(react@18.3.1)(svelte@4.2.18)(vue@3.4.31(typescript@5.5.3))(zod@3.23.8) + version: 3.2.19(openai@4.55.3(zod@3.23.8))(react@18.3.1)(svelte@4.2.18)(vue@3.4.31(typescript@5.5.3))(zod@3.23.8) llamaindex: specifier: workspace:* version: link:../../.. @@ -8330,6 +8330,15 @@ packages: resolution: {integrity: sha512-qqH8GsyPE3z06took/2uWOGqRcrZNlRoPAsihpg4jsl0+2Dfelnw6HDDMep0EI2Cfzw75nn3vHRZehep/IZzxg==} hasBin: true + openai@4.55.3: + resolution: {integrity: sha512-/IUDdK5w3aB1Kd88Ml7w5F+EkVM5aXlrY+lSpWXdIPL18CmGkC7lV9HFJ7beR0OUSFLFT0qmWvMynqtbMF06/Q==} + hasBin: true + peerDependencies: + zod: ^3.23.8 + peerDependenciesMeta: + zod: + optional: true + opener@1.5.2: resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==} hasBin: true @@ -15720,7 +15729,7 @@ snapshots: '@vue/shared': 3.4.31 estree-walker: 2.0.2 magic-string: 0.30.11 - postcss: 8.4.40 + postcss: 8.4.39 source-map-js: 1.2.0 '@vue/compiler-ssr@3.4.31': @@ -15911,7 +15920,7 @@ snapshots: clean-stack: 2.2.0 indent-string: 4.0.0 - ai@3.2.19(openai@4.52.5)(react@18.3.1)(svelte@4.2.18)(vue@3.4.31(typescript@5.5.3))(zod@3.23.8): + ai@3.2.19(openai@4.55.3(zod@3.23.8))(react@18.3.1)(svelte@4.2.18)(vue@3.4.31(typescript@5.5.3))(zod@3.23.8): dependencies: '@ai-sdk/provider': 0.0.12 '@ai-sdk/provider-utils': 1.0.2(zod@3.23.8) @@ -15928,7 +15937,7 @@ snapshots: sswr: 2.1.0(svelte@4.2.18) zod-to-json-schema: 3.22.5(zod@3.23.8) optionalDependencies: - openai: 4.52.5(encoding@0.1.13) + openai: 4.55.3(zod@3.23.8) react: 18.3.1 svelte: 4.2.18 zod: 3.23.8 @@ -16623,14 +16632,14 @@ snapshots: chownr@2.0.0: {} - chromadb@1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.10.6(@aws-sdk/client-sso-oidc@3.613.0(@aws-sdk/client-sts@3.613.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.52.5(encoding@0.1.13)): + chromadb@1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.10.6(@aws-sdk/client-sso-oidc@3.613.0(@aws-sdk/client-sts@3.613.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.55.3(encoding@0.1.13)(zod@3.23.8)): dependencies: cliui: 8.0.1 isomorphic-fetch: 3.0.0(encoding@0.1.13) optionalDependencies: '@google/generative-ai': 0.12.0 cohere-ai: 7.10.6(@aws-sdk/client-sso-oidc@3.613.0(@aws-sdk/client-sts@3.613.0))(encoding@0.1.13) - openai: 4.52.5(encoding@0.1.13) + openai: 4.55.3(encoding@0.1.13)(zod@3.23.8) transitivePeerDependencies: - encoding @@ -20693,7 +20702,7 @@ snapshots: execa: 8.0.1 pathe: 1.1.2 pkg-types: 1.1.3 - ufo: 1.5.3 + ufo: 1.5.4 object-assign@4.1.1: {} @@ -20824,6 +20833,35 @@ snapshots: transitivePeerDependencies: - encoding + openai@4.55.3(encoding@0.1.13)(zod@3.23.8): + dependencies: + '@types/node': 18.19.39 + '@types/node-fetch': 2.6.11 + abort-controller: 3.0.0 + agentkeepalive: 4.5.0 + form-data-encoder: 1.7.2 + formdata-node: 4.4.1 + node-fetch: 2.7.0(encoding@0.1.13) + optionalDependencies: + zod: 3.23.8 + transitivePeerDependencies: + - encoding + + openai@4.55.3(zod@3.23.8): + dependencies: + '@types/node': 18.19.39 + '@types/node-fetch': 2.6.11 + abort-controller: 3.0.0 + agentkeepalive: 4.5.0 + form-data-encoder: 1.7.2 + formdata-node: 4.4.1 + node-fetch: 2.7.0(encoding@0.1.13) + optionalDependencies: + zod: 3.23.8 + transitivePeerDependencies: + - encoding + optional: true + opener@1.5.2: {} option@0.2.4: {}