Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

September '24 Maintenance #45

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions audio_classification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@ package hfapigo_test

import (
"testing"
"time"

"github.com/Kardbord/hfapigo/v3"
)

func TestAudioClassificationRequest(t *testing.T) {
const retries = 10

acResps := []*hfapigo.AudioClassificationResponse{}
var err error
for i := 0; i < retries; i++ {
acResps, err = hfapigo.SendAudioClassificationRequest(hfapigo.RecommendedAudioClassificationModel, TestFilesDir+"/sample.flac")
if err == nil {
break
} else {
time.Sleep(time.Second * 5)
}
}
acResps, err = hfapigo.SendAudioClassificationRequest(hfapigo.RecommendedAudioClassificationModel, TestFilesDir+"/sample.flac")
if err != nil {
t.Fatal(err)
}
Expand Down
12 changes: 1 addition & 11 deletions image_to_text_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@ package hfapigo_test

import (
"testing"
"time"

"github.com/Kardbord/hfapigo/v3"
)

func TestImageToText(t *testing.T) {
const retries = 10

resps := []*hfapigo.ImageToTextResponse{}
var err error
for i := 0; i < retries; i++ {
resps, err = hfapigo.SendImageToTextRequest(hfapigo.RecommendedImageToTextModel, TestFilesDir+"/test-image.png")
if err == nil {
break
} else {
time.Sleep(time.Second * 5)
}
}

resps, err = hfapigo.SendImageToTextRequest(hfapigo.RecommendedImageToTextModel, TestFilesDir+"/test-image.png")
if err != nil {
t.Fatal(err)
}
Expand Down
12 changes: 1 addition & 11 deletions object_detection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@ package hfapigo_test

import (
"testing"
"time"

"github.com/Kardbord/hfapigo/v3"
)

func TestObjectDetectionRequest(t *testing.T) {
const retries = 10

resps := []*hfapigo.ObjectDetectionResponse{}
var err error
for i := 0; i < retries; i++ {
resps, err = hfapigo.SendObjectDetectionRequest(hfapigo.RecommendedObjectDetectionModel, TestFilesDir+"/test-image.png")
if err == nil {
break
} else {
time.Sleep(time.Second * 5)
}
}
resps, err = hfapigo.SendObjectDetectionRequest(hfapigo.RecommendedObjectDetectionModel, TestFilesDir+"/test-image.png")
if err != nil {
t.Fatal(err)
}
Expand Down
9 changes: 3 additions & 6 deletions setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,9 @@ func init() {
}

func TestMain(m *testing.M) {
shouldWarn := hfapigo.APIKey() == ""
if shouldWarn {
fmt.Printf("%s not found in env, tests may fail due to rate limiting.\n", HuggingFaceTokenEnv)
if hfapigo.APIKey() == "" {
fmt.Fprintf(os.Stderr, "%s not set, tests will fail due to rate limiting.", HuggingFaceTokenEnv)
os.Exit(1)
}
m.Run()
if shouldWarn {
fmt.Printf("%s not found in env, tests may fail due to rate limiting.\n", HuggingFaceTokenEnv)
}
}
12 changes: 1 addition & 11 deletions speech_recognition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@ package hfapigo_test

import (
"testing"
"time"

"github.com/Kardbord/hfapigo/v3"
)

func TestSpeechRecognitionRequest(t *testing.T) {
const retries = 10

arResp := &hfapigo.SpeechRecognitionResponse{}
var err error
for i := 0; i < retries; i++ {
arResp, err = hfapigo.SendSpeechRecognitionRequest(hfapigo.RecommendedSpeechRecongnitionModelEnglish, TestFilesDir+"/sample.flac")
if err == nil {
break
} else {
time.Sleep(time.Second * 5)
}
}
arResp, err = hfapigo.SendSpeechRecognitionRequest(hfapigo.RecommendedSpeechRecongnitionModelEnglish, TestFilesDir+"/sample.flac")
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion text_to_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
_ "image/png"
)

const RecommendedTextToImageModel = "runwayml/stable-diffusion-v1-5"
const RecommendedTextToImageModel = "stable-diffusion-v1-5/stable-diffusion-v1-5"

// Request structure for text-to-image model
type TextToImageRequest struct {
Expand Down
Loading