Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat: optimize xinference stream (#989)

takatost18d3877151cf
diff --git a/api/core/third_party/langchain/llms/xinference_llm.py b/api/core/third_party/langchain/llms/xinference_llm.py
index 0aa73057aab..dda3659d8eb 100644
--- a/api/core/third_party/langchain/llms/xinference_llm.py
+++ b/api/core/third_party/langchain/llms/xinference_llm.py
@@ -108,12 +108,12 @@ class XinferenceLLM(Xinference):
Yields:
A string token.
"""
- if isinstance(model, RESTfulGenerateModelHandle):
- streaming_response = model.generate(
+ if isinstance(model, (RESTfulChatModelHandle, RESTfulChatglmCppChatModelHandle)):
+ streaming_response = model.chat(
prompt=prompt, generate_config=generate_config
)
else:
- streaming_response = model.chat(
+ streaming_response = model.generate(
prompt=prompt, generate_config=generate_config
)