From 0ba9d1c3292a9041f15031722eb3941ae340acf5 Mon Sep 17 00:00:00 2001 From: Smillence Date: Fri, 1 Nov 2024 20:45:14 +0800 Subject: [PATCH 1/2] sys_code nullable --- assets/schema/dbgpt.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assets/schema/dbgpt.sql b/assets/schema/dbgpt.sql index 039c6ddb7..4b3403220 100644 --- a/assets/schema/dbgpt.sql +++ b/assets/schema/dbgpt.sql @@ -388,7 +388,7 @@ CREATE TABLE `gpts_app_collection` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id', `app_code` varchar(255) NOT NULL COMMENT 'Current AI assistant code', `user_code` int(11) NOT NULL COMMENT 'user code', - `sys_code` varchar(255) NOT NULL COMMENT 'system app code', + `sys_code` varchar(255) NULL COMMENT 'system app code', `created_at` datetime DEFAULT NULL COMMENT 'create time', `updated_at` datetime DEFAULT NULL COMMENT 'last update time', PRIMARY KEY (`id`), @@ -439,10 +439,10 @@ CREATE TABLE `recommend_question` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id', `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time', `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last update time', - `app_code` varchar(255) DEFAULT NULL COMMENT 'Current AI assistant code', + `app_code` varchar(255) NOT NULL COMMENT 'Current AI assistant code', `question` text DEFAULT NULL COMMENT 'question', `user_code` int(11) NOT NULL COMMENT 'user code', - `sys_code` varchar(255) NOT NULL COMMENT 'system app code', + `sys_code` varchar(255) NULL COMMENT 'system app code', `valid` varchar(10) DEFAULT 'true' COMMENT 'is it effective,true/false', `chat_mode` varchar(255) DEFAULT NULL COMMENT 'Conversation scene mode,chat_knowledge...', `params` text DEFAULT NULL COMMENT 'question param', @@ -456,7 +456,7 @@ CREATE TABLE `user_recent_apps` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id', `gmt_create` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time', `gmt_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last update time', - `app_code` varchar(255) DEFAULT NULL COMMENT 'AI assistant code', + `app_code` varchar(255) NOT NULL COMMENT 'AI assistant code', `last_accessed` timestamp NULL DEFAULT NULL COMMENT 'User recent usage time', `user_code` varchar(255) DEFAULT NULL COMMENT 'user code', `sys_code` varchar(255) DEFAULT NULL COMMENT 'system app code', From 23597d137285c924f1e21407d3e2afc7c7a046dd Mon Sep 17 00:00:00 2001 From: Smillence Date: Mon, 4 Nov 2024 22:06:11 +0800 Subject: [PATCH 2/2] support spark ultra/max/pro;add web/env.template --- dbgpt/model/proxy/llms/spark.py | 32 ++++++++++++++++++++++++++++++-- web/.env.template | 1 + 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 web/.env.template diff --git a/dbgpt/model/proxy/llms/spark.py b/dbgpt/model/proxy/llms/spark.py index 8c31a70f8..adbb647eb 100644 --- a/dbgpt/model/proxy/llms/spark.py +++ b/dbgpt/model/proxy/llms/spark.py @@ -135,15 +135,43 @@ def __init__( context_length: Optional[int] = 4096, executor: Optional[Executor] = None, ): + """ + Tips: 星火大模型API当前有Lite、Pro、Pro-128K、Max、Max-32K和4.0 Ultra六个版本,各版本独立计量tokens。 + 传输协议 :ws(s),为提高安全性,强烈推荐wss + + Spark4.0 Ultra 请求地址,对应的domain参数为4.0Ultra: + wss://spark-api.xf-yun.com/v4.0/chat + + Spark Max-32K请求地址,对应的domain参数为max-32k + wss://spark-api.xf-yun.com/chat/max-32k + + Spark Max请求地址,对应的domain参数为generalv3.5 + wss://spark-api.xf-yun.com/v3.5/chat + + Spark Pro-128K请求地址,对应的domain参数为pro-128k: + wss://spark-api.xf-yun.com/chat/pro-128k + + Spark Pro请求地址,对应的domain参数为generalv3: + wss://spark-api.xf-yun.com/v3.1/chat + + Spark Lite请求地址,对应的domain参数为lite: + wss://spark-api.xf-yun.com/v1.1/chat + """ if not model_version: model_version = model or os.getenv("XUNFEI_SPARK_API_VERSION") if not api_base: if model_version == SPARK_DEFAULT_API_VERSION: api_base = "ws://spark-api.xf-yun.com/v3.1/chat" domain = "generalv3" + elif model_version == "v4.0": + api_base = "ws://spark-api.xf-yun.com/v4.0/chat" + domain = "4.0Ultra" + elif model_version == "v3.5": + api_base = "ws://spark-api.xf-yun.com/v3.5/chat" + domain = "generalv3.5" else: - api_base = "ws://spark-api.xf-yun.com/v2.1/chat" - domain = "generalv2" + api_base = "ws://spark-api.xf-yun.com/v1.1/chat" + domain = "lite" if not api_domain: api_domain = domain self._model = model diff --git a/web/.env.template b/web/.env.template new file mode 100644 index 000000000..39bf56c45 --- /dev/null +++ b/web/.env.template @@ -0,0 +1 @@ +API_BASE_URL=http://127.0.0.1:5670 \ No newline at end of file