Skip to content

[python][examples] Add quickstart workflow examples - #158

Merged
Sxnan merged 3 commits into
apache:mainfrom
Sxnan:workflow-quickstart
Sep 18, 2025
Merged

Sxnan merged 3 commits into
apache:mainfrom
Sxnan:workflow-quickstart

Conversation

@Sxnan

@Sxnan Sxnan commented Sep 11, 2025

Copy link
Copy Markdown
Contributor

Purpose of change

This PR introduces a comprehensive quickstart workflow for Flink Agents with practical examples demonstrating how to integrate LLM-powered agents with Flink streaming pipelines. The changes include:

  1. Two complete example workflows:

    • product_review_analysis.py: A simple streaming pipeline that analyzes product reviews using an LLM agent to extract review scores and unsatisfied reasons
    • product_improve_suggestion.py: A more complex multi-stage pipeline that aggregates review analysis results and generates product improvement suggestions
  2. Agent implementations:

    • ReviewAnalysisAgent: Analyzes individual product reviews
    • ProductSuggestionAgent: Generates improvement suggestions based on aggregated review data
  3. Sample data: Product review data in JSON format for testing the examples

These examples serve as a practical entry point for users to understand how to build streaming applications that leverage LLM agents for real-time data processing and analysis.

Tests

API

This change does not modify any public APIs. It only adds example code that demonstrates usage of existing Flink Agents APIs

Documentation

@Sxnan
Sxnan force-pushed the workflow-quickstart branch from 8fbfae5 to 8af3767 Compare September 11, 2025 03:32
Comment on lines +139 to +146
aggregated_analysis_res_stream = (
review_analysis_res_stream.key_by(lambda x: x.id)
.window(TumblingProcessingTimeWindows.of(Time.minutes(1)))
.process(AggregateScoreDistributionAndDislikeReasons())
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can convert the output of ReviewAnalysisAgent into a table, and apply some event-time windowing. The purpose is to show how to integrate the agent with not only datastream but also table api, and event-time is more frequently used by flink users.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that the ActionExecutionOperator cannot properly work with event time at the moment. I created an issue for it. #178

The aggregation of the review analysis results is not trivial. We may do that in a follow-up PR. I created a follow-up issue. #179

WDYT?

@Sxnan
Sxnan marked this pull request as ready for review September 12, 2025 02:21
@xintongsong xintongsong added this to the 0.1.0 milestone Sep 12, 2025
@Sxnan
Sxnan force-pushed the workflow-quickstart branch from 71468da to 71e68b4 Compare September 16, 2025 09:59
@Sxnan

Sxnan commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

@xintongsong Thanks for the review! All the comments are addressed. Please take another look.

@Sxnan
Sxnan requested a review from xintongsong September 16, 2025 10:04

@xintongsong xintongsong left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please merge after resolving the conflicts.

@Sxnan
Sxnan force-pushed the workflow-quickstart branch from 71e68b4 to 338074d Compare September 18, 2025 01:39
@Sxnan

Sxnan commented Sep 18, 2025

Copy link
Copy Markdown
Contributor Author

Conflict resolved, merging...

@Sxnan
Sxnan merged commit 401b928 into apache:main Sep 18, 2025
@Sxnan Sxnan added priority/major Default priority of the PR or issue. fixVersion/0.1.0 The feature or bug should be implemented/fixed in the 0.1.0 version. doc-not-needed Your PR changes do not impact docs labels Nov 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs fixVersion/0.1.0 The feature or bug should be implemented/fixed in the 0.1.0 version. priority/major Default priority of the PR or issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants