From f264b10b283ea6165bc159c761402ac3b544b97e Mon Sep 17 00:00:00 2001 From: Tanner Kvarfordt Date: Sat, 10 Feb 2024 21:54:58 -0700 Subject: [PATCH 1/7] Added build script --- tools/build.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 tools/build.sh diff --git a/tools/build.sh b/tools/build.sh new file mode 100755 index 0000000..bf81e2f --- /dev/null +++ b/tools/build.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -e + +pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null + +echo "Formatting code..." +go fmt ./... +echo "Building $(basename "$(pwd)")" +go build ./... +echo "Vetting..." +go vet ./... +echo "Running tests..." +go test ./... +echo "Done." \ No newline at end of file From e2913f834606e5973b38815cf013ab8878c91d6a Mon Sep 17 00:00:00 2001 From: Tanner Kvarfordt Date: Sat, 10 Feb 2024 21:55:15 -0700 Subject: [PATCH 2/7] Fixed go vet issue --- examples/conversational/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/conversational/main.go b/examples/conversational/main.go index 2364d62..69ef4f1 100644 --- a/examples/conversational/main.go +++ b/examples/conversational/main.go @@ -22,7 +22,7 @@ func init() { } func init() { - ch := make(chan os.Signal) + ch := make(chan os.Signal, 1) signal.Notify(ch, os.Interrupt, syscall.SIGTERM) go func() { <-ch From 0434616902682acf124320632f3dc180fe706fdb Mon Sep 17 00:00:00 2001 From: Tanner Kvarfordt Date: Sat, 10 Feb 2024 21:57:13 -0700 Subject: [PATCH 3/7] Added vet step to unit tests workflow --- .github/workflows/unit-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 03f538b..4c14014 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -26,6 +26,9 @@ jobs: - name: Build run: go build -v ./... + - name: Vet + run: go vet -v ./... + - name: Test run: go test -timeout 300s -v ./... env: From 8d0a38f40413f598a087bea0c8bb2931df6a75db Mon Sep 17 00:00:00 2001 From: Tanner Kvarfordt Date: Sat, 10 Feb 2024 22:03:58 -0700 Subject: [PATCH 4/7] Added build-examples script --- tools/build-examples.sh | 12 ++++++++++++ tools/build.sh | 5 ++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 tools/build-examples.sh diff --git a/tools/build-examples.sh b/tools/build-examples.sh new file mode 100755 index 0000000..4fac78d --- /dev/null +++ b/tools/build-examples.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e + +pushd "$(dirname "${BASH_SOURCE[0]}")/../examples" >/dev/null + +for d in */; do + pushd "${d}" >/dev/null + echo "Building ${d}" + go build + popd >/dev/null +done \ No newline at end of file diff --git a/tools/build.sh b/tools/build.sh index bf81e2f..3efc9f6 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash set -e -pushd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null +pushd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null +./build-examples.sh + +pushd .. >/dev/null echo "Formatting code..." go fmt ./... echo "Building $(basename "$(pwd)")" From 3b1962588545d904017f3516966298ec92f9906e Mon Sep 17 00:00:00 2001 From: Tanner Kvarfordt Date: Sat, 10 Feb 2024 22:15:04 -0700 Subject: [PATCH 5/7] Updated image_segmentation model --- image_segmentation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image_segmentation.go b/image_segmentation.go index 3715413..65ef4b9 100644 --- a/image_segmentation.go +++ b/image_segmentation.go @@ -2,7 +2,7 @@ package hfapigo import "encoding/json" -const RecommendedImageSegmentationModel = "facebook/detr-resnet-50-panoptic" +const RecommendedImageSegmentationModel = "nvidia/segformer-b1-finetuned-cityscapes-1024-1024" type ImageSegmentationResponse struct { // The label for the class (model specific) of a segment. From f9687c0ede51068f3439693317798bb10c730bd6 Mon Sep 17 00:00:00 2001 From: Tanner Kvarfordt Date: Sat, 17 Feb 2024 17:34:21 -0700 Subject: [PATCH 6/7] Disabled conversational test for now --- conversational_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conversational_test.go b/conversational_test.go index 80499a9..485adef 100644 --- a/conversational_test.go +++ b/conversational_test.go @@ -65,6 +65,8 @@ func TestMarshalUnMarshalConversationalRequest(t *testing.T) { } func TestConversationalRequest(t *testing.T) { + t.Skip("The conversational endpoint seems to be undergoing deprecation/refactor. Disabling the unit tests for it until more information is available and updates can be made.") + // Basic request { cresp, err := hfapigo.SendConversationalRequest(hfapigo.RecommendedConversationalModel, &hfapigo.ConversationalRequest{ From f8595309d05e1c0568fad02da5a58199fb1f062b Mon Sep 17 00:00:00 2001 From: Tanner Kvarfordt Date: Sat, 17 Feb 2024 18:00:25 -0700 Subject: [PATCH 7/7] Deprecated conversational endpoint for now --- README.md | 2 +- conversational.go | 4 ++++ examples/conversational/main.go | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 22f7e47..969830a 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ An API key is required for authorized access. To get one, create a [Hugging Face See the [examples](./examples) directory. - [Audio Classification](./examples/audio_classification/main.go) -- [Conversational](./examples/conversational/main.go) +- ~~[Conversational](./examples/conversational/main.go)~~ - [Fill Mask](./examples/fill_mask/main.go) - [Image Classification](./examples/image_classification/main.go) - [Image Segmentation](./examples/image_segmentation/main.go) diff --git a/conversational.go b/conversational.go index de609c1..e2d0e4e 100644 --- a/conversational.go +++ b/conversational.go @@ -109,6 +109,10 @@ type Conversation struct { PastUserInputs []string `json:"past_user_inputs,omitempty"` } +// Deprecated: HF's conversational endpoint seems to be under construction +// and slated to be either updated or replaced. +// TODO: Update or remove conversational support once it becomes +// clear what its replacement is. func SendConversationalRequest(model string, request *ConversationalRequest) (*ConversationalResponse, error) { if request == nil { return nil, errors.New("nil ConversationalRequest") diff --git a/examples/conversational/main.go b/examples/conversational/main.go index 69ef4f1..187fc9a 100644 --- a/examples/conversational/main.go +++ b/examples/conversational/main.go @@ -32,6 +32,10 @@ func init() { const model = "facebook/blenderbot-400M-distill" +// Deprecated: HF's conversational endpoint seems to be under construction +// and slated to be either updated or replaced. +// TODO: Update or remove conversational support once it becomes +// clear what its replacement is. func main() { fmt.Println("Enter your messages below. Hit enter to send. Use Ctrl+c or Ctrl+d to quit.")