Skip to main content
本指南将帮助您迁移代码库以适应 Agno 发布伴随的主要重构。

通用命名空间更新

此重构包括对命名空间的全面更新,以提高清晰度和一致性。请密切关注以下更改:
  • 所有 phi 命名空间现已替换为 agno,以反映更新后的结构。
  • 子模块和类已重命名,以更好地代表其功能和上下文。

接口更改

模块和命名空间更新

  • Models:
    • phi.model.xagno.models.x
      • 所有模型类现在都位于 agno.models 命名空间下,将相关功能集中在同一个位置。
  • Knowledge Bases:
    • phi.knowledge_base.xagno.knowledge.x
      • 知识库已进行了重构,以便在 agno.knowledge 下更好地组织。
  • Document Readers:
    • phi.document.reader.xxxagno.document.reader.xxx_reader
      • 文档阅读器现在包含一个 _reader 后缀,以增强清晰度和一致性。
  • Toolkits:
    • 所有 Agno 工具包现在都有一个 Tools 后缀。例如:DuckDuckGoDuckDuckGoTools
      • 此更改标准化了工具的命名,使其用途更加明确。

多模态接口更新

多模态接口现在使用特定类型来处理不同的媒体输入和输出:

输入

  • Images:
    • 现在使用专门的 Image 类来表示图像,为图像处理提供额外的元数据和控制。
  • Audio:
    • 音频文件通过 Audio 类处理,允许指定内容和格式。
  • Video:
    • 视频拥有自己的 Video 类,能够更好地处理视频数据。

输出

  • RunResponse 现在包含更新的工件类型:
    • RunResponse.imagesImageArtifact 类型的列表:
    • RunResponse.audioAudioArtifact 类型的列表:
    • RunResponse.videosVideoArtifact 类型的列表:
    • RunResponse.response_audioAudioOutput 类型:
      • 此响应音频对应于模型以音频格式的响应。

模型名称更改

  • HermesOllamaHermes
  • AzureOpenAIChatAzureOpenAI
  • CohereChatCohere
  • DeepSeekChatDeepSeek
  • GeminiOpenAIChatGeminiOpenAI
  • HuggingFaceChatHuggingFace
例如:

Storage 类更新

  • Agent Storage:
    • PgAgentStoragePostgresAgentStorage
    • SqlAgentStorageSqliteAgentStorage
    • MongoAgentStorageMongoDbAgentStorage
    • S2AgentStorageSingleStoreAgentStorage
  • Workflow Storage:
    • SqlWorkflowStorageSqliteWorkflowStorage
    • PgWorkflowStoragePostgresWorkflowStorage
    • MongoWorkflowStorageMongoDbWorkflowStorage

Knowledge Base 更新

  • phi.knowledge.pdf.PDFUrlKnowledgeBaseagno.knowledge.pdf_url.PDFUrlKnowledgeBase
  • phi.knowledge.csv.CSVUrlKnowledgeBaseagno.knowledge.csv_url.CSVUrlKnowledgeBase

Embedders 更新

Embedders 现在都接受 id 作为参数,而不是 model。例如:
  • OllamaEmbedder(model="llama3.2") -> OllamaEmbedder(id="llama3.2")

Reader 更新

  • phi.document.reader.arxivagno.document.reader.arxiv_reader
  • phi.document.reader.docxagno.document.reader.docx_reader
  • phi.document.reader.jsonagno.document.reader.json_reader
  • phi.document.reader.pdfagno.document.reader.pdf_reader
  • phi.document.reader.s3.pdfagno.document.reader.s3.pdf_reader
  • phi.document.reader.s3.textagno.document.reader.s3.text_reader
  • phi.document.reader.textagno.document.reader.text_reader
  • phi.document.reader.websiteagno.document.reader.website_reader

Agent 更新

  • guidelines, prevent_hallucinations, prevent_prompt_leakage, limit_tool_access, 和 task 已从 Agent 类中移除。您可以根据需要将它们纳入 instructions 参数中。
例如:

CLI 和基础设施更新

命令行界面更改

Agno CLI 已从 phi 重构为 ag。以下是主要更改:
现在必须使用命令 ag ws up devag ws up prod 来分别在开发模式和生产模式下启动工作空间,而不是使用 ag ws up

新增命令

  • ag ping -> 检查您是否已通过身份验证

移除命令

  • phi ws setup -> 已被 ag setup 取代

基础设施路径更改

已对与基础设施相关的代码进行了重新组织,以提高清晰度:
  • Docker Infrastructure: 已移至 /libs/infra/agno_docker 中的一个单独包,并有一个单独的 PyPi 包 agno-docker
  • AWS Infrastructure: 已移至 /libs/infra/agno_aws 中的一个单独包,并有一个单独的 PyPi 包 agno-aws
我们建议在您打算使用 Agno 部署到 AWS 的应用程序中安装这些包,或者如果您是从 Phidata 应用程序迁移。 具体路径更改如下:
  • import phi.aws.resource.xxximport agno.aws.resource.xxx
  • import phi.docker.xxximport agno.docker.xxx

请按照上述步骤确保您的代码库与最新版本的 Agno AI 兼容。如果您遇到任何问题,请随时通过 DiscourseDiscord 与我们联系。