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

General Maintenance + Deprecate Conversational Endpoint (for now) #32

Merged
merged 7 commits into from
Feb 18, 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
3 changes: 3 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions conversational.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions conversational_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
6 changes: 5 additions & 1 deletion examples/conversational/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.")

Expand Down
2 changes: 1 addition & 1 deletion image_segmentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions tools/build-examples.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions tools/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -e

pushd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null

./build-examples.sh

pushd .. >/dev/null
echo "Formatting code..."
go fmt ./...
echo "Building $(basename "$(pwd)")"
go build ./...
echo "Vetting..."
go vet ./...
echo "Running tests..."
go test ./...
echo "Done."
Loading