diff --git a/packages/llamaindex/package.json b/packages/llamaindex/package.json index ddd1206f8e..8f8f228ea3 100644 --- a/packages/llamaindex/package.json +++ b/packages/llamaindex/package.json @@ -56,7 +56,7 @@ "md-utils-ts": "^2.0.0", "mongodb": "^6.7.0", "notion-md-crawler": "^1.0.0", - "openai": "^4.57.0", + "openai": "^4.60.0", "papaparse": "^5.4.1", "pathe": "^1.1.2", "portkey-ai": "0.1.16", diff --git a/packages/llamaindex/src/llm/openai.ts b/packages/llamaindex/src/llm/openai.ts index eb8ac39c17..1a5b237a16 100644 --- a/packages/llamaindex/src/llm/openai.ts +++ b/packages/llamaindex/src/llm/openai.ts @@ -97,6 +97,9 @@ export function getOpenAISession( } export const GPT4_MODELS = { + "chatgpt-4o-latest": { + contextWindow: 128000, + }, "gpt-4": { contextWindow: 8192 }, "gpt-4-32k": { contextWindow: 32768 }, "gpt-4-32k-0613": { contextWindow: 32768 }, @@ -129,12 +132,28 @@ export const GPT35_MODELS = { "gpt-3.5-turbo-0301": { contextWindow: 16385 }, }; +export const O1_MODELS = { + "o1-preview": { + contextWindow: 128000, + }, + "o1-preview-2024-09-12": { + contextWindow: 128000, + }, + "o1-mini": { + contextWindow: 128000, + }, + "o1-mini-2024-09-12": { + contextWindow: 128000, + }, +}; + /** * We currently support GPT-3.5 and GPT-4 models */ export const ALL_AVAILABLE_OPENAI_MODELS = { ...GPT4_MODELS, ...GPT35_MODELS, + ...O1_MODELS, } satisfies Record; export function isFunctionCallingModel(llm: LLM): llm is OpenAI { @@ -148,7 +167,8 @@ export function isFunctionCallingModel(llm: LLM): llm is OpenAI { } const isChatModel = Object.keys(ALL_AVAILABLE_OPENAI_MODELS).includes(model); const isOld = model.includes("0314") || model.includes("0301"); - return isChatModel && !isOld; + const isO1 = model.startsWith("o1"); + return isChatModel && !isOld && !isO1; } export type OpenAIAdditionalMetadata = {}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fe9dd4dd29..c7ed08d739 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -152,7 +152,7 @@ importers: version: 2.4.6 chromadb: specifier: ^1.8.1 - version: 1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.13.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.57.0(encoding@0.1.13)(zod@3.23.8)) + version: 1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.13.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.60.0(encoding@0.1.13)(zod@3.23.8)) commander: specifier: ^12.1.0 version: 12.1.0 @@ -167,7 +167,7 @@ importers: version: link:../packages/llamaindex mongodb: specifier: ^6.7.0 - version: 6.8.0(@aws-sdk/credential-providers@3.637.0) + version: 6.8.0(@aws-sdk/credential-providers@3.637.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))) pathe: specifier: ^1.1.2 version: 1.1.2 @@ -276,7 +276,7 @@ importers: version: 1.1.0(@types/react@18.3.5)(react@18.3.1) ai: specifier: ^3.3.21 - version: 3.3.21(openai@4.57.0(zod@3.23.8))(react@18.3.1)(sswr@2.1.0(svelte@4.2.19))(svelte@4.2.19)(vue@3.4.38(typescript@5.5.4))(zod@3.23.8) + version: 3.3.21(openai@4.60.0(zod@3.23.8))(react@18.3.1)(sswr@2.1.0(svelte@4.2.19))(svelte@4.2.19)(vue@3.4.38(typescript@5.5.4))(zod@3.23.8) class-variance-authority: specifier: ^0.7.0 version: 0.7.0 @@ -554,7 +554,7 @@ importers: version: 4.7.0 chromadb: specifier: 1.8.1 - version: 1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.13.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.57.0(encoding@0.1.13)(zod@3.23.8)) + version: 1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.13.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.60.0(encoding@0.1.13)(zod@3.23.8)) cohere-ai: specifier: 7.13.0 version: 7.13.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))(encoding@0.1.13) @@ -581,13 +581,13 @@ importers: version: 2.0.0 mongodb: specifier: ^6.7.0 - version: 6.8.0(@aws-sdk/credential-providers@3.637.0) + version: 6.8.0(@aws-sdk/credential-providers@3.637.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))) notion-md-crawler: specifier: ^1.0.0 version: 1.0.0(encoding@0.1.13) openai: - specifier: ^4.57.0 - version: 4.57.0(encoding@0.1.13)(zod@3.23.8) + specifier: ^4.60.0 + version: 4.60.0(encoding@0.1.13)(zod@3.23.8) papaparse: specifier: ^5.4.1 version: 5.4.1 @@ -700,7 +700,7 @@ importers: dependencies: ai: specifier: ^3.3.21 - version: 3.3.21(openai@4.57.0(zod@3.23.8))(react@18.3.1)(sswr@2.1.0(svelte@4.2.19))(svelte@4.2.19)(vue@3.4.38(typescript@5.5.4))(zod@3.23.8) + version: 3.3.21(openai@4.60.0(zod@3.23.8))(react@18.3.1)(sswr@2.1.0(svelte@4.2.19))(svelte@4.2.19)(vue@3.4.38(typescript@5.5.4))(zod@3.23.8) llamaindex: specifier: workspace:* version: link:../../.. @@ -8388,6 +8388,15 @@ packages: zod: optional: true + openai@4.60.0: + resolution: {integrity: sha512-U/wNmrUPdfsvU1GrKRP5mY5YHR3ev6vtdfNID6Sauz+oquWD8r+cXPL1xiUlYniosPKajy33muVHhGS/9/t6KA==} + hasBin: true + peerDependencies: + zod: ^3.23.8 + peerDependenciesMeta: + zod: + optional: true + opener@1.5.2: resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==} hasBin: true @@ -15966,7 +15975,7 @@ snapshots: clean-stack: 2.2.0 indent-string: 4.0.0 - ai@3.3.21(openai@4.57.0(zod@3.23.8))(react@18.3.1)(sswr@2.1.0(svelte@4.2.19))(svelte@4.2.19)(vue@3.4.38(typescript@5.5.4))(zod@3.23.8): + ai@3.3.21(openai@4.60.0(zod@3.23.8))(react@18.3.1)(sswr@2.1.0(svelte@4.2.19))(svelte@4.2.19)(vue@3.4.38(typescript@5.5.4))(zod@3.23.8): dependencies: '@ai-sdk/provider': 0.0.22 '@ai-sdk/provider-utils': 1.0.17(zod@3.23.8) @@ -15983,7 +15992,7 @@ snapshots: secure-json-parse: 2.7.0 zod-to-json-schema: 3.23.2(zod@3.23.8) optionalDependencies: - openai: 4.57.0(zod@3.23.8) + openai: 4.60.0(zod@3.23.8) react: 18.3.1 sswr: 2.1.0(svelte@4.2.19) svelte: 4.2.19 @@ -16660,14 +16669,14 @@ snapshots: chownr@2.0.0: {} - chromadb@1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.13.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.57.0(encoding@0.1.13)(zod@3.23.8)): + chromadb@1.8.1(@google/generative-ai@0.12.0)(cohere-ai@7.13.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))(encoding@0.1.13))(encoding@0.1.13)(openai@4.60.0(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.13.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))(encoding@0.1.13) - openai: 4.57.0(encoding@0.1.13)(zod@3.23.8) + openai: 4.60.0(encoding@0.1.13)(zod@3.23.8) transitivePeerDependencies: - encoding @@ -17755,6 +17764,16 @@ snapshots: transitivePeerDependencies: - supports-color + eslint-module-utils@2.8.2(@typescript-eslint/parser@8.3.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint@8.57.0): + dependencies: + debug: 3.2.7 + optionalDependencies: + '@typescript-eslint/parser': 8.3.0(eslint@8.57.0)(typescript@5.5.4) + eslint: 8.57.0 + eslint-import-resolver-node: 0.3.9 + transitivePeerDependencies: + - supports-color + eslint-plugin-import@2.29.1(@typescript-eslint/parser@8.3.0(eslint@8.57.0)(typescript@5.5.4))(eslint@8.57.0): dependencies: array-includes: 3.1.8 @@ -17765,7 +17784,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.2(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3(@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) + eslint-module-utils: 2.8.2(@typescript-eslint/parser@8.3.0(eslint@8.57.0)(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint@8.57.0) hasown: 2.0.2 is-core-module: 2.15.1 is-glob: 4.0.3 @@ -20493,7 +20512,7 @@ snapshots: optionalDependencies: '@aws-sdk/credential-providers': 3.637.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0)) - mongodb@6.8.0(@aws-sdk/credential-providers@3.637.0): + mongodb@6.8.0(@aws-sdk/credential-providers@3.637.0(@aws-sdk/client-sso-oidc@3.637.0(@aws-sdk/client-sts@3.637.0))): dependencies: '@mongodb-js/saslprep': 1.1.7 bson: 6.8.0 @@ -20923,7 +20942,23 @@ snapshots: transitivePeerDependencies: - encoding - openai@4.57.0(zod@3.23.8): + openai@4.60.0(encoding@0.1.13)(zod@3.23.8): + dependencies: + '@types/node': 18.19.47 + '@types/node-fetch': 2.6.11 + '@types/qs': 6.9.15 + 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) + qs: 6.13.0 + optionalDependencies: + zod: 3.23.8 + transitivePeerDependencies: + - encoding + + openai@4.60.0(zod@3.23.8): dependencies: '@types/node': 18.19.47 '@types/node-fetch': 2.6.11 @@ -23348,7 +23383,7 @@ snapshots: union@0.5.0: dependencies: - qs: 6.11.2 + qs: 6.13.0 unique-string@3.0.0: dependencies: