langchain-ai / langchainjs

🦜🔗 Build context-aware reasoning applications 🦜🔗
https://js.langchain.com/docs/
MIT License
12.31k stars 2.08k forks source link

Add support for GPT-4o #5346

Closed ahm750 closed 4 months ago

ahm750 commented 4 months ago

Checked other resources

Example Code

Error Message and Stack Trace (if applicable)

Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (file:///node_modules/js-tiktoken/dist/chunk-HXW345QN.js:224:13) at encodingForModel (file:///node_modules/@langchain/core/dist/utils/tiktoken.js:19:24) at ChatOpenAI.getNumTokens (file:///node_modules/@langchain/core/dist/language_models/base.js:174:40) at file:///node_modules/@langchain/openai/dist/chat_models.js:642:42 at Array.map () at ChatOpenAI.getNumTokensFromMessages (file:///node_modules/@langchain/openai/dist/chat_models.js:641:60) at ChatOpenAI.getEstimatedTokenCountFromPrompt (file:///node_modules/@langchain/openai/dist/chat_models.js:589:34) at ChatOpenAI._generate (file:///node_modules/@langchain/openai/dist/chat_models.js:536:49) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.allSettled (index 0) Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (file:///node_modules/js-tiktoken/dist/chunk-HXW345QN.js:224:13) at encodingForModel (file:///node_modules/@langchain/core/dist/utils/tiktoken.js:19:24) at ChatOpenAI.getNumTokens (file:///node_modules/@langchain/core/dist/language_models/base.js:174:40) at file:///node_modules/@langchain/openai/dist/chat_models.js:643:42 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.all (index 0) at async ChatOpenAI.getNumTokensFromMessages (file:///node_modules/@langchain/openai/dist/chat_models.js:641:33) at async ChatOpenAI.getEstimatedTokenCountFromPrompt (file:///node_modules/@langchain/openai/dist/chat_models.js:589:23) at async ChatOpenAI._generate (file:///node_modules/@langchain/openai/dist/chat_models.js:536:38) at async Promise.allSettled (index 0) Failed to calculate number of tokens, falling back to approximate count Error: Unknown model at getEncodingNameForModel (file:///node_modules/js-tiktoken/dist/chunk-HXW345QN.js:224:13) at encodingForModel (file:///node_modules/@langchain/core/dist/utils/tiktoken.js:19:24) at ChatOpenAI.getNumTokens (file:///node_modules/@langchain/core/dist/language_models/base.js:174:40) at file:///node_modules/@langchain/openai/dist/chat_models.js:623:35 at Array.map () at ChatOpenAI.getNumTokensFromGenerations (file:///node_modules/@langchain/openai/dist/chat_models.js:617:64) at ChatOpenAI._generate (file:///node_modules/@langchain/openai/dist/chat_models.js:537:53) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.allSettled (index 0) at async ChatOpenAI._generateUncached (file:///node_modules/@langchain/core/dist/language_models/chat_models.js:114:25)

Description

Hi, OpenAI just released GPT-4o and langchain needs to be updated to support this model. At the moment, it throws the above error when using the new model.

System Info

Langchain: 0.1.37 Platform: macos Node: 21.7.3 Yarn: 4.2.2

jeasonnow commented 4 months ago

5354

This is a resolved issue, please wait for the new version of langchainjs.

sanjiv-upgiant commented 4 months ago

This is not yet solved. Here's my langchain packages.

    "@langchain/community": "^0.0.54",
    "@langchain/groq": "^0.0.9",
    "@langchain/langgraph": "^0.0.12",
    "@langchain/openai": "^0.0.29",
sanjiv-upgiant commented 4 months ago

NEED THE UPDATE TO BE RELEASED........

ahm750 commented 4 months ago

@jacoblee93 Any ETA on the new release?

jacoblee93 commented 4 months ago

Hey the fix should be live if you update to the latest @langchain/core! The tiktoken dep is there.

jacoblee93 commented 4 months ago

https://x.com/philippec_me/status/1790142477141147884?s=46&t=pBOviutddr6W7u_gV0VQqg

maikosantos commented 4 months ago

Hi,

Now, It's working for me!

Thanks!

ahm750 commented 4 months ago

Thank you, it works now!

adeenrabbani1 commented 2 months ago

guys I have only installed langchain npm. does this install langchain core?

jacoblee93 commented 2 months ago

guys I have only installed langchain npm. does this install langchain core?

It does as a dependency, yes. See this guide:

https://js.langchain.com/v0.2/docs/how_to/installation/#installing-integration-packages

adeenrabbani1 commented 2 months ago

@jacoblee93 even though I have updated to version 0.2.6, I still get weird context length errors which are not valid, as the context len for gpt-4o is 128k.

I have also raise an issue here. https://github.com/langchain-ai/langchainjs/issues/5888

it seems to start at version of langchain 0.1.37