Closed MirzaCickusic closed 1 year ago
@MirzaCickusic I'm seeing this error as well, what was the resolution?
fyi - I encountered this after upgrading LangChain to a new version. It uses a different format for chat History - an array of strings not an array of string pairs. Or you could use the more complicated BaseChatMessage[]. See https://github.com/hwchase17/langchainjs/blob/c538b228098ee96aed180a1b049cac3f56defb0d/langchain/src/chains/conversational_retrieval_chain.ts?plain=1#L68-L82
I came across this issue too after upgrade langchain to 0.0.90. In case you have got the same issue. You can checkout my forked version(which uses chromadb as vector database).
I came across this issue too after upgrade langchain to 0.0.90. In case you have got the same issue. You can checkout my forked version(which uses chromadb as vector database).
It seems BaseChatMessage, HumanChatMessage, AIChatMessage are deprecated in newer versions. They can be now replaced with BaseMessage, HumanMessage, and AIMessage accordingly.
you should use langchain schema in your code when you wanna create a message to use that in a conversation chain , like this code :
import { ChatMessage } from 'langchain/schema';
let chatHistory: ChatMessage[] = []; const message= new ChatMessage("how can i use langchain to create a chat bot ?","user"); chatHistory.push(message);
await chain.call({ question: initialPrompt, chat_history:chatHistory });
Whenever I send a second message I always get the: _error TypeError: chatMessage.getType is not a function
I am wondering if this is a project-related or library-related issue.
Full stack trace:
error TypeError: chatMessage._getType is not a function at file:///Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/langchain/dist/chains/conversational_retrieval_chain.js:67:33 at Array.map (<anonymous>) at ConversationalRetrievalQAChain.getChatHistoryString (file:///Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/langchain/dist/chains/conversational_retrieval_chain.js:66:18) at ConversationalRetrievalQAChain._call (file:///Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/langchain/dist/chains/conversational_retrieval_chain.js:90:60) at ConversationalRetrievalQAChain.call (file:///Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/langchain/dist/chains/base.js:65:39) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async handler (webpack-internal:///(api)/./pages/api/chat.ts:45:26) at async Object.apiResolver (/Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/next/dist/server/api-utils/node.js:372:9) at async DevServer.runApi (/Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/next/dist/server/next-server.js:513:9) at async Object.fn (/Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/next/dist/server/next-server.js:815:35) at async Router.execute (/Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/next/dist/server/router.js:243:32) at async DevServer.runImpl (/Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/next/dist/server/base-server.js:432:29) at async DevServer.run (/Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/next/dist/server/dev/next-dev-server.js:814:20) at async DevServer.handleRequestImpl (/Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/next/dist/server/base-server.js:375:20) at async /Users/mirzacickusic/Documents/code/projects/gpt4-pdf-chatbot-langchain/node_modules/next/dist/server/base-server.js:157:99