mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-30 15:21:02 +00:00
Fix llm strategy store and update app/static. (#1181)
Co-authored-by: lcxadml <864255598@qq.com>
This commit is contained in:
parent
ab5e1c7ea1
commit
21682575f5
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
||||
self.__BUILD_MANIFEST=function(s,c,a,e,t,n,f,d,k,h,i,u,b,j,p,o,g,l,r){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[p,s,c,e,a,h,f,d,o,"static/chunks/9305-f44429d5185a9fc7.js","static/chunks/7299-cb3b5c1ad528f20a.js","static/chunks/pages/index-60038165daa70046.js"],"/_error":["static/chunks/pages/_error-8095ba9e1bf12f30.js"],"/agent":[s,c,a,t,h,n,"static/chunks/pages/agent-ce4aada0ffb26742.js"],"/app":[i,s,c,e,a,t,n,u,b,"static/chunks/7958-ed34baf152e6e252.js",j,"static/chunks/pages/app-75e39485cc4a24b3.js"],"/chat":["static/chunks/pages/chat-1434817946faf8ff.js"],"/database":[s,c,e,a,t,n,d,k,"static/chunks/7902-94d75aab69ac7c8d.js","static/chunks/pages/database-5b649049b3adcaf7.js"],"/flow":[i,u,b,j,"static/chunks/pages/flow-c83aa1081ec293f9.js"],"/flow/canvas":[p,i,s,c,e,a,f,d,u,k,b,g,o,"static/chunks/4350-1896c46dd5e9afe8.js",j,"static/chunks/pages/flow/canvas-d313d1fe05a1d9e1.js"],"/knowledge":[l,s,c,a,t,h,n,d,k,r,g,"static/chunks/8660-25eebcb95c34109b.js","static/chunks/pages/knowledge-3b36ed0feb6e3138.js"],"/knowledge/chunk":[s,e,t,f,n,"static/chunks/pages/knowledge/chunk-148ca5920e6a3447.js"],"/models":[l,s,c,e,a,k,"static/chunks/3444-30181eacc7980e66.js","static/chunks/pages/models-a019e728f75142a1.js"],"/prompt":[s,c,e,a,f,r,"static/chunks/4733-cc041bf7a3d12e39.js","static/chunks/5396-3e98ef6b437678bd.js","static/chunks/pages/prompt-8ac6786093609ab9.js"],sortedPages:["/","/_app","/_error","/agent","/app","/chat","/database","/flow","/flow/canvas","/knowledge","/knowledge/chunk","/models","/prompt"]}}("static/chunks/7113-c0c4ee5dc30929ba.js","static/chunks/5503-c65f6d730754acc7.js","static/chunks/9479-21f588e1fd4e6b6d.js","static/chunks/1009-f20562de52b03b76.js","static/chunks/4442-2fd5fdaab894a502.js","static/chunks/5813-c6244a8eba7ef4ae.js","static/chunks/4810-1e930464030aee69.js","static/chunks/411-b5d3e7f64bee2335.js","static/chunks/8928-0e78def492052d13.js","static/chunks/4553-5a62c446efb06d63.js","static/chunks/971df74e-7436ff4085ebb785.js","static/chunks/7434-29506257e67e8077.js","static/chunks/9924-5bce555f07385e1f.js","static/css/b4846eed11c4725f.css","static/chunks/29107295-75edf0bf34e24b1e.js","static/chunks/2487-24749b0b156943d8.js","static/chunks/6485-a0f49ba464882399.js","static/chunks/75fc9c18-1d6133135d3d283c.js","static/chunks/8548-e633dfc38edeb044.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
||||
self.__BUILD_MANIFEST=function(s,c,a,e,t,n,d,f,k,b,h,i,u,j,p,o,g,l,r){return{__rewrites:{beforeFiles:[],afterFiles:[],fallback:[]},"/":[p,s,c,e,a,b,d,f,o,"static/chunks/9305-f44429d5185a9fc7.js","static/chunks/7299-cb3b5c1ad528f20a.js","static/chunks/pages/index-60038165daa70046.js"],"/_error":["static/chunks/pages/_error-8095ba9e1bf12f30.js"],"/agent":[s,c,a,t,b,n,"static/chunks/pages/agent-ce4aada0ffb26742.js"],"/app":[h,s,c,e,a,t,n,i,u,"static/chunks/7958-ed34baf152e6e252.js",j,"static/chunks/pages/app-3b436b62369b5dee.js"],"/chat":["static/chunks/pages/chat-b09234393c5f8ad7.js"],"/database":[s,c,e,a,t,n,f,k,"static/chunks/7902-94d75aab69ac7c8d.js","static/chunks/pages/database-5b649049b3adcaf7.js"],"/flow":[h,i,u,j,"static/chunks/pages/flow-c83aa1081ec293f9.js"],"/flow/canvas":[p,h,s,c,e,a,d,f,i,k,u,g,o,"static/chunks/4350-1896c46dd5e9afe8.js",j,"static/chunks/pages/flow/canvas-d313d1fe05a1d9e1.js"],"/knowledge":[l,s,c,a,t,b,n,f,k,r,g,"static/chunks/8660-25eebcb95c34109b.js","static/chunks/pages/knowledge-3b36ed0feb6e3138.js"],"/knowledge/chunk":[s,e,t,d,n,"static/chunks/pages/knowledge/chunk-148ca5920e6a3447.js"],"/models":[l,s,c,e,a,k,"static/chunks/3444-30181eacc7980e66.js","static/chunks/pages/models-a019e728f75142a1.js"],"/prompt":[s,c,e,a,d,r,"static/chunks/4733-cc041bf7a3d12e39.js","static/chunks/5396-3e98ef6b437678bd.js","static/chunks/pages/prompt-8ac6786093609ab9.js"],sortedPages:["/","/_app","/_error","/agent","/app","/chat","/database","/flow","/flow/canvas","/knowledge","/knowledge/chunk","/models","/prompt"]}}("static/chunks/7113-c0c4ee5dc30929ba.js","static/chunks/5503-c65f6d730754acc7.js","static/chunks/9479-21f588e1fd4e6b6d.js","static/chunks/1009-f20562de52b03b76.js","static/chunks/4442-2fd5fdaab894a502.js","static/chunks/5813-c6244a8eba7ef4ae.js","static/chunks/4810-1e930464030aee69.js","static/chunks/411-b5d3e7f64bee2335.js","static/chunks/8928-0e78def492052d13.js","static/chunks/4553-5a62c446efb06d63.js","static/chunks/971df74e-7436ff4085ebb785.js","static/chunks/7434-29506257e67e8077.js","static/chunks/9924-5bce555f07385e1f.js","static/css/b4846eed11c4725f.css","static/chunks/29107295-75edf0bf34e24b1e.js","static/chunks/2487-24749b0b156943d8.js","static/chunks/6485-a0f49ba464882399.js","static/chunks/75fc9c18-1d6133135d3d283c.js","static/chunks/8548-e633dfc38edeb044.js"),self.__BUILD_MANIFEST_CB&&self.__BUILD_MANIFEST_CB();
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -90,7 +90,7 @@ class MultiAgents(BaseComponent, ABC):
|
||||
def get_dbgpts(self, user_code: str = None, sys_code: str = None):
|
||||
apps = self.gpts_app.app_list(
|
||||
GptsAppQuery(user_code=user_code, sys_code=sys_code)
|
||||
)
|
||||
).app_list
|
||||
return apps
|
||||
|
||||
async def agent_chat(
|
||||
|
@ -39,7 +39,7 @@ async def create(gpts_app: GptsApp):
|
||||
@router.post("/v1/app/list")
|
||||
async def app_list(query: GptsAppQuery):
|
||||
try:
|
||||
return Result.succ(gpts_dao.app_list(query))
|
||||
return Result.succ(gpts_dao.app_list(query, True))
|
||||
except Exception as ex:
|
||||
return Result.failed(code="E000X", msg=f"query app error: {ex}")
|
||||
|
||||
|
@ -47,7 +47,14 @@ class GptsAppDetail(BaseModel):
|
||||
return value
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, d: Dict[str, Any]):
|
||||
def from_dict(cls, d: Dict[str, Any], parse_llm_strategy: bool = False):
|
||||
lsv = d.get("llm_strategy_value")
|
||||
if parse_llm_strategy and lsv:
|
||||
strategies = json.loads(lsv)
|
||||
llm_strategy_value = ",".join(strategies)
|
||||
else:
|
||||
llm_strategy_value = d.get("llm_strategy_value", None)
|
||||
|
||||
return cls(
|
||||
app_code=d["app_code"],
|
||||
app_name=d["app_name"],
|
||||
@ -56,7 +63,7 @@ class GptsAppDetail(BaseModel):
|
||||
resources=AgentResource.from_josn_list_str(d.get("resources", None)),
|
||||
prompt_template=d.get("prompt_template", None),
|
||||
llm_strategy=d.get("llm_strategy", None),
|
||||
llm_strategy_value=d.get("llm_strategy_value", None),
|
||||
llm_strategy_value=llm_strategy_value,
|
||||
created_at=d.get("created_at", None),
|
||||
updated_at=d.get("updated_at", None),
|
||||
)
|
||||
@ -135,6 +142,13 @@ class GptsAppQuery(GptsApp):
|
||||
is_collected: Optional[str] = None
|
||||
|
||||
|
||||
class GptsAppResponse(BaseModel):
|
||||
total_count: Optional[int] = 0
|
||||
total_page: Optional[int] = 0
|
||||
current_page: Optional[int] = 0
|
||||
app_list: Optional[List[GptsApp]] = []
|
||||
|
||||
|
||||
class GptsAppCollection(BaseModel):
|
||||
app_code: Optional[str] = None
|
||||
user_code: Optional[str] = None
|
||||
@ -318,7 +332,7 @@ class GptsAppCollectionDao(BaseDao):
|
||||
|
||||
|
||||
class GptsAppDao(BaseDao):
|
||||
def app_list(self, query: GptsAppQuery):
|
||||
def app_list(self, query: GptsAppQuery, parse_llm_strategy: bool = False):
|
||||
collection_dao = GptsAppCollectionDao()
|
||||
gpts_collections = collection_dao.list(
|
||||
GptsAppCollection.from_dict(
|
||||
@ -339,6 +353,7 @@ class GptsAppDao(BaseDao):
|
||||
app_qry = app_qry.filter(GptsAppEntity.sys_code == query.sys_code)
|
||||
if query.is_collected and query.is_collected.lower() in ("true", "false"):
|
||||
app_qry = app_qry.filter(GptsAppEntity.app_code.in_(app_codes))
|
||||
total_count = app_qry.count()
|
||||
app_qry = app_qry.order_by(GptsAppEntity.id.desc())
|
||||
app_qry = app_qry.offset((query.page_no - 1) * query.page_size).limit(
|
||||
query.page_size
|
||||
@ -348,6 +363,7 @@ class GptsAppDao(BaseDao):
|
||||
result_app_codes = [res.app_code for res in results]
|
||||
app_details_group = self._group_app_details(result_app_codes, session)
|
||||
apps = []
|
||||
app_resp = GptsAppResponse()
|
||||
for app_info in results:
|
||||
app_details = app_details_group.get(app_info.app_code, [])
|
||||
|
||||
@ -370,13 +386,19 @@ class GptsAppDao(BaseDao):
|
||||
"created_at": app_info.created_at,
|
||||
"updated_at": app_info.updated_at,
|
||||
"details": [
|
||||
GptsAppDetail.from_dict(item.to_dict())
|
||||
GptsAppDetail.from_dict(
|
||||
item.to_dict(), parse_llm_strategy
|
||||
)
|
||||
for item in app_details
|
||||
],
|
||||
}
|
||||
)
|
||||
)
|
||||
return apps
|
||||
app_resp.total_count = total_count
|
||||
app_resp.app_list = apps
|
||||
app_resp.current_page = query.page_no
|
||||
app_resp.total_page = (total_count + query.page_size - 1) // query.page_size
|
||||
return app_resp
|
||||
|
||||
def _group_app_details(self, app_codes, session):
|
||||
app_detail_qry = session.query(GptsAppDetailEntity).filter(
|
||||
@ -483,7 +505,9 @@ class GptsAppDao(BaseDao):
|
||||
resources=json.dumps(resource_dicts, ensure_ascii=False),
|
||||
prompt_template=item.prompt_template,
|
||||
llm_strategy=item.llm_strategy,
|
||||
llm_strategy_value=item.llm_strategy_value,
|
||||
llm_strategy_value=None
|
||||
if item.llm_strategy_value is None
|
||||
else json.dumps(tuple(item.llm_strategy_value.split(","))),
|
||||
created_at=item.created_at,
|
||||
updated_at=item.updated_at,
|
||||
)
|
||||
@ -525,7 +549,9 @@ class GptsAppDao(BaseDao):
|
||||
resources=json.dumps(resource_dicts, ensure_ascii=False),
|
||||
prompt_template=item.prompt_template,
|
||||
llm_strategy=item.llm_strategy,
|
||||
llm_strategy_value=item.llm_strategy_value,
|
||||
llm_strategy_value=None
|
||||
if item.llm_strategy_value is None
|
||||
else json.dumps(tuple(item.llm_strategy_value.split(","))),
|
||||
created_at=item.created_at,
|
||||
updated_at=item.updated_at,
|
||||
)
|
||||
|
@ -33,7 +33,7 @@ import {
|
||||
} from '@/types/knowledge';
|
||||
import { UpdatePromptParams, IPrompt, PromptParams } from '@/types/prompt';
|
||||
import { IFlow, IFlowNode, IFlowResponse, IFlowUpdateParam } from '@/types/flow';
|
||||
import { IAgent, IApp, ITeamModal } from '@/types/app';
|
||||
import { IAgent, IApp, IAppData, ITeamModal } from '@/types/app';
|
||||
|
||||
/** App */
|
||||
export const postScenes = () => {
|
||||
@ -283,7 +283,7 @@ export const addApp = (data: IApp) => {
|
||||
};
|
||||
|
||||
export const getAppList = (data: Record<string, string>) => {
|
||||
return POST<Record<string, string>, IApp[]>('/api/v1/app/list', data);
|
||||
return POST<Record<string, string>, IAppData>('/api/v1/app/list', data);
|
||||
};
|
||||
|
||||
export const collectApp = (data: Record<string, string>) => {
|
||||
|
@ -55,7 +55,7 @@ export default function App() {
|
||||
}
|
||||
if (!data) return;
|
||||
|
||||
setApps(data || []);
|
||||
setApps(data.app_list || []);
|
||||
setSpinning(false);
|
||||
};
|
||||
|
||||
|
@ -31,6 +31,13 @@ export type IApp = {
|
||||
is_collected: string;
|
||||
};
|
||||
|
||||
export type IAppData = {
|
||||
app_list: IApp[];
|
||||
current_page: number;
|
||||
total_count: number;
|
||||
total_page: number;
|
||||
};
|
||||
|
||||
// agent
|
||||
export type AgentParams = {
|
||||
agent_name: string;
|
||||
|
Loading…
Reference in New Issue
Block a user