可以通过添加技能来增强代理的能力。 可以通过启用内置功能(如 图像生成器 或 代码解释器)或添加 API 插件 作为自定义作来添加技能。
重要
本指南假定你已完成 使用 Microsoft 365 代理工具包创建声明性代理 教程。
将映像生成器添加到代理
映像生成器功能使代理能够根据用户提示生成图像。
打开 文件,
appPackage/declarativeAgent.json
并将GraphicArt
条目添加到数组。capabilities
{ "name": "GraphicArt" }
有关详细信息,请参阅 图形艺术对象。
在代理工具包的“生命周期”窗格中选择“预配”。
声明性代理将能够在重新加载页面后生成图像。
将代码解释器添加到代理
代码解释器是一种高级工具,旨在通过 Python 代码解决复杂任务。
打开 文件,
appPackage/declarativeAgent.json
并将CodeInterpreter
条目添加到数组。capabilities
{ "name": "CodeInterpreter" }
有关详细信息,请参阅 代码解释器对象。
在代理工具包的“生命周期”窗格中选择“预配”。
重新加载页面后,声明性代理将具有代码解释器功能。
将 API 插件作为自定义作添加到代理
API 插件通过允许代理与 REST API 交互,将新功能添加到代理。
在开始之前,请创建一个名为 posts-api.yml
的文件,并从 帖子 API OpenAPI 说明文档中添加代码。
在“代理工具包”的“开发”窗格中选择“添加作”。
选择 “使用 OpenAPI 说明文档开始”。
选择“ 浏览 ”并浏览到该文件
posts-api.yml
。选择所有可用的 API,然后选择“ 确定”。
选择 “manifest.json”。
查看对话框中的警告。 准备好继续时,请选择“ 添加”。
在代理工具包的“生命周期”窗格中选择“预配”。
声明性代理将有权访问插件内容,以在重新加载页面后生成其答案。
发布 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 副驾驶®的声明性代理指南。 熟悉声明性代理的功能后,可以在以下文章中详细了解声明性代理。
- 了解如何 使用 TypeSpec 生成声明性代理。
- 了解如何为代理 编写有效的说明 。
- 使用 Copilot 开发人员模式 测试代理,以验证 copilot 业务流程协调程序是否以及如何选择要用于响应给定提示的知识源。
- 获取 常见问题解答。
- 了解使用 Copilot Studio 代理生成器生成声明性代理的替代方法。