Skip to content

Conversation

@sjrl
Copy link
Contributor

@sjrl sjrl commented Sep 16, 2025

Related Issues

Changes

  • Adds a on_pipeline_end callback to streaming_generator and async_streaming_generator. This callback is called on the final result returned to the pipeline allowing us to forward the final result of the pipeline to OpenWebUI via a StreamingChunk
  • Adds the function default_on_pipeline_end to serve as a default callback users can provide to streaming_generator and async_streaming_generator

Example

I added the function

    def on_pipeline_end(self, result: dict) -> str:
        documents = result.get("documents", [])
        references_str = f"\n\n### All Sources:\n"
        if documents:
            for idx, doc in enumerate(documents):
                references_str += f"- [{idx + 1}] {doc.meta['url']}\n"
        return references_str

to add a references section after the chat with website agent was finished

Screen.Recording.2025-10-10.at.10.44.59.mov

@sjrl sjrl force-pushed the return-pipeline-result-streaming branch from 1c53eb9 to 6821963 Compare October 8, 2025 12:20
@sjrl sjrl requested a review from mpangrazzi October 9, 2025 08:39
Copy link
Contributor

@mpangrazzi mpangrazzi left a comment

Choose a reason for hiding this comment

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

@sjrl I like the idea of the on_pipeline_end callback!

I've left some comments.

About tests: since now the on_pipeline_end callback is optional (which is good IMHO), why changing all the existing tests? Maybe we could revert this and add some specific tests with specific behaviours of that callback. WDYT?

@sjrl
Copy link
Contributor Author

sjrl commented Oct 10, 2025

@sjrl I like the idea of the on_pipeline_end callback!

I've left some comments.

About tests: since now the on_pipeline_end callback is optional (which is good IMHO), why changing all the existing tests? Maybe we could revert this and add some specific tests with specific behaviours of that callback. WDYT?

Sure happy to revert!

@sjrl sjrl marked this pull request as ready for review October 13, 2025 08:39
@sjrl sjrl requested a review from mpangrazzi October 13, 2025 08:39
Copy link
Contributor

@mpangrazzi mpangrazzi left a comment

Choose a reason for hiding this comment

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

Nice! 🚀

Would also ask if you can update the docs page about Open WebUI integration adding also info about this new callback. Would be great if you can also add the video (in gif) format into assets folder, showing it just after an example.

You can check out the docs contributing guide to run docs website locally (for development) and then deploy it!

@sjrl sjrl requested a review from mpangrazzi October 15, 2025 11:09
Copy link
Contributor

@mpangrazzi mpangrazzi left a comment

Choose a reason for hiding this comment

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

🙌

@sjrl sjrl merged commit 86d3003 into main Oct 15, 2025
5 checks passed
@sjrl sjrl deleted the return-pipeline-result-streaming branch October 15, 2025 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend streaming_generator to also return the Pipeline result

2 participants