Skip to content

Commit

Permalink
feat(web): copy awel flow (#1200)
Browse files Browse the repository at this point in the history
Co-authored-by: Fangyin Cheng <[email protected]>
  • Loading branch information
2976151305 and fangyinc authored Feb 28, 2024
1 parent 0837da4 commit 673ddaa
Show file tree
Hide file tree
Showing 68 changed files with 898 additions and 190 deletions.
14 changes: 7 additions & 7 deletions assets/schema/dbgpt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ CREATE TABLE IF NOT EXISTS `prompt_manage`
PRIMARY KEY (`id`),
UNIQUE KEY `uk_gpts_conversations` (`conv_id`),
KEY `idx_gpts_name` (`gpts_name`)
) ENGINE=InnoDB AUTO_INCREMENT=26 DEFAULT CHARSET=utf8mb4 COMMENT="gpt conversations";
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT="gpt conversations";

CREATE TABLE IF NOT EXISTS `gpts_instance` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id',
Expand All @@ -222,7 +222,7 @@ CREATE TABLE IF NOT EXISTS `gpts_instance` (
`is_sustainable` tinyint(1) NOT NULL COMMENT 'Applications for sustainable dialogue',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_gpts` (`gpts_name`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COMMENT="gpts instance";
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT="gpts instance";

CREATE TABLE `gpts_messages` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id',
Expand All @@ -241,7 +241,7 @@ CREATE TABLE `gpts_messages` (
`updated_at` datetime DEFAULT NULL COMMENT 'last update time',
PRIMARY KEY (`id`),
KEY `idx_q_messages` (`conv_id`,`rounds`,`sender`)
) ENGINE=InnoDB AUTO_INCREMENT=100 DEFAULT CHARSET=utf8mb4 COMMENT="gpts message";
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT="gpts message";


CREATE TABLE `gpts_plans` (
Expand All @@ -262,7 +262,7 @@ CREATE TABLE `gpts_plans` (
`updated_at` datetime DEFAULT NULL COMMENT 'last update time',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_sub_task` (`conv_id`,`sub_task_num`)
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4 COMMENT="gpt plan";
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT="gpt plan";

-- dbgpt.dbgpt_serve_flow definition
CREATE TABLE `dbgpt_serve_flow` (
Expand Down Expand Up @@ -290,7 +290,7 @@ CREATE TABLE `dbgpt_serve_flow` (
KEY `ix_dbgpt_serve_flow_dag_id` (`dag_id`),
KEY `ix_dbgpt_serve_flow_user_name` (`user_name`),
KEY `ix_dbgpt_serve_flow_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- dbgpt.gpts_app definition
CREATE TABLE `gpts_app` (
Expand All @@ -308,7 +308,7 @@ CREATE TABLE `gpts_app` (
`icon` varchar(1024) DEFAULT NULL COMMENT 'app icon, url',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_gpts_app` (`app_name`)
) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `gpts_app_collection` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'autoincrement id',
Expand Down Expand Up @@ -337,7 +337,7 @@ CREATE TABLE `gpts_app_detail` (
`updated_at` datetime DEFAULT NULL COMMENT 'last update time',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_gpts_app_agent_node` (`app_name`,`agent_name`,`node_id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE
DATABASE IF NOT EXISTS EXAMPLE_1;
Expand Down
3 changes: 3 additions & 0 deletions assets/schema/upgrade/v0_5_1/upgrade_to_v0.5.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
USE dbgpt;
ALTER TABLE dbgpt_serve_flow
ADD COLUMN `error_message` varchar(512) null comment 'Error message' after `state`;
394 changes: 394 additions & 0 deletions assets/schema/upgrade/v0_5_1/v0.5.0.sql

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions dbgpt/app/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ def _migration_db_storage(param: "WebServerParameters"):
f"Create all tables stored in this metadata error: {str(e)}"
)

_ddl_init_and_upgrade(
default_meta_data_path, param.disable_alembic_upgrade
)
_ddl_init_and_upgrade(default_meta_data_path, param.disable_alembic_upgrade)
else:
warn_msg = """For safety considerations, MySQL Database not support DDL init and upgrade. "
"1.If you are use DB-GPT firstly, please manually execute the following command to initialize,
Expand Down
25 changes: 12 additions & 13 deletions dbgpt/app/dbgpt_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from fastapi.staticfiles import StaticFiles

from dbgpt._private.config import Config
from dbgpt._version import version
from dbgpt.app.base import (
WebServerParameters,
_create_model_start_listener,
Expand Down Expand Up @@ -50,7 +51,7 @@
app = FastAPI(
title="DBGPT OPEN API",
description="This is dbgpt, with auto docs for the API and everything",
version="0.5.0",
version=version,
openapi_tags=[],
)
# Use custom router to support priority
Expand Down Expand Up @@ -78,17 +79,6 @@ async def custom_swagger_ui_html():

system_app = SystemApp(app)

origins = ["*"]

# 添加跨域中间件
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
allow_headers=["*"],
)


def mount_routers(app: FastAPI):
"""Lazy import to avoid high time cost"""
Expand Down Expand Up @@ -216,8 +206,17 @@ def run_uvicorn(param: WebServerParameters):
import uvicorn

setup_http_service_logging()

# https://github.com/encode/starlette/issues/617
cors_app = CORSMiddleware(
app=app,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
allow_headers=["*"],
)
uvicorn.run(
app,
cors_app,
host=param.host,
port=param.port,
log_level=logging_str_to_uvicorn_level(param.log_level),
Expand Down
2 changes: 1 addition & 1 deletion dbgpt/app/static/404.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/404/index.html

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions dbgpt/app/static/_next/static/chunks/1009-4b2af86bde623424.js

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions dbgpt/app/static/_next/static/chunks/1009-f20562de52b03b76.js

This file was deleted.

16 changes: 16 additions & 0 deletions dbgpt/app/static/_next/static/chunks/2185-30f9d0578fa0d631.js

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 673ddaa

Please sign in to comment.