sync update from LAN repo (source master @ ca48c4ec)
This commit is contained in:
1 parent
8bc8b0e082
commit
ea9dcff9c0
873 files changed
+107866
-14011
No files matched your search
@@ -136,7 +136,16 @@ def _enable_stream_usage_by_default(model_use_path: str, model_settings_from_con
|
||||
model_settings_from_config["stream_usage"] = True
|
||||
|
||||
|
||||
def create_chat_model(name: str | None = None, thinking_enabled: bool = False, *, app_config: AppConfig | None = None, force_disable_thinking: bool = False, **kwargs) -> BaseChatModel:
|
||||
def create_chat_model(
|
||||
name: str | None = None,
|
||||
thinking_enabled: bool = False,
|
||||
*,
|
||||
app_config: AppConfig | None = None,
|
||||
force_disable_thinking: bool = False,
|
||||
write_file_compatibility: bool | None = None,
|
||||
prompt_suffix_enabled: bool = True,
|
||||
**kwargs,
|
||||
) -> BaseChatModel:
|
||||
"""Create a chat model instance from the config.
|
||||
|
||||
Args:
|
||||
@@ -183,15 +192,37 @@ def create_chat_model(name: str | None = None, thinking_enabled: bool = False, *
|
||||
"thinking",
|
||||
"supports_vision",
|
||||
"write_file_transport",
|
||||
"tool_call_transport",
|
||||
},
|
||||
)
|
||||
configured_write_file_transport = model_config.write_file_transport
|
||||
runtime_write_file_compatibility = get_write_file_compatibility_settings()
|
||||
# ``None`` follows the global switch, so a roundtable run with its own
|
||||
# switch off still uses compatibility when the global switch is on.
|
||||
# ``True`` is the roundtable opt-in used when the global switch is off.
|
||||
compatibility_enabled = (
|
||||
get_write_file_compatibility_settings().enabled
|
||||
if write_file_compatibility is None
|
||||
else write_file_compatibility
|
||||
)
|
||||
effective_write_file_transport = (
|
||||
WriteFileTransport.BUFFERED_GATEWAY
|
||||
if runtime_write_file_compatibility.enabled
|
||||
if compatibility_enabled
|
||||
else configured_write_file_transport
|
||||
)
|
||||
if model_config.tool_call_transport.value != "native":
|
||||
from deerflow.models.patched_openai import PatchedChatOpenAI
|
||||
|
||||
if not issubclass(model_class, PatchedChatOpenAI):
|
||||
raise ValueError(
|
||||
"tool_call_transport=deepseek_dsml is supported only by "
|
||||
"langchain_openai:ChatOpenAI or PatchedChatOpenAI models"
|
||||
)
|
||||
if model_config.use_responses_api:
|
||||
raise ValueError(
|
||||
"tool_call_transport=deepseek_dsml requires the OpenAI-compatible "
|
||||
"chat-completions API, not use_responses_api"
|
||||
)
|
||||
model_settings_from_config["tool_call_transport"] = model_config.tool_call_transport.value
|
||||
if effective_write_file_transport in {
|
||||
WriteFileTransport.BUFFERED_GATEWAY,
|
||||
WriteFileTransport.ARTIFACT_RENDERER,
|
||||
@@ -343,7 +374,14 @@ def create_chat_model(name: str | None = None, thinking_enabled: bool = False, *
|
||||
elif needs_qwen_flash_next_integrity(model_config.name, model_config.model):
|
||||
model_settings_from_config.setdefault("strict_stream_integrity", True)
|
||||
|
||||
model_instance = model_class(**kwargs, **model_settings_from_config)
|
||||
from deerflow.models.prompt_suffix import with_model_prompt_suffix
|
||||
|
||||
model_instance = with_model_prompt_suffix(model_class)(
|
||||
**kwargs,
|
||||
**model_settings_from_config,
|
||||
deerflow_prompt_model_name=name,
|
||||
deerflow_prompt_suffix_enabled=prompt_suffix_enabled,
|
||||
)
|
||||
|
||||
# Always emit a compact model lifecycle trace. In particular, the first
|
||||
# streamed callback proves that the upstream endpoint accepted the request
|
||||
|
||||
Reference in new issue
Block a user