Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
chore(huggingface): fix HuggingFace definition bug (#29)
Browse files Browse the repository at this point in the history
Because

- missed the `model` config in definition
- some small bugs in implementation

This commit

- fix HuggingFace definition bug
  • Loading branch information
donch1989 committed Oct 27, 2023
1 parent fd76e18 commit 13d5b2b
Show file tree
Hide file tree
Showing 17 changed files with 616 additions and 439 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/ghodss/yaml v1.0.0
github.com/gofrs/uuid v4.4.0+incompatible
github.com/h2non/filetype v1.1.3
github.com/instill-ai/component v0.6.0-alpha.0.20231026130206-961c654c4746
github.com/instill-ai/component v0.6.0-alpha.0.20231026154255-a1903a066149
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20231019202606-71607ddcd93f
github.com/santhosh-tekuri/jsonschema/v5 v5.3.0
github.com/stretchr/testify v1.8.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.2 h1:I/pwhnUln5wbMnTyRbzswA0/JxpK
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.2/go.mod h1:lsuH8kb4GlMdSlI4alNIBBSAt5CHJtg3i+0WuN9J5YM=
github.com/h2non/filetype v1.1.3 h1:FKkx9QbD7HR/zjK1Ia5XiBsq9zdLi5Kf3zGyFTAFkGg=
github.com/h2non/filetype v1.1.3/go.mod h1:319b3zT68BvV+WRj7cwy856M2ehB3HqNOt6sy1HndBY=
github.com/instill-ai/component v0.6.0-alpha.0.20231026130206-961c654c4746 h1:HQ3YLmUjn5B0YU90dxAq4pvdQ7jZOnGLiQl4iydGfWY=
github.com/instill-ai/component v0.6.0-alpha.0.20231026130206-961c654c4746/go.mod h1:LAufWJ0hJGFaKhVMIES9XeN+TWdyOjDvAnV3Br6xKWs=
github.com/instill-ai/component v0.6.0-alpha.0.20231026154255-a1903a066149 h1:nxpyrka2zgbg2gtMliolzBpCZtUfatMWRi4MNXhPL28=
github.com/instill-ai/component v0.6.0-alpha.0.20231026154255-a1903a066149/go.mod h1:LAufWJ0hJGFaKhVMIES9XeN+TWdyOjDvAnV3Br6xKWs=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20231019202606-71607ddcd93f h1:hweU93u6qsg8GH/YSogOfa+wOZEnkilGsijcy1xKX7E=
github.com/instill-ai/protogen-go v0.3.3-alpha.0.20231019202606-71607ddcd93f/go.mod h1:q/YL5TZXD9nvmJ7Rih4gY3/B2HT2+GiFdxeZp9D+yE4=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
Expand Down
286 changes: 143 additions & 143 deletions pkg/airbyte/config/definitions.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/airbyte/config/seed/generate_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

definitions_json = json.dumps(definitions, indent=2, sort_keys=True)
definitions_json = definitions_json.replace(
"airbyte_secret", "credential_field")
"airbyte_secret", "instillCredentialField")

with open('../definitions.json', 'w') as o:
o.write(definitions_json)
2 changes: 1 addition & 1 deletion pkg/bigquery/config/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"type": "string"
},
"json_key": {
"instillCredentialField": true,
"description": "Contents of the JSON key file with access to the bucket.",
"instillCredentialField": true,
"instillUIOrder": 0,
"title": "JSON Key File contents",
"type": "string"
Expand Down
4 changes: 2 additions & 2 deletions pkg/googlecloudstorage/config/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
"additionalProperties": false,
"properties": {
"bucket_name": {
"instillCredentialField": false,
"description": "Name of the bucket to be used for object storage.",
"instillCredentialField": false,
"instillUIOrder": 0,
"title": "Bucket Name",
"type": "string"
},
"json_key": {
"instillCredentialField": true,
"description": "Contents of the JSON key file with access to the bucket.",
"instillCredentialField": true,
"instillUIOrder": 1,
"title": "JSON Key File contents",
"type": "string"
Expand Down
9 changes: 6 additions & 3 deletions pkg/huggingface/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,13 @@ func (c *Client) MakeHFAPIRequest(body []byte, model string) ([]byte, error) {
if err != nil {
return nil, err
}
err = checkRespForError(respBody)
if err != nil {
return nil, err
if resp.StatusCode != http.StatusOK {
err = checkRespForError(respBody)
if err != nil {
return nil, err
}
}

return respBody, nil
}

Expand Down
7 changes: 3 additions & 4 deletions pkg/huggingface/config/definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"TASK_TOKEN_CLASSIFICATION",
"TASK_TRANSLATION",
"TASK_ZERO_SHOT_CLASSIFICATION",
"TASK_FEATURE_EXTRACTION",
"TASK_QUESTION_ANSWERING",
"TASK_TABLE_QUESTION_ANSWERING",
"TASK_SENTENCE_SIMILARITY",
Expand All @@ -32,24 +31,24 @@
"additionalProperties": true,
"properties": {
"api_key": {
"instillCredentialField": true,
"description": "Fill your Hugging face API token. To find your token, visit https://huggingface.co/settings/tokens.",
"instillCredentialField": true,
"instillUIOrder": 0,
"title": "API Key",
"type": "string"
},
"base_url": {
"instillCredentialField": false,
"default": "https://api-inference.huggingface.co",
"description": "Hostname for the endpoint. To use Inference API set to https://api-inference.huggingface.co, for Inference Endpoint set to your custom endpoint.",
"instillCredentialField": false,
"instillUIOrder": 1,
"title": "Base URL",
"type": "string"
},
"is_custom_endpoint": {
"instillCredentialField": false,
"default": false,
"description": "Fill true if you are using a custom Inference Endpoint and not the Inference API.",
"instillCredentialField": false,
"instillUIOrder": 2,
"title": "Is Custom Endpoint",
"type": "boolean"
Expand Down
Loading

0 comments on commit 13d5b2b

Please sign in to comment.