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.

fix: _convert_prompt_message_to_dict parameters err (#5716)

takatost0bf481747453
diff --git a/api/core/app/task_pipeline/workflow_cycle_manage.py b/api/core/app/task_pipeline/workflow_cycle_manage.py
index e79ac05a752..513fc692ffb 100644
--- a/api/core/app/task_pipeline/workflow_cycle_manage.py
+++ b/api/core/app/task_pipeline/workflow_cycle_manage.py
@@ -167,13 +167,14 @@ class WorkflowCycleManage(WorkflowIterationCycleManage):
db.session.refresh(workflow_run)
db.session.close()
- trace_manager.add_trace_task(
- TraceTask(
- TraceTaskName.WORKFLOW_TRACE,
- workflow_run=workflow_run,
- conversation_id=conversation_id,
+ if trace_manager:
+ trace_manager.add_trace_task(
+ TraceTask(
+ TraceTaskName.WORKFLOW_TRACE,
+ workflow_run=workflow_run,
+ conversation_id=conversation_id,
+ )
)
- )
return workflow_run
diff --git a/api/core/model_runtime/model_providers/moonshot/llm/llm.py b/api/core/model_runtime/model_providers/moonshot/llm/llm.py
index ef301b0f6c3..17cf65dc3ad 100644
--- a/api/core/model_runtime/model_providers/moonshot/llm/llm.py
+++ b/api/core/model_runtime/model_providers/moonshot/llm/llm.py
@@ -93,7 +93,7 @@ class MoonshotLargeLanguageModel(OAIAPICompatLargeLanguageModel):
}.intersection(model_schema.features or []):
credentials['function_calling_type'] = 'tool_call'
- def _convert_prompt_message_to_dict(self, message: PromptMessage) -> dict:
+ def _convert_prompt_message_to_dict(self, message: PromptMessage, credentials: Optional[dict] = None) -> dict:
"""
Convert PromptMessage to dict for OpenAI API format
"""
diff --git a/api/core/model_runtime/model_providers/nvidia/llm/llm.py b/api/core/model_runtime/model_providers/nvidia/llm/llm.py
index 4b2dbf3d3a5..11252b92115 100644
--- a/api/core/model_runtime/model_providers/nvidia/llm/llm.py
+++ b/api/core/model_runtime/model_providers/nvidia/llm/llm.py
@@ -200,7 +200,7 @@ class NVIDIALargeLanguageModel(OAIAPICompatLargeLanguageModel):
endpoint_url = str(URL(endpoint_url) / 'chat' / 'completions')
elif 'server_url' in credentials:
endpoint_url = server_url
- data['messages'] = [self._convert_prompt_message_to_dict(m) for m in prompt_messages]
+ data['messages'] = [self._convert_prompt_message_to_dict(m, credentials) for m in prompt_messages]
elif completion_type is LLMMode.COMPLETION:
data['prompt'] = 'ping'
if 'endpoint_url' in credentials:
diff --git a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py
index 36eae2042d1..b76f460737b 100644
--- a/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py
+++ b/api/core/model_runtime/model_providers/openai_api_compatible/llm/llm.py
@@ -582,7 +582,7 @@ class OAIAPICompatLargeLanguageModel(_CommonOAI_API_Compat, LargeLanguageModel):
return result
- def _convert_prompt_message_to_dict(self, message: PromptMessage, credentials: dict = None) -> dict:
+ def _convert_prompt_message_to_dict(self, message: PromptMessage, credentials: Optional[dict] = None) -> dict:
"""
Convert PromptMessage to dict for OpenAI API format
"""