跳至内容

检索

GenAIScript 提供多种实用工具来检索内容和增强提示。 这一技术在文献中通常被称为RAG(检索增强生成)。

GenAIScript提供多种向量数据库来支持嵌入(向量)搜索。

// index creation
const index = await retrieval.index("animals")
// indexing
await index.insertOrUpdate(env.files)
// search
const 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的信息。