Closed natapol2547 closed 5 months ago
On the other hand, I should ask for a feature request for integration with Astra DB Chat Memory like Langchain Python has Link. It would use the astra-db-ts library instead. It would be awesome if we have that π
π€
Hello @natapol2547! I'm Dosu, a friendly bot here to assist you while we wait for a human maintainer. I can help you with bug fixes, answer questions, and guide you on your journey to becoming a contributor. Let's tackle this issue together.
The "Contact points are not defined" error typically occurs when the Cassandra driver is unable to find the contact points or nodes of the Cassandra cluster. In your case, it seems like you're using a secure connection bundle to connect to the Cassandra cluster, which should contain the necessary contact points.
However, if you're still encountering this error, it might be due to an incorrect or missing secure connection bundle. Make sure the path to your secure bundle is correct and the bundle file is present at that location.
As for the integration with Astra DB Chat Memory using the astra-db-ts library, the current version of LangChain JS (0.1.9) does not support this feature. However, you can extend the BufferMemory
class to use the astra-db-ts library for storing chat history. Here's a basic example:
import { BufferMemory } from "langchain/memory";
import { AstraChatMessageHistory } from "<path to your AstraChatMessageHistory class>";
import { ChatOpenAI } from "langchain/chat_models/openai";
import { ConversationChain } from "langchain/chains";
const memory = new BufferMemory({
chatHistory: new AstraChatMessageHistory({
cloud: {
secureConnectBundle: "<path to your secure bundle>",
},
credentials: {
username: "token",
password: "<your Astra DB access token>",
},
keyspace: "langchain",
table: "message_history",
sessionId: "<some unique session identifier>",
}),
});
const model = new ChatOpenAI();
const chain = new ConversationChain({ llm: model, memory });
In this example, AstraChatMessageHistory
is a hypothetical class that you would need to implement, which uses the astra-db-ts library to interact with Astra DB. Please note that this is a high-level example and the actual implementation may vary based on the specifics of your application and the astra-db-ts library.
Regarding your question about the expected format and content of the serviceProviderArgs
object in the configConnection
when using the CassandraChatMessageHistory
class, I wasn't able to find an answer within the repository. Could you provide more details about the error or issue you're encountering with this object? This would help me provide a more accurate answer.
For more information, you can refer to the examples/src/memory/cassandra-store.ts file in the langchainjs repository.
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a π if this is helpful and π if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
@natapol2547
AstraDB is supported by CassandraChatMessageHistory
and it works for me.
I'm using LangChain community @0.0.32
const configConnection = {
serviceProviderArgs: {
astra: {
token: "AstraCS:zzz",
endpoint: "https://fxxx.apps.astra.datastax.com"
},
},
};
const chatHistory = new CassandraChatMessageHistory({
...configConnection,
keyspace: "default_keyspace",
table: "message_history",
sessionId: "yyy",
})
chatHistory.addMessage(new AIMessage("test?"))
Agreed about the having AstraDB integration! But the current cassandra one is still compatible
@natapol2547 AstraDBChatMessageHistory
was added as part of 0.1.21
@mfortman11 Ohh Thank you so much for mentioning me! I'll close this issue now. π
Description: The Langchain JS Cassandra Chat Memory documentation specifies a configuration for connecting to Cassandra using the cassandra-driver. However, when attempting to use this configuration, it results in a TypeError, indicating that "Contacts points are not defined." I am using Astra DB
Code to Reproduce:
Error Log:
Additional Information: Langchain JS version: 0.1.9 cassandra-driver version: 4.7.2