feat: (0.6)New UI (#1855)

Co-authored-by: 夏姜 <wenfengjiang.jwf@digital-engine.com>
Co-authored-by: aries_ckt <916701291@qq.com>
Co-authored-by: wb-lh513319 <wb-lh513319@alibaba-inc.com>
Co-authored-by: csunny <cfqsunny@163.com>
This commit is contained in:
明天
2024-08-21 17:37:45 +08:00
committed by GitHub
parent 3fc82693ba
commit b124ecc10b
824 changed files with 93371 additions and 2515 deletions

View File

@@ -1,12 +1,12 @@
"""This is an auto-generated model file
You can define your own models and DAOs here
"""
import uuid
from datetime import datetime
from typing import Any, Dict, Union
from sqlalchemy import Column, DateTime, Index, Integer, String, Text, UniqueConstraint
from dbgpt._private.pydantic import model_to_dict
from dbgpt.storage.metadata import BaseDao, Model, db
from ..api.schemas import ServeRequest, ServerResponse
@@ -28,12 +28,14 @@ class ServeEntity(Model):
chat_scene = Column(String(100), comment="Chat scene")
sub_chat_scene = Column(String(100), comment="Sub chat scene")
prompt_code = Column(String(256), comment="Prompt Code")
prompt_type = Column(String(100), comment="Prompt type(eg: common, private)")
prompt_name = Column(String(256), comment="Prompt name")
content = Column(Text, comment="Prompt content")
input_variables = Column(
String(1024), nullable=True, comment="Prompt input variables(split by comma))"
)
response_schema = Column(Text, comment="Prompt response schema")
model = Column(
String(128),
nullable=True,
@@ -50,6 +52,7 @@ class ServeEntity(Model):
comment="Prompt format(eg: f-string, jinja2)",
)
prompt_desc = Column(String(512), nullable=True, comment="Prompt description")
user_code = Column(String(128), index=True, nullable=True, comment="User code")
user_name = Column(String(128), index=True, nullable=True, comment="User name")
sys_code = Column(String(128), index=True, nullable=True, comment="System code")
gmt_created = Column(DateTime, default=datetime.now, comment="Record creation time")
@@ -59,7 +62,7 @@ class ServeEntity(Model):
return (
f"ServeEntity(id={self.id}, chat_scene='{self.chat_scene}', sub_chat_scene='{self.sub_chat_scene}', "
f"prompt_type='{self.prompt_type}', prompt_name='{self.prompt_name}', content='{self.content}',"
f"user_name='{self.user_name}', gmt_created='{self.gmt_created}', gmt_modified='{self.gmt_modified}')"
f"user_code='{self.user_code}', user_name='{self.user_name}', gmt_created='{self.gmt_created}', gmt_modified='{self.gmt_modified}')"
)
@@ -79,10 +82,10 @@ class ServeDao(BaseDao[ServeEntity, ServeRequest, ServerResponse]):
Returns:
T: The entity
"""
request_dict = (
model_to_dict(request) if isinstance(request, ServeRequest) else request
)
request_dict = request.dict() if isinstance(request, ServeRequest) else request
entity = ServeEntity(**request_dict)
if not entity.prompt_code:
entity.prompt_code = uuid.uuid4().hex
return entity
def to_request(self, entity: ServeEntity) -> ServeRequest:
@@ -99,8 +102,10 @@ class ServeDao(BaseDao[ServeEntity, ServeRequest, ServerResponse]):
sub_chat_scene=entity.sub_chat_scene,
prompt_type=entity.prompt_type,
prompt_name=entity.prompt_name,
prompt_code=entity.prompt_code,
content=entity.content,
prompt_desc=entity.prompt_desc,
user_code=entity.user_code,
user_name=entity.user_name,
sys_code=entity.sys_code,
)
@@ -121,11 +126,16 @@ class ServeDao(BaseDao[ServeEntity, ServeRequest, ServerResponse]):
id=entity.id,
chat_scene=entity.chat_scene,
sub_chat_scene=entity.sub_chat_scene,
prompt_code=entity.prompt_code,
prompt_type=entity.prompt_type,
prompt_name=entity.prompt_name,
content=entity.content,
prompt_desc=entity.prompt_desc,
user_name=entity.user_name,
user_code=entity.user_code,
model=entity.model,
input_variables=entity.input_variables,
prompt_language=entity.prompt_language,
sys_code=entity.sys_code,
gmt_created=gmt_created_str,
gmt_modified=gmt_modified_str,