Skip to content

Python: Log exception in planner. #6371

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

Merged
merged 3 commits into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions python/semantic_kernel/planners/plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from semantic_kernel import Kernel
from semantic_kernel.connectors.ai import PromptExecutionSettings
from semantic_kernel.exceptions import KernelInvokeException
from semantic_kernel.exceptions import KernelFunctionNotFoundError, KernelInvokeException, KernelPluginNotFoundError
from semantic_kernel.functions.function_result import FunctionResult
from semantic_kernel.functions.kernel_arguments import KernelArguments
from semantic_kernel.functions.kernel_function import KernelFunction
Expand Down Expand Up @@ -200,9 +200,12 @@ def metadata(self) -> KernelFunctionMetadata:
def set_available_functions(self, plan: "Plan", kernel: "Kernel", arguments: "KernelArguments") -> "Plan":
if len(plan.steps) == 0:
try:
pluginFunction = kernel.plugins[plan.plugin_name][plan.name]
plan.set_function(pluginFunction)
except Exception:
plugin_function = kernel.get_function(plan.plugin_name, plan.name)
plan.set_function(plugin_function)
except (KernelFunctionNotFoundError, KernelPluginNotFoundError) as exc:
logger.error(
f"Something went wrong when setting available functions in {self._plugin_name}.{self._name}:'{exc}'"
)
pass
else:
for step in plan.steps:
Expand Down
Loading