mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context In addition to the Python local process runtime, we're adding the ability to congfigure the Dapr runtime for Python SK processes. <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> ### Description The PR introduces: - The ability to configure the Dapr Runtime for Python processes - Adds a sample FastAPI app showing how to configure the Dapr runtime with a sample SK Python process (see the README for details on setup) - Adds some unit test coverage for the Dapr runtime - Closes #9355 <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄
28 lines
980 B
Python
28 lines
980 B
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
from typing import Any
|
|
|
|
from semantic_kernel.processes.kernel_process.kernel_process_edge import KernelProcessEdge
|
|
from semantic_kernel.processes.process_message import ProcessMessage
|
|
|
|
|
|
class ProcessMessageFactory:
|
|
"""Factory class for creating ProcessMessage instances."""
|
|
|
|
@staticmethod
|
|
def create_from_edge(edge: KernelProcessEdge, data: Any) -> ProcessMessage:
|
|
"""Creates a new ProcessMessage from a KernelProcessEdge."""
|
|
target = edge.output_target
|
|
parameter_value: dict[str, Any] = {}
|
|
if target.parameter_name is not None:
|
|
parameter_value[target.parameter_name] = data
|
|
|
|
return ProcessMessage(
|
|
source_id=edge.source_step_id,
|
|
destination_id=target.step_id,
|
|
function_name=target.function_name,
|
|
values=parameter_value,
|
|
target_event_id=target.target_event_id,
|
|
target_event_data=data,
|
|
)
|