Mixing Semantic and Native Functions in a Plugin Class (Python) #11031
-
Hello, Is there a good pattern for how to mix semantic functions (functions sourced from a prompt or PromptTemplateConfig) with native functions that use the @kernel_function decorator in one plugin class? Either language works, focused on Python |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You could import the native functions in one plugin and load functions in another plugin and then create a plugin to combine the two. |
Beta Was this translation helpful? Give feedback.
-
@haithamshahin333, it can be handled like this: prompt_func = KernelFunctionFromPrompt(
function_name="world",
prompt="Tell me something interesting about the world",
)
@kernel_function
def get_weather(self, location: str) -> str:
"""Get the weather for a given location."""
return f"The weather in {location} is sunny."
kernel.add_functions(plugin_name="SomePlugin", functions=[prompt_func, get_weather]) Those two functions get grouped under the plugin with the name |
Beta Was this translation helpful? Give feedback.
@haithamshahin333, it can be handled like this:
Those two functions get grouped under the plugin with the name
SomePlugin
.