Skip to content

Conversation

jonathan-buttner
Copy link

👋

Here's an example of what I was thinking to simplify things.

This leverages the StreamingErrorResponse class to always provide code(), param(), and type(). That makes creating the unified error easier.

I'll note a few places I think we can still refactor but I wanted to give this as an example.

String.valueOf(vertexAIErrorResponse.code()),
null
);
if (errorResponse instanceof StreamingErrorResponse streamingErrorResponse) {
Copy link
Author

Choose a reason for hiding this comment

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

I didn't go through the exercise to prove this out but I suspect that most of the *UnifiedChatCompletionResponseHandlers will have the exact same code as this implementation. So maybe we could move the contents into the BaseResponseHandler as a new method and have the buildError() override here have one line that simply class back into the base class.

Choose a reason for hiding this comment

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

Responded in original PR:
elastic#128923 (comment)

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.

2 participants