Skip to content

[Platform] Use JSON Path to convert responses #136

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chr-hertel
Copy link
Contributor

@chr-hertel chr-hertel commented Jul 15, 2025

Q A
Bug fix? no
New feature? no
Docs? no
Issues
License MIT

This is the first draft of one idea to encapsulate the way json response are converted into DTOs using the new JSON Path component - in combination with using the Capability::OUTPUT_VECTOR to activate a centralized converter with low priority - see google example where a specific one still gets activated first.

In general the idea would be to define different, response type specific extractors, that can be re-used across bridges, configured or exchanged with custom ones. The embedding responses are def the easiest ones here, but work to get an idea of the concept - i hope. The goal would be to get rid off the ResponseConverter duplicates and on top have a centralized standard that works basically with the OpenAI contract - with the perspective of enabling more compatible platform/models out of the box, see #114

The weak spot here would be the centralization in combination with the capability check - but there are ways to solve that I guess.

WDYT?

image

@chr-hertel chr-hertel added Platform Issues & PRs about the AI Platform component RFC RFC = Request For Comments (proposals about features that you want to be discussed) labels Jul 15, 2025
@chr-hertel chr-hertel force-pushed the refactor-json-path-converter branch 3 times, most recently from ed6eaea to 7ec4f22 Compare July 15, 2025 23:52
@alexandre-daubois
Copy link
Member

alexandre-daubois commented Jul 16, 2025

I really like the idea! Know that if you manage to get a resource for the response, JsonPath uses JsonStreamer to optimize the part to actually decode. Just in case 🙂

Given that JsonPath is experimental, I'd suggest changing the composer constraint to 7.3.*. That's what we do in core because experimental components may not be compatible between their minor versions. I have no plan to change classes or signatures in the JsonPath component until it's stable release as I managed to make it RFC compliant lately with the exact same API. But better be safe than sorry!

@valtzu
Copy link
Contributor

valtzu commented Jul 16, 2025

Interesting approach!

Do we even need the platform-specific ResponseConverters if there's no platform-specific logic apart a custom json path? This path could be injected in PlatformFactory.


EDIT: ok hmm I guess the idea was to encapsulate the "protocol" in the converter to be reused in different platforms

@chr-hertel chr-hertel force-pushed the refactor-json-path-converter branch 2 times, most recently from 8b26c09 to 4387b79 Compare July 16, 2025 23:37
@chr-hertel
Copy link
Contributor Author

chr-hertel commented Jul 16, 2025

I'd suggest changing the composer constraint to 7.3.*

Thanks for that!

encapsulate the "protocol" in the converter to be reused in different platforms

exactly

@chr-hertel chr-hertel force-pushed the refactor-json-path-converter branch from 4387b79 to b820262 Compare July 16, 2025 23:44
@OskarStark
Copy link
Contributor

We just created some CHANGELOG.md files.
Please rebase your branch and add info to the appropriate CHANGELOG.md file.

Thanks

Base automatically changed from refactor-decouple-client-converter to main July 17, 2025 20:10
@chr-hertel chr-hertel self-assigned this Jul 19, 2025
@chr-hertel chr-hertel force-pushed the refactor-json-path-converter branch from b820262 to e72b08c Compare July 19, 2025 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Issues & PRs about the AI Platform component RFC RFC = Request For Comments (proposals about features that you want to be discussed)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants