Skip to main content

rag-singlestoredb

这个模板使用SingleStoreDB和OpenAI执行RAG。

环境设置

这个模板使用SingleStoreDB作为向量存储,并且需要设置SINGLESTOREDB_URL。它应该采用以下形式:admin:password@svc-xxx.svc.singlestore.com:port/db_name

设置OPENAI_API_KEY环境变量以访问OpenAI模型。

使用方法

要使用这个包,你首先需要安装LangChain CLI:

pip install -U langchain-cli

要创建一个新的LangChain项目并将其安装为唯一的包,可以执行以下操作:

langchain app new my-app --package rag-singlestoredb

如果要将其添加到现有项目中,只需运行:

langchain app add rag-singlestoredb

并将以下代码添加到你的server.py文件中:

from rag_singlestoredb import chain as rag_singlestoredb_chain

add_routes(app, rag_singlestoredb_chain, path="/rag-singlestoredb")

(可选)现在让我们配置LangSmith。 LangSmith将帮助我们跟踪、监视和调试LangChain应用程序。 LangSmith目前处于私有测试版,你可以在这里注册。 如果你没有访问权限,可以跳过此部分

export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_API_KEY=<your-api-key>
export LANGCHAIN_PROJECT=<your-project> # 如果未指定,默认为"default"

如果你在此目录中,则可以直接启动LangServe实例:

langchain serve

这将在本地启动一个运行在http://localhost:8000的FastAPI应用程序服务器

我们可以在http://127.0.0.1:8000/docs上查看所有模板 我们可以在http://127.0.0.1:8000/rag-singlestoredb/playground上访问playground

我们可以通过以下代码访问模板:

from langserve.client import RemoteRunnable

runnable = RemoteRunnable("http://localhost:8000/rag-singlestoredb")

=======

请确认以上翻译是否符合您的要求。