Skip to content

Commit

Permalink
Feat support xunfei spark ultra/max/pro/lite (#2117)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiyizi authored Nov 6, 2024
1 parent 25d47ce commit 8593f10
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
8 changes: 4 additions & 4 deletions assets/schema/dbgpt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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`),
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down
32 changes: 30 additions & 2 deletions dbgpt/model/proxy/llms/spark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions web/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_BASE_URL=http://127.0.0.1:5670

0 comments on commit 8593f10

Please sign in to comment.