Skip to main content
Open In ColabOpen on GitHub

Galaxia 检索器

Galaxia 是 GraphRAG 解决方案,可以自动化文档处理、知识库(Graph 语言模型)创建和检索:galaxia-rag

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

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

The module repository is located here: github

集成细节

检索器Self-host云开发解决方案
Galaxia Retrieverlangchain-galaxia-retriever

设置

在您能够获取任何内容之前,您需要在这里创建您的图语言模型:smabbler-cloud

按照以下3个简单的步骤: rag-指令

记得在构建模型后激活它!

安装

retriever 是在以下包中实现的:pypi

%pip install -qU langchain-galaxia-retriever

Instantiation

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