Galaxia Retriever
Galaxia 是一种 GraphRAG 解决方案,可自动化文档处理、知识库(图语言模型)创建和检索: galaxia-rag
要使用 Galaxia,首先在此处上传您的文本并创建图语言模型: smabbler-cloud
模型构建并激活后,您将能够使用此集成来检索所需内容。
模块仓库位于此处: github
集成详情
检索器 | 自托管 | 云服务 | 包 |
---|---|---|---|
Galaxia Retriever | ❌ | ✅ | langchain-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