|
|
|
|
@ -89,13 +89,13 @@ class XinferenceLLM(Xinference):
|
|
|
|
|
|
|
|
|
|
return completion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _stream_generate(
|
|
|
|
|
self,
|
|
|
|
|
model: Union["RESTfulGenerateModelHandle", "RESTfulChatModelHandle", "RESTfulChatglmCppChatModelHandle"],
|
|
|
|
|
prompt: str,
|
|
|
|
|
run_manager: Optional[CallbackManagerForLLMRun] = None,
|
|
|
|
|
generate_config: Optional[Union["LlamaCppGenerateConfig", "PytorchGenerateConfig", "ChatglmCppGenerateConfig"]] = None,
|
|
|
|
|
generate_config: Optional[
|
|
|
|
|
Union["LlamaCppGenerateConfig", "PytorchGenerateConfig", "ChatglmCppGenerateConfig"]] = None,
|
|
|
|
|
) -> Generator[str, None, None]:
|
|
|
|
|
"""
|
|
|
|
|
Args:
|
|
|
|
|
@ -123,6 +123,10 @@ class XinferenceLLM(Xinference):
|
|
|
|
|
if choices:
|
|
|
|
|
choice = choices[0]
|
|
|
|
|
if isinstance(choice, dict):
|
|
|
|
|
if 'finish_reason' in choice and choice['finish_reason'] \
|
|
|
|
|
and choice['finish_reason'] in ['stop', 'length']:
|
|
|
|
|
break
|
|
|
|
|
|
|
|
|
|
if 'text' in choice:
|
|
|
|
|
token = choice.get("text", "")
|
|
|
|
|
elif 'delta' in choice and 'content' in choice['delta']:
|
|
|
|
|
|