检索
GenAIScript 提供多种实用工具来检索内容和增强提示。 这一技术在文献中通常被称为RAG(检索增强生成)。
向量搜索
GenAIScript提供多种向量数据库来支持嵌入(向量)搜索。
// index creationconst index = await retrieval.index("animals")// indexingawait index.insertOrUpdate(env.files)// searchconst res = await index.search("cat dog")def("RAG", res)
- 了解更多关于向量搜索及其使用方法。
模糊搜索
retrieve.fuzzSearch
执行"传统"模糊搜索以找到与提示最相似的文档。
const files = await retrieval.fuzzSearch("cat dog", env.files)
网页搜索
retrieval.webSearch
通过搜索引擎API执行网络搜索。您需要为您想使用的搜索引擎提供API密钥。
const { webPages } = await retrieval.webSearch("cat dog")def("RAG", webPages)
Bing
要启用Bing搜索,请在您的.env
文件中配置BING_SEARCH_API_KEY
密钥。了解更多关于配置Bing搜索API的信息。