请按照 MongoDB 设置指南 中的说明获取连接字符串。
安装 MongoDB 包
MongoDB 也支持异步操作,可实现并发处理,从而提高性能。
在对吞吐量要求较高的应用中,请使用 aload()
和 aprint_response()
方法配合 asyncio.run()
来实现非阻塞操作。
参数 | 类型 | 说明 | 默认值 |
---|---|---|---|
collection_name | str | MongoDB 集合的名称 | Required |
db_url | Optional[str] | MongoDB 连接字符串 | "mongodb://localhost:27017/" |
database | str | 数据库名称 | "agno" |
embedder | Optional[Embedder] | 用于生成 embedding 的 embedder 实例 | OpenAIEmbedder() |
distance_metric | str | 用于相似度计算的距离度量 | Distance.cosine |
overwrite | bool | 如果为 True,则覆盖现有集合和索引 | False |
wait_until_index_ready | Optional[float] | 等待索引就绪的秒数 | None |
wait_after_insert | Optional[float] | 插入文档后等待的秒数 | None |
max_pool_size | int | 连接池中的最大连接数 | 100 |
retry_writes | bool | 是否重试写入操作 | True |
client | Optional[MongoClient] | 一个已存在的 MongoClient 实例 | None |