Skip to content

Conversation

@mathetake
Copy link
Member

@mathetake mathetake commented Dec 1, 2025

Description
This consolidates all the copy-pasted processors that existed per endpoint we support into one generic processor. This was made possible thanks to the series of refactoring that we landed in the past few weeks primarily for dynamic module work #90.

Notably, now in order to add an endpoint, majority of the new code will be in translator (where also have shared generic interface) as well as the type definition. No longer it requires the huge copy paste of processors.

Related Issues/PRs (if applicable)

Resolves #1083
Blocker for #1429 #1584 #1592 #1594

@mathetake
Copy link
Member Author

wow cool all tests passing

@mathetake
Copy link
Member Author

Tomorrow i will backfill the tests and then good to go

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 97.47475% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.51%. Comparing base (6f312e5) to head (ff7a321).

Files with missing lines Patch % Lines
internal/extproc/processor_impl.go 97.11% 2 Missing and 1 partial ⚠️
internal/endpointspec/endpointspec.go 97.87% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1600      +/-   ##
==========================================
- Coverage   83.97%   83.51%   -0.47%     
==========================================
  Files         141      137       -4     
  Lines       13021    11934    -1087     
==========================================
- Hits        10935     9967     -968     
+ Misses       1463     1386      -77     
+ Partials      623      581      -42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake mathetake marked this pull request as ready for review December 2, 2025 19:04
@mathetake mathetake requested a review from a team as a code owner December 2, 2025 19:04
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Dec 2, 2025
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Copy link
Member Author

Choose a reason for hiding this comment

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

this is where I generalized the ChatCompletionsProcessor with a few type params, almost all the logic is the same

Copy link
Member Author

@mathetake mathetake Dec 2, 2025

Choose a reason for hiding this comment

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

all new endpoints will only touch this file by declaring one type implementing one small interface and that's it

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
@mathetake
Copy link
Member Author

Cool i came up with some cool trick while eating dinner and now we no longer need to touch internal/extproc AT ALL for adding endpoints!!!!!!!

func NewFactory[ReqT any, RespT any, RespChunkT any, EndpointSpecT endpointspec.Spec[ReqT, RespT, RespChunkT]](
f metrics.Factory,
tracer tracing.RequestTracer[ReqT, RespT, RespChunkT],
_ EndpointSpecT, // This is a type marker to bind EndpointSpecT without specifying ReqT, RespT, RespChunkT explicitly.
Copy link
Member Author

Choose a reason for hiding this comment

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

This is so cool

Copy link
Member

@nacx nacx left a comment

Choose a reason for hiding this comment

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

Nice!

@nacx
Copy link
Member

nacx commented Dec 3, 2025

/retest

@nacx nacx merged commit 6d7059c into main Dec 3, 2025
47 of 49 checks passed
@nacx nacx deleted the genericprocessor branch December 3, 2025 10:47
missBerg pushed a commit to missBerg/ai-gateway that referenced this pull request Dec 20, 2025
…xy#1600)

**Description**
This consolidates all the copy-pasted processors that existed per
endpoint we support into one generic processor. This was made possible
thanks to the series of refactoring that we landed in the past few weeks
primarily for dynamic module work envoyproxy#90.

Notably, now in order to add an endpoint, majority of the new code will
be in translator (where also have shared generic interface) as well as
the type definition. No longer it requires the huge copy paste of
processors.

**Related Issues/PRs (if applicable)**

Resolves envoyproxy#1083
Blocker for envoyproxy#1429 envoyproxy#1584 envoyproxy#1592 envoyproxy#1594

---------

Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Co-authored-by: Ignasi Barrera <ignasi@tetrate.io>
Signed-off-by: Erica Hughberg <erica.sundberg.90@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor processors code to share common logic

4 participants