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
feat: add spark v3.0 llm support (#1434)
takatost076f3289d294
diff --git a/api/core/model_providers/providers/spark_provider.py b/api/core/model_providers/providers/spark_provider.pyindex 4174c011635..bd95db4890e 100644--- a/api/core/model_providers/providers/spark_provider.py+++ b/api/core/model_providers/providers/spark_provider.py@@ -28,14 +28,19 @@ class SparkProvider(BaseModelProvider):if model_type == ModelType.TEXT_GENERATION:return [{- 'id': 'spark',- 'name': 'Spark V1.5',+ 'id': 'spark-v3',+ 'name': 'Spark V3.0','mode': ModelMode.CHAT.value,},{'id': 'spark-v2','name': 'Spark V2.0','mode': ModelMode.CHAT.value,+ },+ {+ 'id': 'spark',+ 'name': 'Spark V1.5',+ 'mode': ModelMode.CHAT.value,}]else:@@ -96,7 +101,7 @@ class SparkProvider(BaseModelProvider):try:chat_llm = ChatSpark(- model_name='spark-v2',+ model_name='spark-v3',max_tokens=10,temperature=0.01,**credential_kwargs@@ -110,10 +115,10 @@ class SparkProvider(BaseModelProvider):chat_llm(messages)except SparkError as ex:- # try spark v1.5 if v2.1 failed+ # try spark v2.1 if v3.1 failedtry:chat_llm = ChatSpark(- model_name='spark',+ model_name='spark-v2',max_tokens=10,temperature=0.01,**credential_kwargs@@ -127,10 +132,27 @@ class SparkProvider(BaseModelProvider):chat_llm(messages)except SparkError as ex:- raise CredentialsValidateFailedError(str(ex))- except Exception as ex:- logging.exception('Spark config validation failed')- raise ex+ # try spark v1.5 if v2.1 failed+ try:+ chat_llm = ChatSpark(+ model_name='spark',+ max_tokens=10,+ temperature=0.01,+ **credential_kwargs+ )++ messages = [+ HumanMessage(+ content="ping"+ )+ ]++ chat_llm(messages)+ except SparkError as ex:+ raise CredentialsValidateFailedError(str(ex))+ except Exception as ex:+ logging.exception('Spark config validation failed')+ raise exexcept Exception as ex:logging.exception('Spark config validation failed')raise exdiff --git a/api/core/model_providers/rules/spark.json b/api/core/model_providers/rules/spark.jsonindex a3a01ae4a51..24133107f86 100644--- a/api/core/model_providers/rules/spark.json+++ b/api/core/model_providers/rules/spark.json@@ -22,6 +22,12 @@"completion": "0.36","unit": "0.0001","currency": "RMB"+ },+ "spark-v3": {+ "prompt": "0.36",+ "completion": "0.36",+ "unit": "0.0001",+ "currency": "RMB"}}}\ No newline at end of filediff --git a/api/core/third_party/spark/spark_llm.py b/api/core/third_party/spark/spark_llm.pyindex 542565e7325..828fea75e42 100644--- a/api/core/third_party/spark/spark_llm.py+++ b/api/core/third_party/spark/spark_llm.py@@ -19,9 +19,25 @@ class SparkLLMClient:def __init__(self, model_name: str, app_id: str, api_key: str, api_secret: str, api_domain: Optional[str] = None):domain = 'spark-api.xf-yun.com' if not api_domain else api_domain- api_version = 'v2.1' if model_name == 'spark-v2' else 'v1.1'- self.chat_domain = 'generalv2' if model_name == 'spark-v2' else 'general'+ model_api_configs = {+ 'spark': {+ 'version': 'v1.1',+ 'chat_domain': 'general'+ },+ 'spark-v2': {+ 'version': 'v2.1',+ 'chat_domain': 'generalv2'+ },+ 'spark-v3': {+ 'version': 'v3.1',+ 'chat_domain': 'generalv3'+ }+ }++ api_version = model_api_configs[model_name]['version']++ self.chat_domain = model_api_configs[model_name]['chat_domain']self.api_base = f"wss://{domain}/{api_version}/chat"self.app_id = app_idself.ws_url = self.create_url(