Closed sadra-barikbin closed 2 months ago
Currently I should do this as the alternative:
from dataclasses import asdict
input_as_dict = asdict(input)
input_as_dict["parameters"]["stop_sequences"] = input_as_dict["parameters"]["stop"]
del input_as_dict["parameters"]["stop"]
client.text_generation(input.inputs, **input_as_dict["parameters"])
Hi @sadra-barikbin, yes I definitely agree this parameter should be unified. I opened a PR to fix it :) https://github.com/huggingface/huggingface_hub/pull/2473
Thanks @Wauplin ! 👍
There's also a discrepancy between ChatCompletionInput
's stream
param which is optional defaulting to None
and chat_completion()
's stream
param which should be either True
or False
. Is this OK?
Thanks for flagging this @sadra-barikbin. It's a slight discrepancy but it allows us to simplify the @overload
logic in InferenceClient.chat_completion
. If we add the type annotation for None
value, we would have to overload the method even more. The problem is that bool
and Literal[True, False]
is not considered the same by mypy / code editors. It led to quite some headaches when trying to solve that (the main thing I was focused on was to have correct autocomplete for the lib'). So all of this to say, the slight discrepancy is fine for now especially because it doesn't change anything in this case.
Hi there! 🤗
It would be great if
text_generation()
'sstop_sequences
andTextGenerationInput
'sstop
params are unified just likechat_completion
andChatCompletionInput
to be able to feed the input dataclasses to the client methods directly:https://github.com/huggingface/huggingface_hub/blob/359093fbe4fa049aadadf08ca60a2b0fa9a39c2d/src/huggingface_hub/inference/_client.py#L1658