Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: OpenAPI plugin updates to promote plugin to preview #9670

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

moonbox3
Copy link
Contributor

Motivation and Context

We currently handle OpenAPI plugins via the kernel, but in a pretty simple way. The changes in this PR are allowing one to define multiple server paths for an operation as well as configure security on the operations either at the operation level or at the "global" spec level (these are included as metadata in the kernel function parameter additional_parameters dict).

Description

Adds support for OpenAPI plugin:

  • allow for multiple servers for an API operation
  • allows one to define security configuration at the spec level as well as per operation level
  • fixes a bug where the excluded_operations on the execution settings were never checked during REST API operation building
  • adds the deprecated tag to the OpenAI plugin code as it was deprecated by OpenAI and we never handled it in SK Python.
  • adds unit tests

Contribution Checklist

@moonbox3 moonbox3 requested a review from a team as a code owner November 12, 2024 20:57
@moonbox3 moonbox3 self-assigned this Nov 12, 2024
@moonbox3 moonbox3 added the openapi Issues related to the OpenAPI function importer label Nov 12, 2024
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Nov 12, 2024
@moonbox3 moonbox3 changed the title Python: OpenAPI updates to support multiple operation servers & security config Python: OpenAPI plugin updates to promote plugin to preview Nov 15, 2024
@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report
FileStmtsMissCoverMissing
semantic_kernel
   kernel.py1994776%148, 159, 163, 313–316, 423, 437–480
semantic_kernel/agents/group_chat
   agent_chat.py124298%78, 171
   agent_group_chat.py100298%151, 201
   broadcast_queue.py72199%35
semantic_kernel/agents/open_ai
   assistant_content_generation.py141994%97–98, 329–337, 379, 381
   azure_assistant_agent.py107298%284, 304
   open_ai_assistant_agent.py105298%252, 272
   open_ai_assistant_base.py467898%260, 338–339, 747, 868, 871, 945, 1007
semantic_kernel/connectors/ai
   audio_to_text_client_base.py9189%51
   chat_completion_client_base.py116298%382, 392
   completion_usage.py8188%17
   text_to_audio_client_base.py8188%52
semantic_kernel/connectors/ai/anthropic/services
   anthropic_chat_completion.py176597%147, 165, 169, 223, 419
semantic_kernel/connectors/ai/azure_ai_inference/services
   azure_ai_inference_chat_completion.py119794%120, 146–149, 159, 180, 202
   azure_ai_inference_text_embedding.py41198%86
semantic_kernel/connectors/ai/bedrock/services
   bedrock_chat_completion.py1361490%117, 138, 163, 167–170, 228, 246–265, 324
   bedrock_text_completion.py57296%95, 118
   bedrock_text_embedding.py45198%94
semantic_kernel/connectors/ai/bedrock/services/model_provider
   bedrock_ai21_labs.py13192%67
   bedrock_anthropic_claude.py12192%54
   bedrock_cohere.py20195%75
   utils.py802075%68, 71, 102, 106–115, 132–150, 171–174
semantic_kernel/connectors/ai/embeddings
   embedding_generator_base.py8188%50
semantic_kernel/connectors/ai/google/google_ai/services
   google_ai_chat_completion.py119497%126, 152, 175, 177
   google_ai_text_completion.py63297%98, 121
   utils.py65395%139, 159–164
semantic_kernel/connectors/ai/google/vertex_ai/services
   utils.py66395%140, 160–165
   vertex_ai_chat_completion.py119497%121, 147, 170, 172
   vertex_ai_text_completion.py62297%95, 116
semantic_kernel/connectors/ai/hugging_face/services
   hf_text_completion.py60395%103, 112, 127
   hf_text_embedding.py32584%79–83
semantic_kernel/connectors/ai/mistral_ai/prompt_execution_settings
   mistral_ai_prompt_execution_settings.py33294%59–62
semantic_kernel/connectors/ai/mistral_ai/services
   mistral_ai_chat_completion.py1223670%119–122, 147–150, 180–184, 197–205, 221–229, 241–254, 260, 269–273, 318–321
   mistral_ai_text_embedding.py39197%108
semantic_kernel/connectors/ai/ollama/services
   ollama_chat_completion.py1071190%114, 139, 143–144, 154, 186, 223, 233–234, 256, 283
   ollama_text_completion.py57395%93, 103, 130
   utils.py462546%29, 44–52, 64–86, 98–102, 119–122
semantic_kernel/connectors/ai/onnx
   utils.py53394%50–51, 112
semantic_kernel/connectors/ai/onnx/services
   onnx_gen_ai_chat_completion.py72790%67–68, 98, 122, 167, 173, 179
   onnx_gen_ai_completion_base.py582164%59–71, 79–90
   onnx_gen_ai_text_completion.py46589%54–55, 87, 117, 133
semantic_kernel/connectors/ai/open_ai/prompt_execution_settings
   open_ai_prompt_execution_settings.py95199%117
   open_ai_text_to_audio_execution_settings.py17194%29
   open_ai_text_to_image_execution_settings.py36197%60
semantic_kernel/connectors/ai/open_ai/services
   azure_chat_completion.py103397%140, 149, 152
   open_ai_audio_to_text_base.py28389%37–38, 43
   open_ai_chat_completion_base.py127596%71, 121, 141, 177, 287
   open_ai_handler.py104892%134, 142–143, 159–160, 172, 181–182
   open_ai_text_completion_base.py80298%56, 161
   open_ai_text_to_audio_base.py25388%35–36, 41
semantic_kernel/connectors/ai/open_ai/settings
   azure_open_ai_settings.py24483%111–114
semantic_kernel/connectors/memory/azure_ai_search
   azure_ai_search_collection.py1343375%170, 172, 245–283, 293–303, 307, 311, 316–319
   azure_ai_search_store.py42295%130–131
   utils.py73790%125, 127, 129, 150–151, 154–155
semantic_kernel/connectors/memory/azure_cosmos_db
   azure_cosmos_db_no_sql_base.py49982%90, 93–94, 102, 112–116
   azure_cosmos_db_no_sql_collection.py1645964%98–99, 126–131, 145–150, 154–161, 172–186, 192–198, 204–208, 231–242, 246, 250, 274, 303, 307–312
   azure_cosmos_db_no_sql_store.py33682%91–96
   utils.py60788%41, 53, 67, 155, 169–172
semantic_kernel/connectors/memory/in_memory
   in_memory_collection.py1421689%65, 117, 119, 139, 149, 174, 189, 201, 219–222, 226, 228, 230–231
semantic_kernel/connectors/memory/qdrant
   qdrant_collection.py119497%187, 191, 320–321
   qdrant_store.py48296%139–140
semantic_kernel/connectors/memory/redis
   redis_collection.py2424781%173, 178–179, 190–200, 208–228, 231–238, 253–258, 262, 338, 375–382, 460, 482–489
   redis_store.py42295%108–109
   utils.py713255%153–154, 172, 174, 181–196, 203–233
semantic_kernel/connectors/memory/weaviate
   utils.py802272%92–97, 194, 243, 262, 269–272, 281–292
   weaviate_collection.py1937462%172–184, 188–201, 205–213, 224–241, 248–255, 264–284, 293–309, 313, 316–320, 364, 368–375, 390, 409, 425, 434–435, 441, 446
   weaviate_store.py591771%110–118, 122–127, 132–137, 142–143
semantic_kernel/connectors/openai_plugin
   openai_function_execution_parameters.py27196%45
semantic_kernel/connectors/openapi_plugin
   openapi_manager.py87792%68, 107–110, 155–156
   openapi_parser.py116794%70, 127, 191, 239–240, 243–244
   openapi_runner.py105298%177–178
semantic_kernel/connectors/openapi_plugin/models
   rest_api_operation.py2161991%101–102, 111–112, 121–122, 132, 141–142, 161–162, 171–172, 191–192, 234–237, 361
   rest_api_parameter.py952079%55, 64–65, 74–75, 84–85, 94–95, 114–115, 124–125, 134–135, 144–145, 150, 154–155
   rest_api_payload.py46687%46–47, 66–67, 76–77
   rest_api_payload_property.py701776%41–42, 51–52, 61–62, 71–72, 81–82, 91–92, 97, 101–102, 111–112
semantic_kernel/contents
   audio_content.py18194%53
   binary_content.py92298%170–171
   function_call_content.py100298%185, 213
   streaming_chat_message_content.py68199%210
   streaming_content_mixin.py39295%37, 64
semantic_kernel/core_plugins/sessions_python_tool
   sessions_python_plugin.py134894%69, 82–91, 99
   sessions_python_settings.py39490%84–87
semantic_kernel/data
   search_filter.py25196%7
semantic_kernel/data/record_definition
   vector_store_model_definition.py681775%66, 80–89, 101–106
   vector_store_record_utils.py28293%55, 57
semantic_kernel/data/text_search
   text_search.py72494%125, 165, 205, 293
   utils.py33779%23, 54–60, 69–70
   vector_store_text_search.py761778%167–174, 180–187, 192
semantic_kernel/data/vector_search
   vector_search_filter.py20195%6
   vector_text_search.py16194%45
   vectorizable_text_search.py15193%50
   vectorized_search.py15193%45
semantic_kernel/data/vector_storage
   vector_store.py16194%51
   vector_store_record_collection.py2532192%431, 491–495, 503–507, 548–552, 559–563
semantic_kernel/functions
   kernel_function_decorator.py98199%102
   kernel_function_from_method.py96199%153
   kernel_function_from_prompt.py154795%165–166, 180, 201, 219, 239, 322
   kernel_function_log_messages.py36683%37–43
   kernel_plugin.py201598%476, 479, 508, 529, 554
semantic_kernel/planners
   plan.py2344581%54, 163–165, 197, 214–227, 264, 269, 277–278, 288–291, 308, 313, 329, 332–337, 355, 360, 363, 365, 372, 386–388, 393–397
semantic_kernel/planners/function_calling_stepwise_planner
   function_calling_stepwise_planner.py116497%145, 189–190, 198
semantic_kernel/planners/sequential_planner
   sequential_planner.py64691%71, 75, 109, 125, 134–135
   sequential_planner_extensions.py50982%31–32, 56, 110–124
   sequential_planner_parser.py771284%66–74, 93, 117–120
semantic_kernel/processes
   process_builder.py714142%44–53, 57–59, 65–75, 79–88, 92–98, 102–106, 111, 115–120
   process_end_step.py19289%37, 41
   process_event.py15380%21, 26, 31
   process_function_target_builder.py27389%43–46
   process_step_builder.py1092577%45, 94, 108, 115–128, 140–147, 156, 165–175, 180, 194, 211
   process_step_edge_builder.py35391%43, 58, 68
   process_types.py25196%35
semantic_kernel/processes/dapr_runtime
   dapr_actor_registration.py261735%25–31, 37–42, 48–53
   dapr_kernel_process.py22291%26, 38
   dapr_kernel_process_context.py34294%25, 27
   dapr_process_info.py31487%25, 30, 40, 47
   dapr_step_info.py31294%30, 39
semantic_kernel/processes/dapr_runtime/actors
   event_buffer_actor.py521767%40–43, 65–68, 81–85, 89–92
   external_event_buffer_actor.py551278%52–55, 77–80, 103–106
   message_buffer_actor.py491276%39–42, 57–60, 74–77
   process_actor.py24211353%69–73, 78, 81, 87, 90, 94, 100, 103, 119–122, 127, 140, 156–160, 165, 175, 180, 189–197, 201–203, 211–219, 226, 242–303, 308, 319, 333–341, 344–351, 355–383, 414–427
   step_actor.py25014841%77–81, 86, 89, 93–94, 106–108, 152–155, 169–171, 176–250, 254–350, 354, 358–361, 365–381, 385–404, 408–426, 430–433, 437, 441–444
semantic_kernel/processes/kernel_process
   kernel_process_step_context.py20290%38, 41
semantic_kernel/processes/local_runtime
   local_kernel_process.py22291%24, 35
   local_kernel_process_context.py32294%66–67
   local_process.py1345261%92, 102, 120–130, 163–190, 194–199, 203, 207–213, 217–227, 231–232
   local_step.py16310039%61, 72, 81–169, 173, 177, 181–182, 187–249, 253–256, 260–263, 267–276, 282–285, 289–291
semantic_kernel/prompt_template
   kernel_prompt_template.py78791%144–151
semantic_kernel/schema
   kernel_json_schema_builder.py131993%54, 93, 189, 197, 208, 216, 231, 235–236
semantic_kernel/services
   ai_service_client_base.py22195%64
semantic_kernel/template_engine/blocks
   code_block.py77199%119
   named_arg_block.py43198%98
semantic_kernel/utils/authentication
   entra_id_authentication.py15287%26, 38
semantic_kernel/utils/telemetry
   user_agent.py16288%18–19
semantic_kernel/utils/telemetry/model_diagnostics
   decorators.py171498%364–367
TOTAL16325150391% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2912 4 💤 0 ❌ 0 🔥 1m 16s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openapi Issues related to the OpenAPI function importer python Pull requests for the Python Semantic Kernel
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants