You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I really really love langchain. But you are moving too fast, releasing integration after integration without documenting the existing stuff enough or explaining how to implement real life use cases.
Here is what I am failing to do, probably one of the most basic tasks:
If my Redis server does not have a specific index, create one. Otherwise load from the index. There is a _check_index_exists method in the lib. There is also a call to create_index but it is burried inside from_texts.
Not sure how to proceed from here
The text was updated successfully, but these errors were encountered:
Thank you for bringing this issue to our attention. We apologize for the lack of documentation and explanation on how to implement real life use cases.
To check if an index exists and create one if it does not, you can use the following code example:
fromlangchain.embeddings.openaiimportOpenAIEmbeddingsfromlangchain.text_splitterimportCharacterTextSplitterfromlangchain.vectorstores.redisimportRedis# Load documentsloader=TextLoader('../../../state_of_the_union.txt')
documents=loader.load()
text_splitter=CharacterTextSplitter(chunk_size=1000, chunk_overlap=0)
docs=text_splitter.split_documents(documents)
# Create embeddingsembeddings=OpenAIEmbeddings()
# Create Redis instancerds=Redis.from_documents(docs, embeddings, redis_url="redis://localhost:6379", index_name='link')
# Check if index existsifrds.index_nameisnotNone:
# Load from indexquery="What did the president say about Ketanji Brown Jackson"results=rds.similarity_search(query)
print(results[0].page_content)
else:
# Create indexprint(rds.add_texts(["Ankush went to Princeton"]))
# Queryquery="Princeton"results=rds.similarity_search(query)
print(results[0].page_content)
We have also created a tutorial notebook that goes over different options for using the vector store as a retriever, as well as how to use Redis and SQLAlchemy caches. You can find the tutorial notebook here: [link to tutorial notebook].
We hope this helps and we apologize again for the lack of documentation. Please let us know if you have any further questions or concerns.
I really really love langchain. But you are moving too fast, releasing integration after integration without documenting the existing stuff enough or explaining how to implement real life use cases.
Here is what I am failing to do, probably one of the most basic tasks:
If my Redis server does not have a specific index, create one. Otherwise load from the index. There is a _check_index_exists method in the lib. There is also a call to create_index but it is burried inside from_texts.
Not sure how to proceed from here
The text was updated successfully, but these errors were encountered: