GitHub user rosemarYuan edited a comment on the discussion: [Discussion] 
Trigger action by Event Field Values

With #709 (Cross Language Actions) merged into `main`, this proposal is now 
described against the updated `@Action` API shape. The following section 
outlines the API design after that merge, with one key separation of concerns:

CEL trigger conditions and cross-language dispatch are orthogonal:
- `value()` decides **when** an action should fire.
- `target` decides **where** the action should execute.

#### Java declaration with Python execution
```java
// CEL trigger; execution is delegated to the Python target.
@Action(
    value = "type == EventType.ChatResponseEvent && request_sender == 
'PlannerAction'",
    target = @PythonFunction(
        module = "my_module",
        qualname = "handle_planner_response"
    )
)
public static void handlePlannerResponseStub(Event event, RunnerContext ctx) {
    // Body is unused when target is set; dispatch routes to Python.
}
```

#### Python declaration with Java execution
```python
from flink_agents.api.function import JavaFunction
# CEL trigger; execution is delegated to the Java target.
@action(
    "type == EventType.ChatResponseEvent && request_sender == 'PlannerAction'",
    target=JavaFunction(
        qualname="com.example.PlannerHandler",
        method_name="handlePlannerResponse",
    ),
)
def handle_planner_response_stub(event, ctx):
    raise NotImplementedError  # Body is unused when target is set.
```
For same-language actions, the API remains unchanged from the original design: 
users declare CEL trigger conditions through `value()` and simply leave 
`target` unset.

GitHub link: 
https://github.com/apache/flink-agents/discussions/726#discussioncomment-17160461

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: [email protected]

Reply via email to