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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
chore: format get_customizable_model_schema return value (#9335)
ice yao1e829ceaf32d
diff --git a/api/core/model_runtime/docs/en_US/customizable_model_scale_out.md b/api/core/model_runtime/docs/en_US/customizable_model_scale_out.mdindex f5b806ade6f..f050919d81b 100644--- a/api/core/model_runtime/docs/en_US/customizable_model_scale_out.md+++ b/api/core/model_runtime/docs/en_US/customizable_model_scale_out.md@@ -218,7 +218,7 @@ For instance, Xinference supports `max_tokens`, `temperature`, and `top_p` paramHowever, some vendors may support different parameters for different models. For example, the `OpenLLM` vendor supports `top_k`, but not all models provided by this vendor support `top_k`. Let's say model A supports `top_k` but model B does not. In such cases, we need to dynamically generate the model parameter schema, as illustrated below:```python- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/docs/zh_Hans/customizable_model_scale_out.md b/api/core/model_runtime/docs/zh_Hans/customizable_model_scale_out.mdindex 7b3a8edba37..240f65802b8 100644--- a/api/core/model_runtime/docs/zh_Hans/customizable_model_scale_out.md+++ b/api/core/model_runtime/docs/zh_Hans/customizable_model_scale_out.md@@ -205,7 +205,7 @@ provider_credential_schema:但是有的供应商根据不同的模型支持不同的参数,如供应商`OpenLLM`支持`top_k`,但是并不是这个供应商提供的所有模型都支持`top_k`,我们这里举例A模型支持`top_k`,B模型不支持`top_k`,那么我们需要在这里动态生成模型参数的Schema,如下所示:```python- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/azure_ai_studio/llm/llm.py b/api/core/model_runtime/model_providers/azure_ai_studio/llm/llm.pyindex 516ef8b295e..53030bad834 100644--- a/api/core/model_runtime/model_providers/azure_ai_studio/llm/llm.py+++ b/api/core/model_runtime/model_providers/azure_ai_studio/llm/llm.py@@ -294,7 +294,7 @@ class AzureAIStudioLargeLanguageModel(LargeLanguageModel):],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""Used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/azure_ai_studio/rerank/rerank.py b/api/core/model_runtime/model_providers/azure_ai_studio/rerank/rerank.pyindex 6ed7ab277cd..b6dfb20b66b 100644--- a/api/core/model_runtime/model_providers/azure_ai_studio/rerank/rerank.py+++ b/api/core/model_runtime/model_providers/azure_ai_studio/rerank/rerank.py@@ -148,7 +148,7 @@ class AzureRerankModel(RerankModel):InvokeBadRequestError: [InvokeBadRequestError, KeyError, ValueError, json.JSONDecodeError],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/huggingface_tei/rerank/rerank.py b/api/core/model_runtime/model_providers/huggingface_tei/rerank/rerank.pyindex 74a1dfc3ffe..0bb9a9c8b58 100644--- a/api/core/model_runtime/model_providers/huggingface_tei/rerank/rerank.py+++ b/api/core/model_runtime/model_providers/huggingface_tei/rerank/rerank.py@@ -118,7 +118,7 @@ class HuggingfaceTeiRerankModel(RerankModel):InvokeBadRequestError: [InvokeBadRequestError, KeyError, ValueError],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/huggingface_tei/text_embedding/text_embedding.py b/api/core/model_runtime/model_providers/huggingface_tei/text_embedding/text_embedding.pyindex 6b439345389..a0917630a9f 100644--- a/api/core/model_runtime/model_providers/huggingface_tei/text_embedding/text_embedding.py+++ b/api/core/model_runtime/model_providers/huggingface_tei/text_embedding/text_embedding.py@@ -189,7 +189,7 @@ class HuggingfaceTeiTextEmbeddingModel(TextEmbeddingModel):return usage- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/localai/llm/llm.py b/api/core/model_runtime/model_providers/localai/llm/llm.pyindex e7295355f62..756c5571d40 100644--- a/api/core/model_runtime/model_providers/localai/llm/llm.py+++ b/api/core/model_runtime/model_providers/localai/llm/llm.py@@ -1,5 +1,5 @@from collections.abc import Generator-from typing import cast+from typing import Optional, castfrom httpx import Timeoutfrom openai import (@@ -212,7 +212,7 @@ class LocalAILanguageModel(LargeLanguageModel):except Exception as ex:raise CredentialsValidateFailedError(f"Invalid credentials {str(ex)}")- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:completion_model = Noneif credentials["completion_type"] == "chat_completion":completion_model = LLMMode.CHAT.valuediff --git a/api/core/model_runtime/model_providers/localai/speech2text/speech2text.py b/api/core/model_runtime/model_providers/localai/speech2text/speech2text.pyindex 4b9d0f5bfef..260a35d9d4f 100644--- a/api/core/model_runtime/model_providers/localai/speech2text/speech2text.py+++ b/api/core/model_runtime/model_providers/localai/speech2text/speech2text.py@@ -73,7 +73,7 @@ class LocalAISpeech2text(Speech2TextModel):InvokeBadRequestError: [InvokeBadRequestError],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/localai/text_embedding/text_embedding.py b/api/core/model_runtime/model_providers/localai/text_embedding/text_embedding.pyindex b4dfc1a4dec..0111c3362a5 100644--- a/api/core/model_runtime/model_providers/localai/text_embedding/text_embedding.py+++ b/api/core/model_runtime/model_providers/localai/text_embedding/text_embedding.py@@ -115,7 +115,7 @@ class LocalAITextEmbeddingModel(TextEmbeddingModel):num_tokens += self._get_num_tokens_by_gpt2(text)return num_tokens- def _get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def _get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""Get customizable model schemadiff --git a/api/core/model_runtime/model_providers/moonshot/llm/llm.py b/api/core/model_runtime/model_providers/moonshot/llm/llm.pyindex 3ea46c2967e..01a2a07325e 100644--- a/api/core/model_runtime/model_providers/moonshot/llm/llm.py+++ b/api/core/model_runtime/model_providers/moonshot/llm/llm.py@@ -50,7 +50,7 @@ class MoonshotLargeLanguageModel(OAIAPICompatLargeLanguageModel):self._add_custom_parameters(credentials)super().validate_credentials(model, credentials)- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:return AIModelEntity(model=model,label=I18nObject(en_US=model, zh_Hans=model),diff --git a/api/core/model_runtime/model_providers/openai/speech2text/speech2text.py b/api/core/model_runtime/model_providers/openai/speech2text/speech2text.pyindex 0d54d2ea9a9..ecf455c6fdb 100644--- a/api/core/model_runtime/model_providers/openai/speech2text/speech2text.py+++ b/api/core/model_runtime/model_providers/openai/speech2text/speech2text.py@@ -61,7 +61,7 @@ class OpenAISpeech2TextModel(_CommonOpenAI, Speech2TextModel):return response.text- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/openai_api_compatible/speech2text/speech2text.py b/api/core/model_runtime/model_providers/openai_api_compatible/speech2text/speech2text.pyindex cef77cc9419..a490537e51a 100644--- a/api/core/model_runtime/model_providers/openai_api_compatible/speech2text/speech2text.py+++ b/api/core/model_runtime/model_providers/openai_api_compatible/speech2text/speech2text.py@@ -62,7 +62,7 @@ class OAICompatSpeech2TextModel(_CommonOaiApiCompat, Speech2TextModel):except Exception as ex:raise CredentialsValidateFailedError(str(ex))- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/openllm/llm/llm.py b/api/core/model_runtime/model_providers/openllm/llm/llm.pyindex 34b4de79620..e5ecc748fb1 100644--- a/api/core/model_runtime/model_providers/openllm/llm/llm.py+++ b/api/core/model_runtime/model_providers/openllm/llm/llm.py@@ -1,4 +1,5 @@from collections.abc import Generator+from typing import Optionalfrom core.model_runtime.entities.common_entities import I18nObjectfrom core.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMResultChunk, LLMResultChunkDelta@@ -193,7 +194,7 @@ class OpenLLMLargeLanguageModel(LargeLanguageModel):),)- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/sagemaker/llm/llm.py b/api/core/model_runtime/model_providers/sagemaker/llm/llm.pyindex 97b76920443..dd53914a69d 100644--- a/api/core/model_runtime/model_providers/sagemaker/llm/llm.py+++ b/api/core/model_runtime/model_providers/sagemaker/llm/llm.py@@ -408,7 +408,7 @@ class SageMakerLargeLanguageModel(LargeLanguageModel):InvokeBadRequestError: [InvokeBadRequestError, KeyError, ValueError],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/sagemaker/rerank/rerank.py b/api/core/model_runtime/model_providers/sagemaker/rerank/rerank.pyindex 959dff6a21c..49c3fa5921b 100644--- a/api/core/model_runtime/model_providers/sagemaker/rerank/rerank.py+++ b/api/core/model_runtime/model_providers/sagemaker/rerank/rerank.py@@ -157,7 +157,7 @@ class SageMakerRerankModel(RerankModel):InvokeBadRequestError: [InvokeBadRequestError, KeyError, ValueError],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/sagemaker/speech2text/speech2text.py b/api/core/model_runtime/model_providers/sagemaker/speech2text/speech2text.pyindex 94bae71e539..8fdf68abe18 100644--- a/api/core/model_runtime/model_providers/sagemaker/speech2text/speech2text.py+++ b/api/core/model_runtime/model_providers/sagemaker/speech2text/speech2text.py@@ -111,7 +111,7 @@ class SageMakerSpeech2TextModel(Speech2TextModel):InvokeBadRequestError: [InvokeBadRequestError, KeyError, ValueError],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/sagemaker/text_embedding/text_embedding.py b/api/core/model_runtime/model_providers/sagemaker/text_embedding/text_embedding.pyindex ae7d805b4e3..ececfda11a5 100644--- a/api/core/model_runtime/model_providers/sagemaker/text_embedding/text_embedding.py+++ b/api/core/model_runtime/model_providers/sagemaker/text_embedding/text_embedding.py@@ -180,7 +180,7 @@ class SageMakerEmbeddingModel(TextEmbeddingModel):InvokeBadRequestError: [KeyError],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/sagemaker/tts/tts.py b/api/core/model_runtime/model_providers/sagemaker/tts/tts.pyindex 1a5afd18f99..6a5946453be 100644--- a/api/core/model_runtime/model_providers/sagemaker/tts/tts.py+++ b/api/core/model_runtime/model_providers/sagemaker/tts/tts.py@@ -159,7 +159,7 @@ class SageMakerText2SpeechModel(TTSModel):return self._tts_invoke_streaming(model_type, payload, sagemaker_endpoint)- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/siliconflow/llm/llm.py b/api/core/model_runtime/model_providers/siliconflow/llm/llm.pyindex 4f8f4e0f61c..6015442c2b2 100644--- a/api/core/model_runtime/model_providers/siliconflow/llm/llm.py+++ b/api/core/model_runtime/model_providers/siliconflow/llm/llm.py@@ -40,7 +40,7 @@ class SiliconflowLargeLanguageModel(OAIAPICompatLargeLanguageModel):credentials["mode"] = "chat"credentials["endpoint_url"] = "https://api.siliconflow.cn/v1"- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:return AIModelEntity(model=model,label=I18nObject(en_US=model, zh_Hans=model),diff --git a/api/core/model_runtime/model_providers/stepfun/llm/llm.py b/api/core/model_runtime/model_providers/stepfun/llm/llm.pyindex dab666e4d09..43b91a1aec9 100644--- a/api/core/model_runtime/model_providers/stepfun/llm/llm.py+++ b/api/core/model_runtime/model_providers/stepfun/llm/llm.py@@ -50,7 +50,7 @@ class StepfunLargeLanguageModel(OAIAPICompatLargeLanguageModel):self._add_custom_parameters(credentials)super().validate_credentials(model, credentials)- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:return AIModelEntity(model=model,label=I18nObject(en_US=model, zh_Hans=model),diff --git a/api/core/model_runtime/model_providers/tongyi/llm/llm.py b/api/core/model_runtime/model_providers/tongyi/llm/llm.pyindex 3e3585b30ae..3a1bb75a598 100644--- a/api/core/model_runtime/model_providers/tongyi/llm/llm.py+++ b/api/core/model_runtime/model_providers/tongyi/llm/llm.py@@ -535,7 +535,7 @@ class TongyiLargeLanguageModel(LargeLanguageModel):],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""Architecture for defining customizable modelsdiff --git a/api/core/model_runtime/model_providers/triton_inference_server/llm/llm.py b/api/core/model_runtime/model_providers/triton_inference_server/llm/llm.pyindex cf7e3f14be0..47a4b992146 100644--- a/api/core/model_runtime/model_providers/triton_inference_server/llm/llm.py+++ b/api/core/model_runtime/model_providers/triton_inference_server/llm/llm.py@@ -1,4 +1,5 @@from collections.abc import Generator+from typing import Optionalfrom httpx import Response, postfrom yarl import URL@@ -109,7 +110,7 @@ class TritonInferenceAILargeLanguageModel(LargeLanguageModel):raise NotImplementedError(f"PromptMessage type {type(item)} is not supported")return text- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/volcengine_maas/llm/llm.py b/api/core/model_runtime/model_providers/volcengine_maas/llm/llm.pyindex dec6c9d789c..1c776cec7e3 100644--- a/api/core/model_runtime/model_providers/volcengine_maas/llm/llm.py+++ b/api/core/model_runtime/model_providers/volcengine_maas/llm/llm.py@@ -1,5 +1,6 @@import loggingfrom collections.abc import Generator+from typing import Optionalfrom volcenginesdkarkruntime.types.chat import ChatCompletion, ChatCompletionChunk@@ -298,7 +299,7 @@ class VolcengineMaaSLargeLanguageModel(LargeLanguageModel):chunks = client.stream_chat(prompt_messages, **req_params)return _handle_stream_chat_response(chunks)- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/xinference/llm/llm.py b/api/core/model_runtime/model_providers/xinference/llm/llm.pyindex 0c9d08679ad..b82f0430c5f 100644--- a/api/core/model_runtime/model_providers/xinference/llm/llm.py+++ b/api/core/model_runtime/model_providers/xinference/llm/llm.py@@ -1,5 +1,5 @@from collections.abc import Generator, Iterator-from typing import cast+from typing import Optional, castfrom openai import (APIConnectionError,@@ -321,7 +321,7 @@ class XinferenceAILargeLanguageModel(LargeLanguageModel):return message_dict- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/xinference/rerank/rerank.py b/api/core/model_runtime/model_providers/xinference/rerank/rerank.pyindex 6368cd76dc9..efaf114854b 100644--- a/api/core/model_runtime/model_providers/xinference/rerank/rerank.py+++ b/api/core/model_runtime/model_providers/xinference/rerank/rerank.py@@ -142,7 +142,7 @@ class XinferenceRerankModel(RerankModel):InvokeBadRequestError: [InvokeBadRequestError, KeyError, ValueError],}- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/xinference/speech2text/speech2text.py b/api/core/model_runtime/model_providers/xinference/speech2text/speech2text.pyindex c5ad3839118..3d7aefeb6dd 100644--- a/api/core/model_runtime/model_providers/xinference/speech2text/speech2text.py+++ b/api/core/model_runtime/model_providers/xinference/speech2text/speech2text.py@@ -129,7 +129,7 @@ class XinferenceSpeech2TextModel(Speech2TextModel):return response["text"]- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/xinference/text_embedding/text_embedding.py b/api/core/model_runtime/model_providers/xinference/text_embedding/text_embedding.pyindex f64b9c50afb..e51e6a941c5 100644--- a/api/core/model_runtime/model_providers/xinference/text_embedding/text_embedding.py+++ b/api/core/model_runtime/model_providers/xinference/text_embedding/text_embedding.py@@ -184,7 +184,7 @@ class XinferenceTextEmbeddingModel(TextEmbeddingModel):return usage- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""diff --git a/api/core/model_runtime/model_providers/xinference/tts/tts.py b/api/core/model_runtime/model_providers/xinference/tts/tts.pyindex 3f46b50c338..ad7b64efb5d 100644--- a/api/core/model_runtime/model_providers/xinference/tts/tts.py+++ b/api/core/model_runtime/model_providers/xinference/tts/tts.py@@ -116,7 +116,7 @@ class XinferenceText2SpeechModel(TTSModel):"""return self._tts_invoke_streaming(model, credentials, content_text, voice)- def get_customizable_model_schema(self, model: str, credentials: dict) -> AIModelEntity | None:+ def get_customizable_model_schema(self, model: str, credentials: dict) -> Optional[AIModelEntity]:"""used to define customizable model schema"""