mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-16 15:04:13 +00:00
docs: fix milvus import and update template (#22306)
docs: fix milvus import problem update milvus-rag template with milvus-lite Signed-off-by: ChengZi <chen.zhang@zilliz.com>
This commit is contained in:
@@ -1,12 +1,23 @@
|
||||
from langchain_community.vectorstores import Milvus
|
||||
from langchain_core.output_parsers import StrOutputParser
|
||||
from langchain_core.prompts import ChatPromptTemplate
|
||||
from langchain_core.pydantic_v1 import BaseModel
|
||||
from langchain_core.runnables import RunnableParallel, RunnablePassthrough
|
||||
from langchain_milvus.vectorstores import Milvus
|
||||
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
|
||||
|
||||
# Example for document loading (from url), splitting, and creating vectorstore
|
||||
|
||||
# Setting the URI as a local file, e.g.`./milvus.db`, is the most convenient method,
|
||||
# as it automatically utilizes Milvus Lite to store all data in this file.
|
||||
#
|
||||
# If you have large scale of data such as more than a million docs,
|
||||
# we recommend setting up a more performant Milvus server on docker or kubernetes.
|
||||
# (https://milvus.io/docs/quickstart.md)
|
||||
# When using this setup, please use the server URI,
|
||||
# e.g.`http://localhost:19530`, as your URI.
|
||||
|
||||
URI = "./milvus.db"
|
||||
|
||||
"""
|
||||
# Load
|
||||
from langchain_community.document_loaders import WebBaseLoader
|
||||
@@ -25,6 +36,7 @@ vectorstore = Milvus.from_documents(documents=all_splits,
|
||||
collection_name="rag_milvus",
|
||||
embedding=OpenAIEmbeddings(),
|
||||
drop_old=True,
|
||||
connection_args={"uri": URI},
|
||||
)
|
||||
retriever = vectorstore.as_retriever()
|
||||
"""
|
||||
@@ -35,9 +47,7 @@ vectorstore = Milvus.from_texts(
|
||||
collection_name="rag_milvus",
|
||||
embedding=OpenAIEmbeddings(),
|
||||
drop_old=True,
|
||||
connection_args={
|
||||
"uri": "http://127.0.0.1:19530",
|
||||
},
|
||||
connection_args={"uri": URI},
|
||||
)
|
||||
retriever = vectorstore.as_retriever()
|
||||
|
||||
|
Reference in New Issue
Block a user