Microsoft 365 Agents Toolkit で作成された宣言型エージェントに機能とカスタム アクションを追加する

ヒント

推奨事項: サポートされているプロコード宣言型エージェントとプラグイン シナリオ用の Work IQ 開発ツール から始めます。 WIQD クイックスタートを参照してください。 Toolkit ベースの手順は、それらを必要とする既存のプロジェクトおよびワークフローで引き続き使用できます。 ツールを選択する前に 、機能とターゲット エクスペリエンスのサポート を確認します。WIQD はカスタム エンジン エージェントを対象としません。

機能またはカスタム アクションを追加することで、エージェントの機能を強化できます。 画像ジェネレーターやコード インタープリターなどの組み込み機能を有効にしたり、MCP または API プラグインをカスタム アクションとして追加したりすることで、エージェントを強化できます。 このチュートリアルでは、API プラグインを追加します。 MCP サーバーを追加するには、「 MCP サーバーの構築または再利用 」および 「MCP サーバーから宣言型エージェントのプラグインを構築する」を参照してください。

重要

このガイドは、「 Microsoft 365 Agents Toolkit と JSON を使用して宣言型エージェントを作成する 」チュートリアルを完了していることを前提としています。

エージェントに画像ジェネレーターを追加する

画像生成機能を使用すると、エージェントはユーザー プロンプトに基づいて画像を生成できます。 画像ジェネレーターを追加するには:

  1. appPackage/declarativeAgent.json ファイルを開き、GraphicArt エントリをcapabilities配列に追加します。 詳細については、「 グラフィック アート オブジェクト」を参照してください。

    {
      "name": "GraphicArt"
    }
    
  2. Microsoft 365 Agents Toolkit の [ライフサイクル ] ウィンドウで、[ プロビジョニング] を選択します。

宣言型エージェントは、ページを再読み込みした後に画像を生成できます。

注

Image Generator は、Microsoft 365 Government Community Cloud High (GCCH) 環境のエージェントでは使用できません。

生成されたグラフィック アートを含む宣言型エージェントからの応答を示すスクリーンショット

エージェントにコード インタープリターを追加する

コード インタープリターは、Python コードを介して複雑なタスクを解決するために設計された高度なツールです。

注

GCCH 環境では、コード インタープリターは Microsoft 365 Copilot アドオン ライセンスを持つユーザーのみが使用できます。

  1. appPackage/declarativeAgent.json ファイルを開き、CodeInterpreter エントリをcapabilities配列に追加します。

    {
      "name": "CodeInterpreter"
    }
    

    詳細については、「 コード インタープリター オブジェクト」を参照してください。

  2. Agents Toolkit の [ライフサイクル] ウィンドウで [プロビジョニング] を選択します。

宣言型エージェントには、ページを再読み込みした後のコード インタープリター機能があります。

生成されたグラフを含む宣言型エージェントからの応答を示すスクリーンショット

要求されたグラフの生成に使用される Python コードを示すスクリーンショット

カスタム アクションとして API プラグインをエージェントに追加する

API プラグインは、エージェントが REST API と対話できるようにすることで、エージェントに新しい機能を追加します。

注

カスタム アクションは、GCCH 環境ではサポートされていません。

始める前に、 posts-api.yml という名前のファイルを作成し、 Posts API OpenAPI の説明ドキュメントからコードを追加します。

  1. エージェント ツールキットの [開発] ウィンドウで [アクションの追加] を選択します。

  2. [ OpenAPI の説明ドキュメントで開始する] を選択します。

  3. [ 参照 ] を選択し、 posts-api.yml ファイルを参照します。

  4. 使用可能なすべての API を選択し、[ OK] を選択します。

    Visual Studio Code の API 選択ダイアログのスクリーンショット

  5. [ manifest.json] を選択します。

  6. ダイアログで警告を確認します。 続行する準備ができたら、[ 追加] を選択します。

  7. Agents Toolkit の [ライフサイクル] ウィンドウで [プロビジョニング] を選択します。

宣言型エージェントは、プラグイン コンテンツにアクセスして、ページを再読み込みした後に回答を生成できます。

API プラグイン コンテンツを含む宣言型エージェントからの応答を示すスクリーンショット

Posts API OpenAPI の説明ドキュメント

次の OpenAPI の説明は、偽のデータが必要なときにいつでも使用できる無料のオンライン REST API である JSONPlaceHolder 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 の宣言型エージェント ガイドを完了しました。 宣言型エージェントの機能を理解したら、次の記事で宣言型エージェントについて詳しく学習できます。