
AI代应用的自以为是的知识提取和语义检索。
探索文档»
报告错误·请求功能
Dewy通过从文档中提取知识并在提取的内容上实施语义搜索来帮助您构建AI代理和抹布应用程序。加载您的文档,露水负责解析,分解,总结和索引以进行检索。 Dewy建立在将真正的AI应用程序投入生产的课程的基础上,因此您可以专注于获得?完成,而不是比较矢量数据库和构建数据提取基础架构。
以下是执行抹布的AI代理的典型体系结构。露水处理棕色显示的所有零件,因此您可以专注于应用程序 - 绿色的零件。

(返回到顶部)
要启动并运行本地副本,请按照以下步骤操作。
(可选)启动一个pgvector实例以持续您的数据
Dewy使用矢量数据库存储有关已加载的文档以及用于提供语义搜索结果的嵌入的元数据。
docker run -d
-p 5432:5432
-e POSTGRES_DB=dewydb
-e POSTGRES_USER=dewydbuser
-e POSTGRES_PASSWORD=dewydbpwd
-e POSTGRES_HOST_AUTH_METHOD=trust
ankane/pgvector如果您已经有一个pgvector实例,则可以创建一个数据库,用于露水,并使用DB env var使用露水(见下文)。
安装露水
pip install dewy
这将在您当地的Python环境中安装Dewy。
配置露水。如果提供,露水将从.env文件中读取Env vars。您也可以直接在环境中设置这些设置,例如,在配置Docker / Kubernetes中运行的实例时。
# ~/.env
ENVIRONMENT=LOCAL
DB=postgresql://...
OPENAI_API_KEY=...开火露水
dewy露水包括一个管理控制台,您可以用来创建集合,加载文档和运行测试查询。
open http://localhost:8000/admin安装API客户库库
npm install dewy-ts连接到露水的实例
import { Dewy } from 'dewy_ts' ;
const dewy = new Dewy ( )添加文档
await dewy . kb . addDocument ( {
collection_id : 1 ,
url : “https : //arxiv.org/abs/2005.11401”,
} )检索llm提示的文档块
const context = await dewy . kb . retrieveChunks ( {
collection_id : 1 ,
query : "tell me about RAG" ,
n : 10 ,
} ) ;
// Minimal prompt example
const prompt = [
{
role : 'system' ,
content : `You are a helpful assistant.
You will take into account any CONTEXT BLOCK that is provided in a conversation.
START CONTEXT BLOCK
${ context . results . map ( ( c : any ) => c . chunk . text ) . join ( "n" ) }
END OF CONTEXT BLOCK
` ,
} ,
]
// Using OpenAI to generate responses
const response = await openai . chat . completions . create ( {
model : 'gpt-3.5-turbo' ,
stream : true ,
messages : [ ... prompt , [ { role : 'user' : content : 'Tell me about RAG' } ] ]
} )安装API客户库库
pip install dewy-client连接到露水的实例
from dewy_client import Client
dewy = Client ( base_url = "http://localhost:8000" )添加文档
from dewy_client . api . kb import add_document
from dewy_client . models import AddDocumentRequest
await add_document . asyncio ( client = dewy , body = AddDocumentRequest (
collection_id = 1 ,
url = “ https : // arxiv . org / abs / 2005.11401 ”,
))检索llm提示的文档块
from dewy_client . api . kb import retrieve_chunks
from dewy_client . modles import RetrieveRequest
chunks = await retrieve_chunks . asyncio ( client = dewy , body = RetrieveRequest (
collection_id = 1 ,
query = "tell me about RAG" ,
n = 10 ,
))
# Minimal prompt example
prompt = f"""
You will take into account any CONTEXT BLOCK that is provided in a conversation.
START CONTEXT BLOCK
{ " n " . join ([ chunk . text for chunk in chunks . text_chunks ]) }
END OF CONTEXT BLOCK
"""参见[ python-langchain.ipynb'](demos/python-langchain-notebook/python-langchain.ipynb) for an example using Dewy in LangChain, including an implementation of LangChain's 。
露水正在积极发展。这是我们当前路线图的概述 - 请?对您来说很重要的问题。看不到可以使露水更适合您的应用程序的功能 - 创建功能请求!
贡献是使开源社区成为学习,启发和创造的惊人场所的原因。您所做的任何贡献都非常感谢。
如果您有一个可以使情况变得更好的建议,请分配存储库并创建拉动请求。您也可以简单地使用标签“增强”打开问题。别忘了给项目一个明星!再次感谢!
git checkout -b feature/AmazingFeature )git commit -m 'Add some AmazingFeature' )git push origin feature/AmazingFeature )git clone https://github.com/DewyKB/dewy.gitpoetry install.env文件中读取Env vars。您也可以直接在环境中设置这些设置,例如,在配置Docker / Kubernetes中运行的实例时。 cat > .env << EOF
ENVIRONMENT=LOCAL
DB=postgresql://...
OPENAI_API_KEY=...
EOF cd frontend && npm install && npm run build cd dewy-client && poetry installpoetry run dewy一些基于https://github.com/zhanymkanov/fastapi-best-practices的最佳实践的骨架代码。
以下命令运行测试并应用绒毛。如果您在poetry shell中,可以省略poetry run :
poetry run pytestpoetry run ruff check --fixpoetry run ruff formatpoetry run mypy dewy再生OpenAPI规范和客户端库:
poetry poe extract-openapi
poetry poe update-client(返回到顶部)
释放pyproject.toml用于dewy b。 dewy-client/pyproject.toml用于dewy-client c。 dewy/config.py d中的API版本。 openapi.yaml和dewy-client通过运行poe extract-openapi和poe update-client 。dewy和dewy-client套件。(返回到顶部)
根据Apache 2许可证分发。有关更多信息,请参见LICENSE.txt 。
(返回到顶部)