提示
受到推崇的: 从 Work IQ 开发工具 开始,用于受支持的专业代码声明代理和插件方案。 请参阅 WIQD 快速入门。 基于工具包的说明仍然可用于需要它们的现有项目和工作流。 在选择工具之前,请检查 功能和目标体验支持 : WIQD 不面向自定义引擎代理。
可以通过添加功能或自定义操作来增强代理的能力。 可以通过启用内置功能(如 图像生成器 或 代码解释器)或添加 MCP 或 API 插件 作为自定义操作来增强代理。 本教程将添加一个 API 插件。 若要添加 MCP 服务器,请参阅 构建或重用 MCP 服务器 和从 MCP 服务器构建声明性代理插件。
重要
本指南假定你已完成使用 Microsoft 365 代理工具包和 JSON 创建声明性代理 教程。
将映像生成器添加到代理
图像生成器功能使代理能够根据用户提示生成图像。 要添加图像生成器,请执行以下操作:
打开文件
appPackage/declarativeAgent.json并将条GraphicArt目添加到数组中capabilities。 有关详细信息,请参阅 图形艺术对象。{ "name": "GraphicArt" }在 Microsoft 365 代理工具包的“ 生命周期 ”窗格中,选择 “预配”。
声明性代理可以在重新加载页面后生成图像。
注意
映像生成器不适用于 Microsoft 365 政府社区云高 (GCCH) 环境中的代理。
向代理添加代码解释器
代码解释器是一种高级工具,旨在通过 Python 代码解决复杂任务。
注意
在 GCCH 环境中,代码解释器仅适用于具有智能 智能 Microsoft 365 Copilot 副驾驶® 副驾驶®加载项许可证的用户。
打开文件
appPackage/declarativeAgent.json并将条CodeInterpreter目添加到数组中capabilities。{ "name": "CodeInterpreter" }有关详细信息,请参阅 代码解释器对象。
在 Agents Toolkit 的生命周期窗格中选择预配。
声明性代理在重新加载页面后具有代码解释器功能。
将 API 插件作为自定义操作添加到代理
API 插件允许代理与 REST API 交互,从而为代理添加新功能。
注意
GCCH 环境中不支持自定义操作。
在开始之前,创建一个名为 posts-api.ymlPosts API OpenAPI 说明文档的文件并添加代码。
在 Agents Toolkit 的“开发”窗格中选择“添加操作”。
选择“ 开始使用 OpenAPI 说明文档”。
选择“ 浏览 ”并浏览到文件
posts-api.yml。选择所有可用的 API,然后选择“ 确定”。
选择 manifest.json。
查看对话框中的警告。 准备好继续操作后,选择“ 添加”。
在 Agents Toolkit 的生命周期窗格中选择预配。
声明性代理有权访问您的插件内容,以便在您重新加载页面后生成其答案。
帖子 API OpenAPI 说明文档
以下 OpenAPI 说明适用于 JSONPlaceHolder API,这是一个免费的在线 REST API,可在需要一些虚假数据时使用。
openapi: '3.0.2'
info:
title: Posts API
version: '1.0'
servers:
- url: https://jsonplaceholder.typicode.com/
components:
schemas:
post:
type: object
properties:
userId:
type: integer
description: The ID of the user that authored the post.
id:
type: integer
title:
type: string
body:
type: string
user:
type: object
properties:
id:
type: integer
name:
type: string
username:
type: string
email:
type: string
phone:
type: string
website:
type: string
address:
$ref: '#/components/schemas/address'
company:
$ref: '#/components/schemas/company'
address:
type: object
properties:
street:
type: string
suite:
type: string
city:
type: string
zipcode:
type: string
geo:
$ref: '#/components/schemas/coordinates'
coordinates:
type: object
properties:
lat:
type: string
description: The latitude of the location
lng:
type: string
description: The longitude of the location
company:
type: object
properties:
name:
type: string
catchPhrase:
type: string
bs:
type: string
parameters:
post-id:
name: post-id
in: path
description: 'key: id of post'
required: true
style: simple
schema:
type: integer
user-id:
name: user-id
in: path
description: 'key: id of user'
required: true
style: simple
schema:
type: integer
paths:
/posts:
get:
description: Get posts
operationId: GetPosts
parameters:
- name: userId
in: query
description: Filter results by user ID
required: false
style: form
schema:
type: integer
maxItems: 1
- name: title
in: query
description: Filter results by title
required: false
style: form
schema:
type: string
maxItems: 1
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/post'
post:
description: 'Create post'
operationId: CreatePost
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/post'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/post'
/posts/{post-id}:
get:
description: 'Get post by ID'
operationId: GetPostById
parameters:
- $ref: '#/components/parameters/post-id'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/post'
patch:
description: 'Update post'
operationId: UpdatePost
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/post'
parameters:
- $ref: '#/components/parameters/post-id'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/post'
delete:
description: 'Delete post'
operationId: DeletePost
parameters:
- $ref: '#/components/parameters/post-id'
responses:
'200':
description: OK
/users:
get:
summary: Get users
description: Returns details about users
operationId: GetUsers
parameters:
- name: name
in: query
description: The user's real name
schema:
type: string
- name: username
in: query
description: The user's login name
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/user'
/users/{user-id}:
get:
description: 'Get user by ID'
operationId: GetUserById
parameters:
- $ref: '#/components/parameters/user-id'
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/user'
相关内容
你已完成智能 智能 Microsoft 365 Copilot 副驾驶® 副驾驶®的声明式代理指南。 熟悉声明式代理的功能后,可以在以下文章中了解有关声明式代理的详细信息。
- 使用 Microsoft 365 代理工具包和 TypeSpec 创建声明性代理
- 了解如何为您的代理 编写有效的说明 。
- 使用开发人员模式测试代理,以验证 Copilot 业务流程协调程序是否以及如何选择知识源以用于响应给定提示。 有关详细信息,请参阅使用 开发人员模式在 Microsoft 365 Agents Toolkit 中测试和调试代理。
- 获取 常见问题的解答。
- 了解构建声明式代理的其他方法:代理生成器中的无代码或 Copilot Studio 中的低代码。