View a markdown version of this page

在截止日期云中使用 AI 代理 - 截止日期云

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

在截止日期云中使用 AI 代理

使用 AI 代理在 Deadline Cloud 中编写任务包、开发 conda 包以及对任务进行故障排除。本主题解释了什么是 AI 代理、有效使用它们的要点以及帮助代理了解 Deadline Cloud 的资源。

AI 代理是一种使用大型语言模型 (LLM) 自主执行任务的软件工具。AI 代理可以根据反馈读写文件、运行命令和迭代解决方案。示例包括命令行工具,例如 Kiro网站上的Kiro和助手。 IDE-integrated

与 AI 代理合作的要点

以下要点可帮助您在截止日期云中使用人工智能代理时获得更好的结果。

  • 提供基础 — AI 代理在能够访问相关文档、规范和示例时表现最佳。您可以通过将代理指向特定的文档页面、共享现有示例代码作为参考、将相关的开源存储库克隆到本地工作空间以及为第三方应用程序提供文档来提供基础知识。

  • 指定成功标准 — 定义代理的预期结果和技术要求。例如,当您要求代理开发任务包时,请指定任务输入、参数和预期输出。如果您不确定规格,请先要求代理商提出选项,然后共同完善要求。

  • 启用反馈回路 — 当人工智能代理可以测试解决方案并接收反馈时,他们可以更有效地进行迭代。与其在第一次尝试时就期待一个可行的解决方案,不如让代理能够运行其解决方案并查看结果。当代理可以访问状态更新、日志和验证错误时,这种方法效果很好。例如,当您开发任务包时,允许代理提交任务并查看日志。

  • 期望迭代 ——即使背景良好,代理也可能偏离正轨或做出与您的环境不匹配的假设。观察代理如何完成任务,并在此过程中提供指导。在代理遇到困难时添加缺失的上下文,通过指向特定的日志文件来帮助发现错误,在发现要求时完善要求,并添加负面要求以明确说明代理应避免的内容。

代理上下文资源

GitHub 网站上的以下资源可帮助 AI 代理了解 Deadline Cloud 的概念并生成准确的输出。

  • 截止日期云模型上下文协议 (MCP) 服务器 — 对于支持模型上下文协议的代理,截止日期云存储库包含截止日期云客户端,其中包括用于与任务交互的 MCP 服务器。

  • AWS 文档 MCP 服务器 — 对于支持 MCP 的代理,配置AWS 文档 MCP 服务器以允许代理直接访问 AWS 文档,包括 Deadline Cloud 用户指南和开发人员指南。

  • 空缺职位描述规范 - 空缺职位描述规范定义了作业模板的架构。当代理需要了解作业模板的结构和语法时,请参考存储库。

  • 截止日期云样本 — 截止日期云样本存储库包含示例任务包、conda 配方以及常见应用程序和 CloudFormation 用例的模板。

  • aws-deadline GitHub 组织 — aws-deadline GitHub 组织包含许多第三方应用程序的参考插件,您可以将其用作其他集成的示例。

示例提示:编写任务包

以下示例提示演示如何使用 AI 代理创建任务包,用于训练 LoRa(Low-Rank 适应)适配器以生成 AI 图像。该提示说明了前面讨论的要点:它通过指向相关的存储库来提供基础,定义任务包输出的成功标准,并概述了迭代开发的反馈回路。

Write a pair of job bundles for Deadline Cloud that use the diffusers Python library to train a LoRA adapter on a set of images and then generate images from it. Requirements: - The training job takes a set of JPEG images as input, uses an image description, LoRA rank, learning rate, batch size, and number of training steps as parameters, and outputs a `.safetensors` file. - The generation job takes the `.safetensors` file as input and the number of images to generate, then outputs JPEG images. The jobs use Stable Diffusion 1.5 as the base model. - The jobs run `diffusers` as a Python script. Install the necessary packages using conda by setting the job parameters: - `CondaChannels`: `conda-forge` - `CondaPackages`: list of conda packages to install For context, clone the following repositories to your workspace and review their documentation and code: - OpenJobDescription specification: https://github.com/OpenJobDescription/openjd-specifications/blob/mainline/wiki/2023-09-Template-Schemas.md - Deadline Cloud sample job bundles: https://github.com/aws-deadline/deadline-cloud-samples/tree/mainline/job_bundles - diffusers library: https://github.com/huggingface/diffusers Read through the provided context before you start. To develop a job bundle, iterate with the following steps until the submitted job succeeds. If a step fails, update the job bundle and restart the loop: 1. Create a job bundle. 2. Validate the job template syntax: `openjd check` 3. Submit the job to Deadline Cloud: `deadline bundle submit` 4. Wait for the job to complete: `deadline job wait` 5. View the job status and logs: `deadline job logs` 6. Download the job output: `deadline job download-output` To verify the training and generation jobs work together, iterate with the following steps until the generation job produces images that resemble the dog in the training data: 1. Develop and submit a training job using the training images in `./exdog` 2. Wait for the job to succeed then download its output. 3. Develop and submit a generation job using the LoRA adapter from the training job. 4. Wait for the job to succeed then download its output. 5. Inspect the generated images. If they resemble the dog in the training data, you're done. Otherwise, review the job template, job parameters, and job logs to identify and fix the issue.