diff --git a/python/samples/concepts/search/bing_plugin_examples.py b/python/samples/concepts/search/bing_plugin_examples.py index 6482a3a6d707..dbe6b91e09ec 100644 --- a/python/samples/concepts/search/bing_plugin_examples.py +++ b/python/samples/concepts/search/bing_plugin_examples.py @@ -14,7 +14,7 @@ async def example1(kernel: Kernel, search_plugin_name: str): print("======== Bing and Google Search Plugins ========") question = "What's the largest building in the world?" - function = kernel.plugins[search_plugin_name]["search"] + function = kernel.get_function(plugin_name=search_plugin_name, function_name="search") result = await kernel.invoke(function, query=question) print(question) diff --git a/python/samples/learn_resources/serializing_prompts.py b/python/samples/learn_resources/serializing_prompts.py index 4ced1ee36936..9ade73ac575c 100644 --- a/python/samples/learn_resources/serializing_prompts.py +++ b/python/samples/learn_resources/serializing_prompts.py @@ -50,7 +50,9 @@ async def main(): plugin_name="ConversationSummaryPlugin", ) - summarize_function = kernel.plugins["ConversationSummaryPlugin"]["SummarizeConversation"] + summarize_function = kernel.get_function( + plugin_name="ConversationSummaryPlugin", function_name="SummarizeConversation" + ) # Create the history history = ChatHistory() diff --git a/python/semantic_kernel/connectors/ai/open_ai/const.py b/python/semantic_kernel/connectors/ai/open_ai/const.py index e8e89f0cc633..eaeaa0eddcec 100644 --- a/python/semantic_kernel/connectors/ai/open_ai/const.py +++ b/python/semantic_kernel/connectors/ai/open_ai/const.py @@ -4,4 +4,3 @@ DEFAULT_AZURE_API_VERSION: Final[str] = "2024-02-01" USER_AGENT: Final[str] = "User-Agent" -DEFAULT_CHAT_SYSTEM_PROMPT: Final[str] = "Assistant is a large language model." diff --git a/python/tests/unit/core_plugins/test_http_plugin.py b/python/tests/unit/core_plugins/test_http_plugin.py index 3c13eb38000e..ef156bddba50 100644 --- a/python/tests/unit/core_plugins/test_http_plugin.py +++ b/python/tests/unit/core_plugins/test_http_plugin.py @@ -21,10 +21,10 @@ async def test_it_can_be_imported(): kernel = Kernel() plugin = HttpPlugin() kernel.add_plugin(plugin, "http") - assert kernel.plugins["http"] is not None - assert kernel.plugins["http"].name == "http" - assert kernel.plugins["http"]["getAsync"] is not None - assert kernel.plugins["http"]["postAsync"] is not None + assert kernel.get_plugin(plugin_name="http") is not None + assert kernel.get_plugin(plugin_name="http").name == "http" + assert kernel.get_function(plugin_name="http", function_name="getAsync") is not None + assert kernel.get_function(plugin_name="http", function_name="postAsync") is not None @patch("aiohttp.ClientSession.get") diff --git a/python/tests/unit/core_plugins/test_math_plugin.py b/python/tests/unit/core_plugins/test_math_plugin.py index 28687d6da3af..d38b14da876f 100644 --- a/python/tests/unit/core_plugins/test_math_plugin.py +++ b/python/tests/unit/core_plugins/test_math_plugin.py @@ -15,10 +15,10 @@ def test_can_be_instantiated(): def test_can_be_imported(): kernel = Kernel() kernel.add_plugin(MathPlugin(), "math") - assert kernel.plugins["math"] is not None - assert kernel.plugins["math"].name == "math" - assert kernel.plugins["math"]["Add"] is not None - assert kernel.plugins["math"]["Subtract"] is not None + assert kernel.get_plugin(plugin_name="math") is not None + assert kernel.get_plugin(plugin_name="math").name == "math" + assert kernel.get_function(plugin_name="math", function_name="Add") is not None + assert kernel.get_function(plugin_name="math", function_name="Subtract") is not None @pytest.mark.parametrize( diff --git a/python/tests/unit/core_plugins/test_sessions_python_plugin.py b/python/tests/unit/core_plugins/test_sessions_python_plugin.py index 86a867fa8d9e..0334bdc90f36 100644 --- a/python/tests/unit/core_plugins/test_sessions_python_plugin.py +++ b/python/tests/unit/core_plugins/test_sessions_python_plugin.py @@ -30,8 +30,8 @@ def test_validate_endpoint(aca_python_sessions_unit_test_env): def test_it_can_be_imported(kernel: Kernel, aca_python_sessions_unit_test_env): plugin = SessionsPythonTool(auth_callback=test_auth_callback) assert kernel.add_plugin(plugin=plugin, plugin_name="PythonCodeInterpreter") - assert kernel.plugins["PythonCodeInterpreter"] is not None - assert kernel.plugins["PythonCodeInterpreter"].name == "PythonCodeInterpreter" + assert kernel.get_plugin(plugin_name="PythonCodeInterpreter") is not None + assert kernel.get_plugin(plugin_name="PythonCodeInterpreter").name == "PythonCodeInterpreter" @pytest.mark.asyncio diff --git a/python/tests/unit/core_plugins/test_text_memory_plugin.py b/python/tests/unit/core_plugins/test_text_memory_plugin.py index 7f377c57a416..6d3b21674225 100644 --- a/python/tests/unit/core_plugins/test_text_memory_plugin.py +++ b/python/tests/unit/core_plugins/test_text_memory_plugin.py @@ -36,7 +36,7 @@ def test_can_be_instantiated(memory: SemanticTextMemory): def test_can_be_imported(kernel: Kernel, memory: SemanticTextMemory): kernel.add_plugin(TextMemoryPlugin(memory), "memory_plugin") - assert not kernel.plugins["memory_plugin"]["recall"].is_prompt + assert not kernel.get_function(plugin_name="memory_plugin", function_name="recall").is_prompt @mark.asyncio diff --git a/python/tests/unit/core_plugins/test_text_plugin.py b/python/tests/unit/core_plugins/test_text_plugin.py index c7b67b5980b5..02f95db1b1ff 100644 --- a/python/tests/unit/core_plugins/test_text_plugin.py +++ b/python/tests/unit/core_plugins/test_text_plugin.py @@ -10,12 +10,12 @@ def test_can_be_instantiated(): def test_can_be_imported(kernel: Kernel): kernel.add_plugin(TextPlugin(), "text_plugin") - assert not kernel.plugins["text_plugin"]["trim"].is_prompt + assert not kernel.get_function(plugin_name="text_plugin", function_name="trim").is_prompt def test_can_be_imported_with_name(kernel: Kernel): kernel.add_plugin(TextPlugin(), "text") - assert not kernel.plugins["text"]["trim"].is_prompt + assert not kernel.get_function(plugin_name="text", function_name="trim").is_prompt def test_can_trim(): diff --git a/python/tests/unit/core_plugins/test_time_plugin.py b/python/tests/unit/core_plugins/test_time_plugin.py index a92713aad2eb..7f5693df00f5 100644 --- a/python/tests/unit/core_plugins/test_time_plugin.py +++ b/python/tests/unit/core_plugins/test_time_plugin.py @@ -15,9 +15,9 @@ def test_can_be_instantiated(): def test_can_be_imported(): kernel = sk.Kernel() kernel.add_plugin(TimePlugin(), "time") - assert kernel.plugins["time"] is not None - assert kernel.plugins["time"].name == "time" - assert kernel.plugins["time"]["now"] is not None + assert kernel.get_plugin(plugin_name="time") is not None + assert kernel.get_plugin(plugin_name="time").name == "time" + assert kernel.get_function(plugin_name="time", function_name="now") is not None def test_date(): diff --git a/python/tests/unit/kernel/test_kernel.py b/python/tests/unit/kernel/test_kernel.py index 207bed0ba9e2..45f8fc9c46f7 100644 --- a/python/tests/unit/kernel/test_kernel.py +++ b/python/tests/unit/kernel/test_kernel.py @@ -279,7 +279,7 @@ async def test_add_plugin_from_openai(mock_parse_openai_manifest, kernel: Kernel enable_dynamic_payload=True, ), ) - plugin = kernel.plugins["TestOpenAIPlugin"] + plugin = kernel.get_plugin(plugin_name="TestOpenAIPlugin") assert plugin is not None assert plugin.name == "TestOpenAIPlugin" assert plugin.functions.get("GetSecret") is not None @@ -295,7 +295,7 @@ def test_import_plugin_from_openapi(kernel: Kernel): plugin_name="TestOpenAPIPlugin", openapi_document_path=openapi_spec_file, ) - plugin = kernel.plugins["TestOpenAPIPlugin"] + plugin = kernel.get_plugin(plugin_name="TestOpenAPIPlugin") assert plugin is not None assert plugin.name == "TestOpenAPIPlugin" assert plugin.functions.get("GetSecret") is not None diff --git a/python/tests/unit/kernel/test_register_functions.py b/python/tests/unit/kernel/test_register_functions.py index 3207ca22c037..fa04bc75af4c 100644 --- a/python/tests/unit/kernel/test_register_functions.py +++ b/python/tests/unit/kernel/test_register_functions.py @@ -14,11 +14,11 @@ @pytest.mark.asyncio async def test_register_valid_native_function(kernel: Kernel, decorated_native_function: Callable): - kernel.add_function("TestPlugin", function=decorated_native_function) - registered_func = kernel.get_function("TestPlugin", "getLightStatus") + kernel.add_function(plugin_name="TestPlugin", function=decorated_native_function) + registered_func = kernel.get_function(plugin_name="TestPlugin", function_name="getLightStatus") assert isinstance(registered_func, KernelFunction) - assert kernel.plugins["TestPlugin"]["getLightStatus"] == registered_func + assert kernel.get_function(plugin_name="TestPlugin", function_name="getLightStatus") == registered_func func_result = await registered_func.invoke(kernel, KernelArguments(arg1="testtest")) assert str(func_result) == "test"