|
|
@ -258,7 +258,10 @@ class HuggingFaceEndpoint(LLM):
|
|
|
|
stream=False,
|
|
|
|
stream=False,
|
|
|
|
task=self.task,
|
|
|
|
task=self.task,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
response_text = json.loads(response.decode())[0]["generated_text"]
|
|
|
|
try:
|
|
|
|
|
|
|
|
response_text = json.loads(response.decode())[0]["generated_text"]
|
|
|
|
|
|
|
|
except KeyError:
|
|
|
|
|
|
|
|
response_text = json.loads(response.decode())["generated_text"]
|
|
|
|
|
|
|
|
|
|
|
|
# Maybe the generation has stopped at one of the stop sequences:
|
|
|
|
# Maybe the generation has stopped at one of the stop sequences:
|
|
|
|
# then we remove this stop sequence from the end of the generated text
|
|
|
|
# then we remove this stop sequence from the end of the generated text
|
|
|
@ -289,7 +292,10 @@ class HuggingFaceEndpoint(LLM):
|
|
|
|
stream=False,
|
|
|
|
stream=False,
|
|
|
|
task=self.task,
|
|
|
|
task=self.task,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
response_text = json.loads(response.decode())[0]["generated_text"]
|
|
|
|
try:
|
|
|
|
|
|
|
|
response_text = json.loads(response.decode())[0]["generated_text"]
|
|
|
|
|
|
|
|
except KeyError:
|
|
|
|
|
|
|
|
response_text = json.loads(response.decode())["generated_text"]
|
|
|
|
|
|
|
|
|
|
|
|
# Maybe the generation has stopped at one of the stop sequences:
|
|
|
|
# Maybe the generation has stopped at one of the stop sequences:
|
|
|
|
# then remove this stop sequence from the end of the generated text
|
|
|
|
# then remove this stop sequence from the end of the generated text
|
|
|
|