Skip to content

Latest commit

 

History

History
56 lines (38 loc) · 3.44 KB

File metadata and controls

56 lines (38 loc) · 3.44 KB

Challenge 04 - Import Plugin using OpenAPI

Introduction

OpenAPI is a widely adopted standard for describing RESTful APIs in a way that is both human-readable and machine-friendly. It streamlines API integration by providing automatic documentation, client SDK generation, and reduced manual coding efforts. By leveraging OpenAPI specifications, Semantic Kernel can dynamically load external services as plugins, letting your AI-driven apps discover, invoke, and orchestrate these APIs more effectively.

As developers, we can enrich our applications by integrating various APIs through OpenAPI specifications. In this challenge, you will learn how to import the provided WorkItems API as an OpenAPI plugin in Semantic Kernel and interact with it through AI-driven prompts.

NOTE: You have an existing OpenAPI spec for the WorkItems API. Make sure to locate it and use it when configuring your Semantic Kernel plugin.

Description

This challenge will introduce you to how to import OpenAPI API as Semantic Kernels Plugins in Python, and how to chain plugins using the Auto Function Calling capabilities of Semantic Kernel.

  1. Launch your AI Chat app, and ask the bot What are my work items?
    • Test the prompt "What are my work items?" see how it responds.
  2. You will be adding a new plugin to your Semantic Kernel using the API provided in the workshop. API can be found in workitems folder inside Python folder.
    • Start the uvicorn app

      • Go to Python/workitems folder
      • Run python api.py on command prompt
      • Find the OpenAPI spec in following path http://127.0.0.1:8000/openapi.json
      • Swagger page can be found in http://127.0.0.1:8000/docs
    • Import the API into Semantic Kernel.

      💡 Adding the OpenAPI plugin

      kernel.add_plugin_from_openapi(
          plugin_name="get_tasks",
          openapi_document_path="http://127.0.0.1:8000/openapi.json",
          execution_settings=OpenAPIFunctionExecutionParameters(
              enable_payload_namespacing=True,
          )
      )

      ❗ Semantic Kernel SDK for OpenAPI's - your plugin name must be 64 characters or less.

    • Test the prompt "What are my work items?" see how it responds.

  3. (Optional) Do you have another API you would like to integrate with? Try importing it as a plugin.

Success Criteria

  1. Your chat bot should be able to answer the question "What are my work items?" with a list of work items from the API.
  2. You can ask the bot to filter, sort, group, or change the display format of the work items.
  3. (Optional) Test other CRUD operations on the WorkItems API and try chaining multiple operations together.

Additional Learning Resources

Add Logic Apps as plugins

OpenApiFunctionExecutionParameters