Skip to content

Commit c59ff1d

Browse files
committed
remove conversational from hf
1 parent 3cf87dd commit c59ff1d

12 files changed

Lines changed: 38 additions & 712 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bin
1919
*.swp
2020
*.swo
2121
*~
22-
.env
22+
.env*
2323

2424
# Python dev
2525
.mypy_cache

runtimes/huggingface/mlserver_huggingface/codecs/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from .json import HuggingfaceSingleJSONCodec
44
from .jsonlist import HuggingfaceListJSONCodec
55
from .numpylist import NumpyListCodec
6-
from .conversation import HuggingfaceConversationCodec
76
from .raw import RawCodec
87
from .utils import EqualUtil
98
from .chariot import ChariotImgModelOutputCodec
@@ -14,7 +13,6 @@
1413
"PILImageCodec",
1514
"HuggingfaceSingleJSONCodec",
1615
"HuggingfaceListJSONCodec",
17-
"HuggingfaceConversationCodec",
1816
"ChariotImgModelOutputCodec",
1917
"NumpyListCodec",
2018
"RawCodec",

runtimes/huggingface/mlserver_huggingface/codecs/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from .image import PILImageCodec
2626
from .json import HuggingfaceSingleJSONCodec
2727
from .jsonlist import HuggingfaceListJSONCodec
28-
from .conversation import HuggingfaceConversationCodec
2928
from .numpylist import NumpyListCodec
3029
from .raw import RawCodec
3130

@@ -207,7 +206,6 @@ class HuggingfaceRequestCodec(MultiInputRequestCodec):
207206
PILImageCodec,
208207
HuggingfaceSingleJSONCodec,
209208
HuggingfaceListJSONCodec,
210-
HuggingfaceConversationCodec,
211209
NumpyListCodec,
212210
RawCodec,
213211
]

runtimes/huggingface/mlserver_huggingface/codecs/conversation.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

runtimes/huggingface/mlserver_huggingface/codecs/utils.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import base64
55
import numpy as np
66
from PIL import Image, ImageChops
7-
from transformers.pipelines import Conversation
87

98
IMAGE_PREFIX = "data:image/"
109
DEFAULT_IMAGE_FORMAT = "PNG"
@@ -29,13 +28,6 @@ def default(self, obj):
2928
+ ";base64,"
3029
+ base64.b64encode(buf.getvalue()).decode()
3130
)
32-
elif isinstance(obj, Conversation):
33-
return {
34-
"uuid": str(obj.uuid),
35-
"past_user_inputs": obj.past_user_inputs,
36-
"generated_responses": obj.generated_responses,
37-
"new_user_input": obj.new_user_input,
38-
}
3931
else:
4032
return json.JSONEncoder.default(self, obj)
4133

@@ -69,29 +61,12 @@ def do(cls, raw):
6961
else:
7062
return raw
7163

72-
@classmethod
73-
def convert_conversation(cls, d: Dict[str, Any]):
74-
if set(d.keys()) == conversation_keys:
75-
return Conversation(
76-
text=d["new_user_input"],
77-
conversation_id=d["uuid"],
78-
past_user_inputs=d["past_user_inputs"],
79-
generated_responses=d["generated_responses"],
80-
)
81-
return None
82-
8364
@classmethod
8465
def convert_dict(cls, d: Dict[str, Any]):
85-
conversation = cls.convert_conversation(d)
86-
if conversation is not None:
87-
return conversation
8866
tmp = {}
8967
for k, v in d.items():
9068
if isinstance(v, dict):
91-
if set(v.keys()) == conversation_keys:
92-
tmp[k] = Conversation(text=v["new_user_input"])
93-
else:
94-
tmp[k] = cls.convert_dict(v)
69+
tmp[k] = cls.convert_dict(v)
9570
elif isinstance(v, list):
9671
tmp[k] = cls.convert_list(v)
9772
elif isinstance(v, str):

runtimes/huggingface/mlserver_huggingface/metadata.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,20 @@
200200
),
201201
"text-generation": dict(
202202
inputs=[
203+
# string input
203204
MetadataTensor(
204205
name="array_inputs",
205206
shape=[-1],
206207
datatype="BYTES",
207208
parameters=dict(content_type="str"),
208209
),
210+
# list of dict inputs
211+
MetadataTensor(
212+
name="array_inputs",
213+
shape=[-1],
214+
datatype="BYTES",
215+
parameters=dict(content_type="hg_jsonlist"),
216+
),
209217
],
210218
outputs=[],
211219
),
@@ -258,17 +266,6 @@
258266
],
259267
outputs=[],
260268
),
261-
"conversational": dict(
262-
inputs=[
263-
MetadataTensor(
264-
name="array_inputs",
265-
shape=[-1],
266-
datatype="FP32",
267-
parameters=dict(content_type="hg_conversation"),
268-
),
269-
],
270-
outputs=[],
271-
),
272269
"image-classification": dict(
273270
inputs=[
274271
# file path inputs
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.0.12"
1+
__version__ = "2.0.14"

runtimes/huggingface/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mlserver-huggingface"
3-
version = "2.0.12"
3+
version = "2.0.14"
44
description = "HuggingFace runtime for MLServer"
55
authors = ["Seldon Technologies Ltd. <hello@seldon.io>"]
66
license = "Apache-2.0"

0 commit comments

Comments
 (0)