refactor: Add frontend code to DB-GPT (#912)

This commit is contained in:
katakuri
2023-12-11 00:05:42 +08:00
committed by GitHub
parent b8dc9cf11e
commit 43190ca333
189 changed files with 19179 additions and 16 deletions

61
web/types/agent.ts Normal file
View File

@@ -0,0 +1,61 @@
export type PostAgentHubUpdateParams = {
channel: string;
url: string;
branch: string;
authorization: string;
};
export type PostAgentQueryParams = {
page_index: number;
page_size: number;
filter?: {
name?: string;
description?: string;
author?: string;
email?: string;
type?: string;
version?: string;
storage_channel?: string;
storage_url?: string;
};
};
export type IAgentPlugin = {
name: string;
description: string;
email: string;
version: string;
storage_url: string;
download_param: string;
installed: number;
id: number;
author: string;
type: string;
storage_channel: string;
created_at: string;
};
export type PostAgentPluginResponse = {
page_index: number;
page_size: number;
total_page: number;
total_row_count: number;
datas: IAgentPlugin[];
};
export type IMyPlugin = {
user_name: null | string;
id: number;
file_name: string;
version: string;
succ_count: number;
name: string;
tenant: null | string;
user_code: string;
type: string;
use_count: number;
created_at: string;
description: string;
};
export type PostAgentMyPluginResponse = IMyPlugin[];

106
web/types/chat.ts Normal file
View File

@@ -0,0 +1,106 @@
type ChartValue = {
name: string;
type: string;
value: number;
};
/**
* dashboard chart type
*/
export type ChartData = {
chart_desc: string;
chart_name: string;
chart_sql: string;
chart_type: string;
chart_uid: string;
column_name: Array<string>;
values: Array<ChartValue>;
};
export type SceneResponse = {
chat_scene: string;
param_title: string;
scene_describe: string;
scene_name: string;
show_disable: boolean;
};
export type NewDialogueParam = {
chat_mode: string;
model?: string;
};
export type ChatHistoryResponse = IChatDialogueMessageSchema[];
export type IChatDialogueSchema = {
conv_uid: string;
user_input: string;
user_name: string;
chat_mode: 'chat_with_db_execute' | 'chat_excel' | 'chat_with_db_qa' | 'chat_knowledge' | 'chat_dashboard' | 'chat_execution' | 'chat_agent';
select_param: string;
};
export type DialogueListResponse = IChatDialogueSchema[];
export type IChatDialogueMessageSchema = {
role: 'human' | 'view' | 'system' | 'ai';
context: string;
order: number;
time_stamp: number | string | null;
model_name: string;
retry?: boolean;
};
export type ModelType =
| 'proxyllm'
| 'flan-t5-base'
| 'vicuna-13b'
| 'vicuna-7b'
| 'vicuna-13b-v1.5'
| 'vicuna-7b-v1.5'
| 'codegen2-1b'
| 'codet5p-2b'
| 'chatglm-6b-int4'
| 'chatglm-6b'
| 'chatglm2-6b'
| 'chatglm2-6b-int4'
| 'guanaco-33b-merged'
| 'falcon-40b'
| 'gorilla-7b'
| 'gptj-6b'
| 'proxyllm'
| 'chatgpt_proxyllm'
| 'bard_proxyllm'
| 'claude_proxyllm'
| 'wenxin_proxyllm'
| 'tongyi_proxyllm'
| 'zhipu_proxyllm'
| 'llama-2-7b'
| 'llama-2-13b'
| 'llama-2-70b'
| 'baichuan-7b'
| 'baichuan-13b'
| 'baichuan2-7b'
| 'baichuan2-13b'
| 'wizardlm-13b'
| 'llama-cpp'
| (string & {});
export type LLMOption = { label: string; icon: string };
export type FeedBack = {
information?: string;
just_fun?: string;
others?: string;
work_study?: string;
};
export type Reference = {
name: string;
chunks: Array<number>;
};
export type IDB = {
param: string;
type: string;
};

63
web/types/db.ts Normal file
View File

@@ -0,0 +1,63 @@
export type DBOption = { label: string; value: DBType; disabled?: boolean; isFileDb?: boolean; icon: string; desc?: string };
export type DBType =
| 'mysql'
| 'duckdb'
| 'sqlite'
| 'mssql'
| 'clickhouse'
| 'oracle'
| 'postgresql'
| 'db2'
| 'access'
| 'mongodb'
| 'starrocks'
| 'hbase'
| 'redis'
| 'cassandra'
| 'couchbase'
| (string & {});
export type IChatDbSchema = {
comment: string;
db_host: string;
db_name: string;
db_path: string;
db_port: number;
db_pwd: string;
db_type: DBType;
db_user: string;
};
export type DbListResponse = IChatDbSchema[];
export type IChatDbSupportTypeSchema = {
db_type: DBType;
is_file_db: boolean;
};
export type DbSupportTypeResponse = IChatDbSupportTypeSchema[];
export type PostDbParams = Partial<DbListResponse[0] & { file_path: string }>;
export type ChatFeedBackSchema = {
conv_uid: string;
conv_index: number;
question: string;
knowledge_space: string;
score: number;
ques_type: string;
messages: string;
};
export type PromptProps = {
id: number;
chat_scene: string;
sub_chat_scene: string;
prompt_type: string;
content: string;
user_name: string;
prompt_name: string;
gmt_created: string;
gmt_modified: string;
};

48
web/types/editor.ts Normal file
View File

@@ -0,0 +1,48 @@
export type IEditorSQLRound = {
db_name: string;
round: number;
round_name: string;
};
export type GetEditorSQLRoundRequest = IEditorSQLRound[];
export type PostEditorSQLRunParams = {
db_name: string;
sql: string;
};
export type PostEditorChartRunParams = {
db_name: string;
sql?: string;
chart_type?: string;
};
export type PostEditorChartRunResponse = {
sql_data: {
result_info: string;
run_cost: string;
colunms: string[];
values: Record<string, any>[];
};
chart_values: Record<string, any>[];
chart_type: string;
};
export type PostSQLEditorSubmitParams = {
conv_uid: string;
db_name: string;
conv_round?: string | number | null;
old_sql?: string;
old_speak?: string;
new_sql?: string;
new_speak?: string;
};
export type PostEditorSqlParams = {
con_uid: string;
round: string | number;
};
export type PostEditorSqlRequest = {};
export type GetEditorySqlParams = { con_uid: string; round: string | number };

118
web/types/knowledge.ts Normal file
View File

@@ -0,0 +1,118 @@
import { type } from 'os';
export interface ISpace {
context?: any;
desc: string;
docs: string | number;
gmt_created: string;
gmt_modified: string;
id: string | number;
name: string;
owner: string;
vector_type: string;
}
export type AddKnowledgeParams = {
name: string;
vector_type: string;
owner: string;
desc: string;
};
export type BaseDocumentParams = {
doc_name: string;
content: string;
doc_type: string;
};
export type Embedding = {
chunk_overlap: string | number;
chunk_size: string | number;
model: string;
recall_score: string | number;
recall_type: string;
topk: string;
};
export type Prompt = {
max_token: string | number;
scene: string;
template: string;
};
export type Summary = {
max_iteration: number;
concurrency_limit: number;
};
export type IArguments = {
embedding: Embedding;
prompt: Prompt;
summary: Summary;
};
export type DocumentParams = {
doc_name: string;
source?: string;
content: string;
doc_type: string;
};
export type IDocument = {
doc_name: string;
source?: string;
content: string;
doc_type: string;
chunk_size: string | number;
gmt_created: string;
gmt_modified: string;
id: number;
last_sync: string;
result: string;
space: string;
status: string;
vector_ids: string;
};
export type IDocumentResponse = {
data: Array<IDocument>;
page: number;
total: number;
};
export type ChunkListParams = {
document_id?: string | number;
page: number;
page_size: number;
};
export type IChunk = {
content: string;
doc_name: string;
doc_type: string;
document_id: string | number;
gmt_created: string;
gmt_modified: string;
id: string | number;
meta_info: string;
recall_score?: string | number;
};
export type IChunkList = {
data: Array<IChunk>;
page: number;
total: number;
};
export type ArgumentsParams = {
argument: string;
};
export type StepChangeParams = {
label: 'forward' | 'back' | 'finish';
spaceName?: string;
docType?: string;
};
export type SummaryParams = {
doc_id: number;
model_name: string;
conv_uid: string;
};

67
web/types/model.ts Normal file
View File

@@ -0,0 +1,67 @@
export type IModelData = {
chat_scene: string;
model_name: string;
model_type: string;
host: string;
port: number;
manager_host: string;
manager_port: number;
healthy: boolean;
check_healthy: boolean;
prompt_template: string;
last_heartbeat: string;
stream_api: string;
nostream_api: string;
};
export type BaseModelParams = {
host: string;
port: number;
model: string;
worker_type: string;
params: any;
};
export type ModelParams = {
model_name: string;
model_path: string;
proxy_api_key: string;
proxy_server_url: string;
model_type: string;
max_context_size: number;
};
export type StartModelParams = {
host: string;
port: number;
model: string;
worker_type: string;
params: ModelParams;
};
interface ExtMetadata {
tags: string;
}
export type SupportModelParams = {
param_class: string;
param_name: string;
param_type: string;
default_value: string | boolean | number;
description: string;
required: boolean;
valid_values: null;
ext_metadata: ExtMetadata;
};
export type SupportModel = {
model: string;
path: string;
worker_type: string;
path_exist: boolean;
proxy: boolean;
enabled: boolean;
host: string;
port: number;
params: SupportModelParams;
};

23
web/types/prompt.ts Normal file
View File

@@ -0,0 +1,23 @@
export type PromptParams = {
prompt_type: string;
current: number;
pageSize: number;
hideOnSinglePage: boolean;
showQuickJumper: boolean;
};
export interface UpdatePromptParams extends IPrompt {
prompt_type: string;
}
export interface IPrompt {
chat_scene: string;
content: string;
gmt_created: string;
gmt_modified: string;
id: number;
prompt_name: string;
prompt_type: string;
sub_chat_scene: string;
user_name?: string;
}