feat: add Gemini backend support #93
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant changes to the
internal/cli/cli.go
file to add support for a new backend, Gemini, alongside the existing OpenAI backend. It also includes the implementation of the Gemini client and its associated tests. Below are the most important changes:CLI Enhancements:
backend
flag to specify the backend to use, eitheropenai
orgemini
. (internal/cli/cli.go
) [1] [2]Run
method to select the appropriate translator based on thebackend
flag and set the corresponding API key environment variable. (internal/cli/cli.go
)Gemini Client Implementation:
GeminiTranslator
struct and implemented therequest
method to interact with the Gemini API. (internal/cli/cli.go
)internal/gemini
package, which includes theClient
,Payload
,Message
, andResponse
types, as well as methods for creating a new client and sending chat requests. (internal/gemini/client.go
)Testing:
internal/gemini/client_test.go
)internal/gemini/testdata/gemini_success.json
)Code Cleanup and Documentation:
internal/cli/cli.go
file. (internal/cli/cli.go
) [1] [2] [3]internal/cli/cli.go
) [1] [2]These changes collectively enhance the CLI tool by adding support for the Gemini backend, improving code readability, and ensuring robust testing for the new functionality.