Skip to content

Commit

Permalink
feat: use gemini as name not google
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmcguire1 committed Dec 14, 2023
1 parent 2cce81d commit f2d2bca
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cmd/sqs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func main() {
h := &SqsHandler{
ChatModelSvc: chatmodels.NewClient(&chatmodels.Resources{
GPTApi: chatmodels.NewOpenAiApiClient(os.Getenv("OPENAI_API_KEY")),
GoogleAPI: chatmodels.NewGeminiApiClient(os.Getenv("GEMINI_API_KEY")),
GeminiAPI: chatmodels.NewGeminiApiClient(os.Getenv("GEMINI_API_KEY")),
}),
ResponseQueue: queue.NewQueue(os.Getenv("RESPONSES_QUEUE_URI")),
Logger: logger,
Expand Down
4 changes: 2 additions & 2 deletions internal/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func (h *Handler) DispatchIntents(ctx context.Context, req alexa.Request) (res a
h.Logger.With("prompt", prompt).Info("found phrase to autocomplete")

switch prompt {
case "use google":
h.Model = chatmodels.CHAT_MODEL_GOOGLE
case "use gemini":
h.Model = chatmodels.CHAT_MODEL_GEMINI
res = alexa.NewResponse("Autocomplete", "ok", false)
return
case "use gpt":
Expand Down
6 changes: 3 additions & 3 deletions internal/dom/chatmodels/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ type GptAPI interface {
AutoComplete(context.Context, string) (openai.ChatCompletionResponse, error)
}

type GoogleApi interface {
GoogleChat(context.Context, string) (*genai.GenerateContentResponse, error)
type GeminiAPI interface {
GeminiChat(context.Context, string) (*genai.GenerateContentResponse, error)
}

type mockAPI struct {
Expand All @@ -26,7 +26,7 @@ func (api *mockAPI) AutoComplete(ctx context.Context, prompt string) (res openai
return res, args.Error(1)
}

func (api *mockAPI) GoogleChat(ctx context.Context, prompt string) (res *genai.GenerateContentResponse, err error) {
func (api *mockAPI) GeminiChat(ctx context.Context, prompt string) (res *genai.GenerateContentResponse, err error) {
args := api.Called(ctx, prompt)
res = args.Get(0).(*genai.GenerateContentResponse)
return res, args.Error(1)
Expand Down
2 changes: 1 addition & 1 deletion internal/dom/chatmodels/gemini_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewGeminiApiClient(token string) *GeminiApiClient {
}
}

func (api *GeminiApiClient) GoogleChat(ctx context.Context, prompt string) (*genai.GenerateContentResponse, error) {
func (api *GeminiApiClient) GeminiChat(ctx context.Context, prompt string) (*genai.GenerateContentResponse, error) {
client, err := genai.NewClient(ctx, option.WithAPIKey(api.Token))
if err != nil {
log.Fatal(err)
Expand Down
2 changes: 1 addition & 1 deletion internal/dom/chatmodels/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package chatmodels
type ChatModel string

const (
CHAT_MODEL_GOOGLE ChatModel = "google"
CHAT_MODEL_GEMINI ChatModel = "gemini"
CHAT_MODEL_GPT ChatModel = "gpt"
)

Expand Down
4 changes: 2 additions & 2 deletions internal/dom/chatmodels/prompts.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

func (client *Client) AutoComplete(ctx context.Context, prompt string, model ChatModel) (string, error) {
switch model {
case CHAT_MODEL_GOOGLE:
res, err := client.GoogleAPI.GoogleChat(ctx, prompt)
case CHAT_MODEL_GEMINI:
res, err := client.GeminiAPI.GeminiChat(ctx, prompt)
if err != nil {
return "", err
}
Expand Down
6 changes: 3 additions & 3 deletions internal/dom/chatmodels/prompts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ func TestGeminiChat(t *testing.T) {
},
PromptFeedback: nil,
}
api.On("GoogleChat", mock.Anything, "steve").Return(mockResponse, nil)
c := Client{&Resources{GoogleAPI: api}}
resp, err := c.AutoComplete(context.Background(), "steve", CHAT_MODEL_GOOGLE)
api.On("GeminiChat", mock.Anything, "steve").Return(mockResponse, nil)
c := Client{&Resources{GeminiAPI: api}}
resp, err := c.AutoComplete(context.Background(), "steve", CHAT_MODEL_GEMINI)
assert.NoError(t, err)
assert.EqualValues(t, "is the best", resp)
}
2 changes: 1 addition & 1 deletion internal/dom/chatmodels/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "context"

type Resources struct {
GPTApi GptAPI
GoogleAPI GoogleApi
GeminiAPI GeminiAPI
}

type Service interface {
Expand Down

0 comments on commit f2d2bca

Please sign in to comment.