Skip to content

Commit

Permalink
[#125] [ai][gemini] changed to not test if there is no value for the …
Browse files Browse the repository at this point in the history
…GEMINI_API_KEY environment variable
  • Loading branch information
heaven-chp committed Apr 14, 2024
1 parent c9d4074 commit a2a3cc7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
pull_request:
branches: [ "**" ]

env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}

jobs:

build:
Expand Down
4 changes: 3 additions & 1 deletion ai/gemini/chat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
)

func TestChat(t *testing.T) {
return
if len(test.API_KEY) == 0 {
return
}

chat := gemini.Chat{}
if err := chat.Start(test.API_KEY); err != nil {
Expand Down
8 changes: 6 additions & 2 deletions ai/gemini/gemini_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import (
)

func TestQuestion(t *testing.T) {
return
if len(test.API_KEY) == 0 {
return
}

if answer, err := gemini.Question(test.API_KEY, "who are you?", nil); err != nil {
t.Fatal(err)
Expand All @@ -24,7 +26,9 @@ func TestQuestion(t *testing.T) {
}

func TestQuestionStream(t *testing.T) {
return
if len(test.API_KEY) == 0 {
return
}

if channel, err := gemini.QuestionStream(test.API_KEY, "please say something encouraging", nil); err != nil {
t.Fatal(err)
Expand Down
4 changes: 3 additions & 1 deletion ai/gemini/test-data/api_key.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package test

const API_KEY = ""
import "os"

var API_KEY = os.Getenv("GEMINI_API_KEY")

0 comments on commit a2a3cc7

Please sign in to comment.