ARTICLE DETAIL

资讯详情

深耕郑州网站建设与运营推广的一线实战洞察。

如何把 Azure Blob Storage 设为 GPT Researcher 的报告文档来源

如何把 Azure Blob Storage 设为 GPT Researcher 的报告文档来源 如何把 Azure Blob Storage 设为 GPT Researcher 的报告文档来源【免费下载链接】gpt-researcherAn autonomous agent that conducts deep research on any data using any LLM providers项目地址: https://gitcode.com/GitHub_Trending/gp/gpt-researcherGPT Researcher 默认通过联网检索收集报告上下文如果你的研究素材已经存放在自己的 Azure Blob Storage 容器里可以改用report_sourceazure让报告直接基于容器中的文档生成。完成本文后你用 PIP 包方式运行的GPTResearcher实例会从指定容器下载全部 Blob 作为研究文档输出基于这些文档的报告。整个过程只需要三步配置环境变量、安装依赖、在实例化时指定来源。前提环境变量与依赖在项目根目录的.env文件中设置两个变量AZURE_CONNECTION_STRING是存储账户的连接字符串AZURE_CONTAINER_NAME是你存放研究文档的容器名。AZURE_CONNECTION_STRING AZURE_CONTAINER_NAME然后把azure-storage-blob加进你的requirements.txtazure-storage-blob这两个环境变量会在研究执行时被读取代码中通过os.getenv(AZURE_CONTAINER_NAME)和os.getenv(AZURE_CONNECTION_STRING)取值构造 Azure 客户端见 gpt_researcher/skills/researcher.py#L187-L195所以确保运行时进程能读到.env中的值即可。report_source的可选值在 gpt_researcher/utils/enum.py 中定义Azure 对应的字符串就是azure。执行用 report_sourceazure 实例化实例化GPTResearcher时把report_source传为azure官方文档给出的示例如下report GPTResearcher( queryWhat happened in the latest burning man floods?, report_typeresearch_report, report_sourceazure, )其中query和report_type换成你自己的查询与报告类型report_sourceazure是本文的关键参数。要拿到报告按项目中 Tailored Research 文档给出的通用运行方式执行conduct_research和write_reportfrom gpt_researcher import GPTResearcher import asyncio async def get_report(query: str) - str: researcher GPTResearcher(queryquery, report_typeresearch_report, report_sourceazure) await researcher.conduct_research() report await researcher.write_report() return report if __name__ __main__: query 基于我的文档告诉我什么 report asyncio.run(get_report(queryquery)) print(report)上面的query是示例值替换为你自己的问题。结果验证执行完成后write_report()返回报告文本print(report)打印的内容应当基于你容器中的文档而非公开网页。运行前可以对照下面几点确认配置是否正确环境变量已生效若连接字符串或容器名为空构造BlobServiceClient/ 获取容器客户端时会直接失败容器名正确加载器会调用list_blobs()列出容器内全部Blob 并逐一下载到本地临时目录实现见 gpt_researcher/document/azure_document_loader.py所以容器里放什么报告上下文就是什么不要把无关文件混入该容器Blob 命名安全加载器会拒绝绝对路径或包含..的 blob 名遇到时会抛出ValueError: Unsafe blob name: name。如果你的 blob 是带目录前缀的正常对象名不会触发该检查。报告生成并打印后任务即完成。支持的文档格式Azure 路径下载 blob 后复用的是与本地文档相同的DocumentLoader因此支持的格式与 Local Documents 文档所列一致PDF、纯文本、CSV、Excel、Markdown、PowerPoint 和 Word 文档。参考Azure Storage 官方文档本流程的三步原文Tailored Researchconduct_research/write_report的运行模式gpt_researcher/skills/researcher.py#L187-L195report_sourceazure分支的实现【免费下载链接】gpt-researcherAn autonomous agent that conducts deep research on any data using any LLM providers项目地址: https://gitcode.com/GitHub_Trending/gp/gpt-researcher创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表