Skip to main content
Open In ColabOpen on GitHub

银河检索器

Galaxia 是一个 GraphRAG 解决方案,可自动执行文档处理、知识库(图语言模型)的创建和检索: galaxia-rag

要使用Galaxia,请先上传您的文本并在此处创建一个图语言模型: smabbler-cloud

模型构建并激活后,您将能够使用此集成检索所需内容。

模块存储库位于此处: github

集成详情

检索器Self-host云服务
Galaxia Retrieverlangchain-galaxia-retriever

设置

在检索任何内容之前,您需要在此处创建您的图形语言模型: smabbler-cloud

按照以下3个简单步骤操作: rag-instruction

不要忘记在构建模型后激活它!

安装

检索器在以下包中实现: pypi

%pip install -qU langchain-galaxia-retriever

实例化

from langchain_galaxia_retriever.retriever import GalaxiaRetriever

gr = GalaxiaRetriever(
api_url="beta.api.smabbler.com",
api_key="<key>", # you can find it here: https://beta.cloud.smabbler.com/user/account
knowledge_base_id="<knowledge_base_id>", # you can find it in https://beta.cloud.smabbler.com , in the model table
n_retries=10,
wait_time=5,
)

使用

result = gr.invoke("<test question>")
print(result)

在链中使用

from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough

prompt = ChatPromptTemplate.from_template(
"""Answer the question based only on the context provided.

Context: {context}

Question: {question}"""
)


def format_docs(docs):
return "\n\n".join(doc.page_content for doc in docs)


chain = (
{"context": gr | format_docs, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
chain.invoke("<test question>")

API 参考

有关Galaxia Retriever的更多信息,请查看其在github上的实现 github