fix(cody-gateway): streaming google endpoint#63306
Conversation
…eaming The changes in this commit fix the `ShouldStream()` method of the `googleRequest` struct to always return `true`, until we support Code Completions for Google models on the client side. This change ensures that the Cody Gateway always streams responses for Google model completions, regardless of the `Stream` field in the request.
chrsmith
left a comment
There was a problem hiding this comment.
I don't know enough about what this ShouldStream() function does, or how it relates to the way that we send requests to Cody Gateway to approve this...
It seems like this might have some unintentional consequences? 😬
If you know what you are doing, I'm happy to trust you. But perhaps it might be worth adding some unit tests or something to confirm that this does the right thing for the Google upstream provider? e.g. does this impact how we make the API request to Google?
|
I think the best/easiest way to do this might unfortunately be via the URL detection mechanism we talked about @abeatrix |
|
Here's a proposed path forward: In Cody gateway..
Since the Googe backend provider will already (before your changes) send Cody gateway a URL with that gRPC method at the end of the path, you can check it being there ike that^ and you just need a way for your In the snippet above, I just used Then I think you would not need most (maybe all?) of the other changes in this PR and it'd be a bit cleaner |
Issue: Currently, the ShouldStream() method will always returns false because the Stream value is removed before it was passed into the Handler.
To fix this, we will store the original googleRequest.Stream value if it's true so that ShouldStream() will return the correct Stream value. We will also use the transformBody method to remove the Stream value before we send it to Google API.
Here is the expected behaviour after the stream is fixed:
Screen.Recording.2024-06-18.at.9.22.51.AM.mov
Also confirmed it works with both Cody Gateway and BYOK:
Test plan
Always stream Cody Gateway's requests for Google Gemini models as we haven't implemented Code Completion feature on the client side.
Non-stream request
Streaming request:
Changelog