Repository: eosphoros-ai/DB-GPT-Web
Branch: main
Commit: 4b26a9dbdf9e
Files: 163
Total size: 400.5 KB
Directory structure:
gitextract_231z167n/
├── .eslintrc.json
├── .github/
│ └── ISSUE_TEMPLATE/
│ ├── ✨-feature-request.md
│ ├── 🐛-bug-report.md
│ ├── 📜-documentation.md
│ ├── 🔧-improvement.md
│ └── 🙋-question.md
├── .gitignore
├── .npmrc
├── .vscode/
│ ├── extensions.json
│ └── settings.json
├── README.md
├── app/
│ ├── chat-context.tsx
│ └── i18n.ts
├── client/
│ └── api/
│ ├── index.ts
│ ├── request.ts
│ └── tools/
│ ├── index.ts
│ └── interceptors.ts
├── components/
│ ├── agent/
│ │ ├── market-plugins.tsx
│ │ └── my-plugins.tsx
│ ├── app/
│ │ ├── agent-panel.tsx
│ │ ├── app-card.tsx
│ │ ├── app-modal.tsx
│ │ ├── dag-layout.tsx
│ │ └── resource-card.tsx
│ ├── chart/
│ │ ├── autoChart/
│ │ │ ├── advisor/
│ │ │ │ ├── pipeline.ts
│ │ │ │ ├── rule.ts
│ │ │ │ └── utils.ts
│ │ │ ├── charts/
│ │ │ │ ├── index.ts
│ │ │ │ ├── multi-line-chart.ts
│ │ │ │ ├── multi-measure-column-chart.ts
│ │ │ │ ├── multi-measure-line-chart.ts
│ │ │ │ └── util.ts
│ │ │ ├── helpers/
│ │ │ │ └── index.ts
│ │ │ ├── index.tsx
│ │ │ └── types.ts
│ │ ├── bar-chart.tsx
│ │ ├── index.tsx
│ │ ├── line-chart.tsx
│ │ └── table-chart.tsx
│ ├── chat/
│ │ ├── agent-content.tsx
│ │ ├── chat-container.tsx
│ │ ├── chat-content/
│ │ │ ├── agent-messages.tsx
│ │ │ ├── agent-plans.tsx
│ │ │ ├── chart-view.tsx
│ │ │ ├── code-preview.tsx
│ │ │ ├── config.tsx
│ │ │ ├── index.tsx
│ │ │ ├── vis-chart.tsx
│ │ │ ├── vis-code.tsx
│ │ │ ├── vis-convert-error.tsx
│ │ │ ├── vis-dashboard.tsx
│ │ │ └── vis-plugin.tsx
│ │ ├── chat-feedback.tsx
│ │ ├── completion.tsx
│ │ ├── db-editor.tsx
│ │ ├── doc-list.tsx
│ │ ├── doc-upload.tsx
│ │ ├── header/
│ │ │ ├── agent-selector.tsx
│ │ │ ├── chat-excel.tsx
│ │ │ ├── db-selector.tsx
│ │ │ ├── excel-upload.tsx
│ │ │ ├── index.tsx
│ │ │ └── model-selector.tsx
│ │ ├── mode-tab/
│ │ │ ├── index.css
│ │ │ └── index.tsx
│ │ └── monaco-editor.tsx
│ ├── common/
│ │ ├── FileStatusIcon.tsx
│ │ ├── MyEmpty.tsx
│ │ ├── chat-dialog.tsx
│ │ ├── completion-input.tsx
│ │ ├── db-icon.tsx
│ │ ├── gpt-card.tsx
│ │ ├── icon-wrapper.tsx
│ │ ├── loading.tsx
│ │ └── prompt-bot.tsx
│ ├── database/
│ │ └── form-dialog.tsx
│ ├── flow/
│ │ ├── add-nodes.tsx
│ │ ├── button-edge.tsx
│ │ ├── canvas-node.tsx
│ │ ├── flow-card.tsx
│ │ ├── node-handler.tsx
│ │ ├── node-param-handler.tsx
│ │ ├── preview-flow.tsx
│ │ ├── required-icon.tsx
│ │ └── static-nodes.tsx
│ ├── icons/
│ │ ├── add-icon.tsx
│ │ ├── collect.tsx
│ │ ├── collected.tsx
│ │ ├── colorful-chat.tsx
│ │ ├── colorful-dashboard.tsx
│ │ ├── colorful-data.tsx
│ │ ├── colorful-db.tsx
│ │ ├── colorful-doc.tsx
│ │ ├── colorful-excel.tsx
│ │ ├── colorful-plugin.tsx
│ │ ├── dark-svg.tsx
│ │ ├── db-svg.tsx
│ │ ├── done-icon.tsx
│ │ ├── file-done.tsx
│ │ ├── file-error.tsx
│ │ ├── file-sync.tsx
│ │ ├── index.tsx
│ │ ├── knowledge.tsx
│ │ ├── model-svg.tsx
│ │ ├── pending-icon.tsx
│ │ ├── stars-svg.tsx
│ │ ├── sunny-svg.tsx
│ │ └── sync-icon.tsx
│ ├── knowledge/
│ │ ├── arguments-modal.tsx
│ │ ├── doc-icon.tsx
│ │ ├── doc-panel.tsx
│ │ ├── doc-type-form.tsx
│ │ ├── doc-upload-form.tsx
│ │ ├── segmentation.tsx
│ │ ├── space-card.tsx
│ │ ├── space-form.tsx
│ │ └── strategy-form.tsx
│ ├── layout/
│ │ ├── side-bar.tsx
│ │ └── top-progress-bar.tsx
│ ├── model/
│ │ ├── model-card.tsx
│ │ ├── model-form.tsx
│ │ └── model-params.tsx
│ └── prompt/
│ └── prompt-form.tsx
├── defaultTheme.ts
├── genAntdCss.ts
├── global.d.ts
├── hooks/
│ ├── use-chat.ts
│ └── use-summary.ts
├── next.config.js
├── nprogress.css
├── package.json
├── pages/
│ ├── _app.tsx
│ ├── _document.tsx
│ ├── agent/
│ │ └── index.tsx
│ ├── app/
│ │ └── index.tsx
│ ├── chat/
│ │ └── index.tsx
│ ├── database/
│ │ └── index.tsx
│ ├── flow/
│ │ ├── canvas/
│ │ │ └── index.tsx
│ │ └── index.tsx
│ ├── index.tsx
│ ├── knowledge/
│ │ ├── chunk/
│ │ │ └── index.tsx
│ │ └── index.tsx
│ ├── models/
│ │ └── index.tsx
│ └── prompt/
│ └── index.tsx
├── postcss.config.js
├── styles/
│ └── globals.css
├── tailwind.config.js
├── tsconfig.json
├── types/
│ ├── agent.ts
│ ├── app.ts
│ ├── chat.ts
│ ├── db.ts
│ ├── editor.ts
│ ├── flow.ts
│ ├── knowledge.ts
│ ├── model.ts
│ └── prompt.ts
└── utils/
├── constants.ts
├── ctx-axios.ts
├── flow.ts
├── index.ts
├── request.ts
└── storage.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .eslintrc.json
================================================
{
"extends": "next/core-web-vitals"
}
================================================
FILE: .github/ISSUE_TEMPLATE/✨-feature-request.md
================================================
---
name: "✨ Feature Request"
about: Suggest a new feature idea.
title: "[feature]"
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: .github/ISSUE_TEMPLATE/🐛-bug-report.md
================================================
---
name: "\U0001F41B Bug report"
about: Report an unexpected problem or unintended behavior.
title: "[BUG] "
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]
**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]
**Additional context**
Add any other context about the problem here.
================================================
FILE: .github/ISSUE_TEMPLATE/📜-documentation.md
================================================
---
name: "\U0001F4DC Documentation"
about: Correct spelling errors, improvements or additions to documentation files (README,
CONTRIBUTING...).
title: "[Doc]"
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: .github/ISSUE_TEMPLATE/🔧-improvement.md
================================================
---
name: "\U0001F527 Improvement"
about: Suggest an idea which is not a feature.
title: ''
labels: ''
assignees: ''
---
### Expected Behavior
### Actual Behavior
### Proposal
================================================
FILE: .github/ISSUE_TEMPLATE/🙋-question.md
================================================
---
name: "\U0001F64B Question"
about: Ask a question about DB-GPT-Web.
title: ''
labels: ''
assignees: ''
---
### Question
================================================
FILE: .gitignore
================================================
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
.idea
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
mock
# local env files
.env.prod
.env
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts
.next
================================================
FILE: .npmrc
================================================
registry=http://registry.npmjs.org
================================================
FILE: .vscode/extensions.json
================================================
{
"recommendations": [
"bradlc.vscode-tailwindcss",
"esbenp.prettier-vscode",
"dbaeumer.vscode-eslint",
"formulahendry.auto-close-tag",
"formulahendry.auto-rename-tag",
"vincaslt.highlight-matching-tag",
"ionutvmi.path-autocomplete"
]
}
================================================
FILE: .vscode/settings.json
================================================
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"prettier.arrowParens": "always",
"prettier.tabWidth": 2,
"prettier.printWidth": 150,
"prettier.singleQuote": true,
"prettier.semi": true,
"prettier.trailingComma": "all",
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"tailwindCSS.includeLanguages": {
"plaintext": "typescriptreact"
},
"editor.quickSuggestions": {
"strings": true
},
"cSpell.words": ["DBGPT"]
}
================================================
FILE: README.md
================================================
DB-GPT-Web
_DB-GPT Chat UI, LLM to Vision.
_
---
## 👋 Introduction
***DB-GPT-Web*** is an **Open source chat UI** for [**DB-GPT**](https://github.com/eosphoros-ai/DB-GPT).
Also, it is a **LLM to Vision** solution.
[DB-GPT-Web](https://dbgpt.site) is an Open source Tailwind and Next.js based chat UI for AI and GPT projects. It beautify a lot of markdown labels, such as `table`, `thead`, `th`, `td`, `code`, `h1`, `h2`, `ul`, `li`, `a`, `img`. Also it define some custom labels to adapted to AI-specific scenarios. Such as `plugin running`, `knowledge name`, `Chart view`, and so on.
## 💪🏻 Getting Started
### Prerequisites
- [Node.js](https://nodejs.org/) >= 16
- [npm](https://npmjs.com/) >= 8
- Supported OSes: Linux, macOS and Windows
### Installation
```sh
# Install dependencies
npm install
```
### Usage
```sh
cp .env.example .env
```
edit the `API_BASE_URL` to the real address
```sh
# development model
npm run dev
```
## 🚀 Use In DB-GPT
```sh
npm run compile
# copy compile file to DB-GPT static file dictory
cp -rf out/* ../dbgpt/app/static
```
## 📚 Documentation
For full documentation, visit [document](https://docs.dbgpt.site/).
## Usage
[react-markdown](https://github.com/remarkjs/react-markdown#readme) for markdown support.
[ant-design](https://github.com/ant-design/ant-design) for ui components.
[next.js](https://github.com/vercel/next.js) for server side rendering.
[@antv/g2](https://github.com/antvis/g2#readme) for charts.
## License
DB-GPT-Web is licensed under the [MIT License](LICENSE).
---
Enjoy using DB-GPT-Web to build stunning UIs for your AI and GPT projects.
🌟 If you find it helpful, don't forget to give it a star on GitHub! Stars are like little virtual hugs that keep us going! We appreciate every single one we receive.
For any queries or issues, feel free to open an [issue](https://github.com/eosphoros-ai/DB-GPT-Web/issues) on the repository.
Happy coding! 😊
================================================
FILE: app/chat-context.tsx
================================================
import { createContext, useEffect, useMemo, useState } from 'react';
import { apiInterceptors, getDialogueList, getUsableModels } from '@/client/api';
import { useRequest } from 'ahooks';
import { ChatHistoryResponse, DialogueListResponse, IChatDialogueSchema } from '@/types/chat';
import { useSearchParams } from 'next/navigation';
import { STORAGE_THEME_KEY } from '@/utils';
type ThemeMode = 'dark' | 'light';
interface IChatContext {
mode: ThemeMode;
isContract?: boolean;
isMenuExpand?: boolean;
scene: IChatDialogueSchema['chat_mode'] | (string & {});
chatId: string;
model: string;
dbParam?: string;
modelList: Array;
agent: string;
dialogueList?: DialogueListResponse;
setAgent?: (val: string) => void;
setMode: (mode: ThemeMode) => void;
setModel: (val: string) => void;
setIsContract: (val: boolean) => void;
setIsMenuExpand: (val: boolean) => void;
setDbParam: (val: string) => void;
queryDialogueList: () => void;
refreshDialogList: () => void;
currentDialogue?: DialogueListResponse[0];
history: ChatHistoryResponse;
setHistory: (val: ChatHistoryResponse) => void;
docId?: number;
setDocId: (docId: number) => void;
}
function getDefaultTheme(): ThemeMode {
const theme = localStorage.getItem(STORAGE_THEME_KEY) as ThemeMode;
if (theme) return theme;
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
}
const ChatContext = createContext({
mode: 'light',
scene: '',
chatId: '',
modelList: [],
model: '',
dbParam: undefined,
dialogueList: [],
agent: '',
setAgent: () => {},
setModel: () => {},
setIsContract: () => {},
setIsMenuExpand: () => {},
setDbParam: () => void 0,
queryDialogueList: () => {},
refreshDialogList: () => {},
setMode: () => void 0,
history: [],
setHistory: () => {},
docId: undefined,
setDocId: () => {},
});
const ChatContextProvider = ({ children }: { children: React.ReactElement }) => {
const searchParams = useSearchParams();
const chatId = searchParams?.get('id') ?? '';
const scene = searchParams?.get('scene') ?? '';
const db_param = searchParams?.get('db_param') ?? '';
const [isContract, setIsContract] = useState(false);
const [model, setModel] = useState('');
const [isMenuExpand, setIsMenuExpand] = useState(scene !== 'chat_dashboard');
const [dbParam, setDbParam] = useState(db_param);
const [agent, setAgent] = useState('');
const [history, setHistory] = useState([]);
const [docId, setDocId] = useState();
const [mode, setMode] = useState('light');
const {
run: queryDialogueList,
data: dialogueList = [],
refresh: refreshDialogList,
} = useRequest(
async () => {
const [, res] = await apiInterceptors(getDialogueList());
return res ?? [];
},
{
manual: true,
},
);
useEffect(() => {
if (dialogueList.length && scene === 'chat_agent') {
const agent = dialogueList.find((item) => item.conv_uid === chatId)?.select_param;
agent && setAgent(agent);
}
}, [dialogueList, scene, chatId]);
const { data: modelList = [] } = useRequest(async () => {
const [, res] = await apiInterceptors(getUsableModels());
return res ?? [];
});
useEffect(() => {
setMode(getDefaultTheme());
}, []);
useEffect(() => {
setModel(modelList[0]);
}, [modelList, modelList?.length]);
const currentDialogue = useMemo(() => dialogueList.find((item: any) => item.conv_uid === chatId), [chatId, dialogueList]);
const contextValue = {
isContract,
isMenuExpand,
scene,
chatId,
modelList,
model,
dbParam: dbParam || db_param,
dialogueList,
agent,
setAgent,
mode,
setMode,
setModel,
setIsContract,
setIsMenuExpand,
setDbParam,
queryDialogueList,
refreshDialogList,
currentDialogue,
history,
setHistory,
docId,
setDocId,
};
return {children};
};
export { ChatContext, ChatContextProvider };
================================================
FILE: app/i18n.ts
================================================
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
const en = {
Knowledge_Space: 'Knowledge',
space: 'space',
Vector: 'Vector',
Owner: 'Owner',
Count: 'Count',
File_type_Invalid: 'The file type is invalid',
Knowledge_Space_Config: 'Space Config',
Choose_a_Datasource_type: 'Datasource type',
Segmentation: 'Segmentation',
No_parameter: `No segementation parameter required.`,
Knowledge_Space_Name: 'Knowledge Space Name',
Please_input_the_name: 'Please input the name',
Please_input_the_owner: 'Please input the owner',
Please_select_file: 'Please select one file',
Description: 'Description',
Please_input_the_description: 'Please input the description',
Next: 'Next',
the_name_can_only_contain: 'the name can only contain numbers, letters, Chinese characters, "-" and "_"',
Text: 'Text',
'Fill your raw text': 'Fill your raw text',
URL: 'URL',
Fetch_the_content_of_a_URL: 'Fetch the content of a URL',
Document: 'Document',
Upload_a_document: 'Upload a document, document type can be PDF, CSV, Text, PowerPoint, Word, Markdown',
Name: 'Name',
Text_Source: 'Text Source(Optional)',
Please_input_the_text_source: 'Please input the text source',
Sync: 'Sync',
Back: 'Back',
Finish: 'Finish',
Web_Page_URL: 'Web Page URL',
Please_input_the_Web_Page_URL: 'Please input the Web Page URL',
Select_or_Drop_file: 'Select or Drop file',
Documents: 'Documents',
Chat: 'Chat',
Add_Datasource: 'Add Datasource',
Arguments: 'Arguments',
Type: 'Type',
Size: 'Size',
Last_Sync: 'Last Sync',
Status: 'Status',
Result: 'Result',
Details: 'Details',
Delete: 'Delete',
Operation: 'Operation',
Submit: 'Submit',
Chunks: 'Chunks',
Content: 'Content',
Meta_Data: 'Meta Data',
Please_select_a_file: 'Please select a file',
Please_input_the_text: 'Please input the text',
Embedding: 'Embedding',
topk: 'topk',
the_top_k_vectors: 'the top k vectors based on similarity score',
recall_score: 'recall_score',
Set_a_threshold_score: 'Set a threshold score for the retrieval of similar vectors',
recall_type: 'recall_type',
model: 'model',
A_model_used: 'A model used to create vector representations of text or other data',
Automatic: 'Automatic',
Process: 'Process',
Automatic_desc: 'Automatically set segmentation and preprocessing rules.',
chunk_size: 'chunk_size',
The_size_of_the_data_chunks: 'The size of the data chunks used in processing',
chunk_overlap: 'chunk_overlap',
The_amount_of_overlap: 'The amount of overlap between adjacent data chunks',
Prompt: 'Prompt',
scene: 'scene',
A_contextual_parameter: 'A contextual parameter used to define the setting or environment in which the prompt is being used',
template: 'template',
structure_or_format:
'A pre-defined structure or format for the prompt, which can help ensure that the AI system generates responses that are consistent with the desired style or tone.',
max_token: 'max_token',
max_iteration: 'max_iteration',
concurrency_limit: 'concurrency_limit',
The_maximum_number_of_tokens: 'The maximum number of tokens or words allowed in a prompt',
Theme: 'Theme',
Port: 'Port',
Username: 'Username',
Password: 'Password',
Remark: 'Remark',
Edit: 'Edit',
Database: 'Database',
Data_Source: 'Data Center',
Close_Sidebar: 'Fold',
Show_Sidebar: 'UnFold',
language: 'Language',
choose_model: 'Please choose a model',
data_center_desc: 'DB-GPT also offers a user-friendly data center management interface for efficient data maintenance.',
create_database: 'Create Database',
create_knowledge: 'Create Knowledge',
path: 'Path',
model_manage: 'Models',
stop_model_success: 'Stop model success',
create_model: 'Create Model',
model_select_tips: 'Please select a model',
language_select_tips: 'Please select a language',
submit: 'Submit',
close: 'Close',
start_model_success: 'Start model success',
download_model_tip: 'Please download model first.',
Plugins: 'Plugins',
try_again: 'Try again',
no_data: 'No data',
Open_Sidebar: 'Unfold',
cancel: 'Cancel',
Edit_Success: 'Edit Success',
Add: 'Add',
Add_Success: 'Add Success',
Error_Message: 'Something Error',
Please_Input: 'Please Input',
Prompt_Info_Scene: 'Scene',
Prompt_Info_Sub_Scene: 'Sub Scene',
Prompt_Info_Name: 'Name',
Prompt_Info_Content: 'Content',
Public: 'Public',
Private: 'Private',
Lowest: 'Lowest',
Missed: 'Missed',
Lost: 'Lost',
Incorrect: 'Incorrect',
Verbose: 'Verbose',
Best: 'Best',
Rating: 'Rating',
Q_A_Category: 'Q&A Category',
Q_A_Rating: 'Q&A Rating',
feed_back_desc:
'0: No results\n' +
'1: Results exist, but they are irrelevant, the question is not understood\n' +
'2: Results exist, the question is understood, but it indicates that the question cannot be answered\n' +
'3: Results exist, the question is understood, and an answer is given, but the answer is incorrect\n' +
'4: Results exist, the question is understood, the answer is correct, but it is verbose and lacks a summary\n' +
'5: Results exist, the question is understood, the answer is correct, the reasoning is correct, and a summary is provided, concise and to the point\n',
input_count: 'Total input',
input_unit: 'characters',
Copy: 'Copy',
Copy_success: 'Content copied successfully',
Copy_nothing: 'Content copied is empty',
Copry_error: 'Copy failed',
Click_Select: 'Click&Select',
Quick_Start: 'Quick Start',
Select_Plugins: 'Select Plugins',
Search: 'Search',
Update_From_Github: 'Upload From Github',
Reset: 'Reset',
Upload: 'Upload',
Market_Plugins: 'Market Plugin',
My_Plugins: 'My Plugins',
Del_Knowledge_Tips: 'Do you want delete the Space',
Del_Document_Tips: 'Do you want delete the Document',
Tips: 'Tips',
Limit_Upload_File_Count_Tips: 'Only one file can be uploaded at a time',
To_Plugin_Market: 'Go to the Plugin Market',
Summary: 'Summary',
stacked_column_chart: 'Stacked Column',
column_chart: 'Column',
percent_stacked_column_chart: 'Percent Stacked Column',
grouped_column_chart: 'Grouped Column',
time_column: 'Time Column',
pie_chart: 'Pie',
line_chart: 'Line',
area_chart: 'Area',
stacked_area_chart: 'Stacked Area',
scatter_plot: 'Scatter',
bubble_chart: 'Bubble',
stacked_bar_chart: 'Stacked Bar',
bar_chart: 'Bar',
percent_stacked_bar_chart: 'Percent Stacked Bar',
grouped_bar_chart: 'Grouped Bar',
water_fall_chart: 'Waterfall',
table: 'Table',
multi_line_chart: 'Multi Line',
multi_measure_column_chart: 'Multi Measure Column',
multi_measure_line_chart: 'Multi Measure Line',
Advices: 'Advices',
Retry: 'Retry',
Load_more: 'load more',
new_chat: 'New Chat',
choice_agent_tip: 'Please choose an agent',
no_context_tip: 'Please enter your question',
Terminal: 'Terminal',
awel_flow: 'AWEL Flow',
save: 'Save',
add_node: 'Add Node',
no_node: 'No Node',
connect_warning: 'Nodes cannot be connected',
flow_modal_title: 'Save Flow',
flow_name: 'Flow Name',
flow_description: 'Flow Description',
flow_name_required: 'Please enter the flow name',
flow_description_required: 'Please enter the flow description',
save_flow_success: 'Save flow success',
delete_flow_confirm: 'Are you sure you want to delete this flow?',
related_nodes: 'Related Nodes',
add_resource: 'Add Resource',
team_modal: 'Work Modal',
App: 'App',
resource_name: 'Resource Name',
resource_type: 'Resource Type',
resource_value: 'Value',
resource_dynamic: 'Dynamic',
Please_input_the_work_modal: 'Please select the work modal',
available_resources: ' Available Resources',
edit_new_applications: 'Edit new applications',
collect: 'Collect',
collected: 'Collected',
create: 'Create',
Agents: 'Agents',
edit_application: 'edit application',
add_application: 'add application',
app_name: 'App Name',
LLM_strategy: 'LLM Strategy',
LLM_strategy_value: 'LLM Strategy Value',
resource: 'Resource',
operators: 'Operators',
Chinese: 'Chinese',
English: 'English',
} as const;
export type I18nKeys = keyof typeof en;
export interface Resources {
translation: Record;
}
const zh: Resources['translation'] = {
Knowledge_Space: '知识库',
space: '知识库',
Vector: '向量',
Owner: '创建人',
Count: '文档数',
File_type_Invalid: '文件类型错误',
Knowledge_Space_Config: '知识库配置',
Choose_a_Datasource_type: '知识库类型',
Segmentation: '分片',
No_parameter: '不需要配置分片参数',
Knowledge_Space_Name: '知识库名称',
Please_input_the_name: '请输入名称',
Please_input_the_owner: '请输入创建人',
Please_select_file: '请至少选择一个文件',
Description: '描述',
Please_input_the_description: '请输入描述',
Next: '下一步',
the_name_can_only_contain: '名称只能包含数字、字母、中文字符、-或_',
Text: '文本',
'Fill your raw text': '填写您的原始文本',
URL: '网址',
Fetch_the_content_of_a_URL: '获取 URL 的内容',
Document: '文档',
Upload_a_document: '上传文档,文档类型可以是PDF、CSV、Text、PowerPoint、Word、Markdown',
Name: '名称',
Text_Source: '文本来源(可选)',
Please_input_the_text_source: '请输入文本来源',
Sync: '同步',
Back: '上一步',
Finish: '完成',
Web_Page_URL: '网页网址',
Please_input_the_Web_Page_URL: '请输入网页网址',
Select_or_Drop_file: '选择或拖拽文件',
Documents: '文档',
Chat: '对话',
Add_Datasource: '添加数据源',
Arguments: '参数',
Type: '类型',
Size: '切片',
Last_Sync: '上次同步时间',
Status: '状态',
Result: '结果',
Details: '明细',
Delete: '删除',
Operation: '操作',
Submit: '提交',
close: '关闭',
Chunks: '切片',
Content: '内容',
Meta_Data: '元数据',
Please_select_a_file: '请上传一个文件',
Please_input_the_text: '请输入文本',
Embedding: '嵌入',
topk: 'TopK',
the_top_k_vectors: '基于相似度得分的前 k 个向量',
recall_score: '召回分数',
Set_a_threshold_score: '设置相似向量检索的阈值分数',
recall_type: '召回类型',
model: '模型',
A_model_used: '用于创建文本或其他数据的矢量表示的模型',
Automatic: '自动切片',
Process: '切片处理',
Automatic_desc: '自动设置分割和预处理规则。',
chunk_size: '块大小',
The_size_of_the_data_chunks: '处理中使用的数据块的大小',
chunk_overlap: '块重叠',
The_amount_of_overlap: '相邻数据块之间的重叠量',
scene: '场景',
A_contextual_parameter: '用于定义使用提示的设置或环境的上下文参数',
template: '模板',
structure_or_format: '预定义的提示结构或格式,有助于确保人工智能系统生成与所需风格或语气一致的响应。',
max_token: '最大令牌',
max_iteration: '最大迭代',
concurrency_limit: '并发限制',
The_maximum_number_of_tokens: '提示中允许的最大标记或单词数',
Theme: '主题',
Port: '端口',
Username: '用户名',
Password: '密码',
Remark: '备注',
Edit: '编辑',
Database: '数据库',
Data_Source: '数据中心',
Close_Sidebar: '收起',
Show_Sidebar: '展开',
language: '语言',
choose_model: '请选择一个模型',
data_center_desc: 'DB-GPT支持数据库交互和基于文档的对话,它还提供了一个用户友好的数据中心管理界面。',
create_database: '创建数据库',
create_knowledge: '创建知识库',
path: '路径',
model_manage: '模型管理',
stop_model_success: '模型停止成功',
create_model: '创建模型',
model_select_tips: '请选择一个模型',
submit: '提交',
start_model_success: '启动模型成功',
download_model_tip: '请先下载模型!',
Plugins: '插件列表',
try_again: '刷新重试',
no_data: '暂无数据',
Prompt: '提示语',
Open_Sidebar: '展开',
cancel: '取消',
Edit_Success: '编辑成功',
Add: '新增',
Add_Success: '新增成功',
Error_Message: '出错了',
Please_Input: '请输入',
Prompt_Info_Scene: '场景',
Prompt_Info_Sub_Scene: '次级场景',
Prompt_Info_Name: '名称',
Prompt_Info_Content: '内容',
Public: '公共',
Private: '私有',
Lowest: '渣渣',
Missed: '没理解',
Lost: '答不了',
Incorrect: '答错了',
Verbose: '较啰嗦',
Best: '真棒',
Rating: '评分',
Q_A_Category: '问答类别',
Q_A_Rating: '问答评分',
feed_back_desc:
'0: 无结果\n' +
'1: 有结果,但是在文不对题,没有理解问题\n' +
'2: 有结果,理解了问题,但是提示回答不了这个问题\n' +
'3: 有结果,理解了问题,并做出回答,但是回答的结果错误\n' +
'4: 有结果,理解了问题,回答结果正确,但是比较啰嗦,缺乏总结\n' +
'5: 有结果,理解了问题,回答结果正确,推理正确,并给出了总结,言简意赅\n',
input_count: '共计输入',
input_unit: '字',
Copy: '复制',
Copy_success: '内容复制成功',
Copy_nothing: '内容复制为空',
Copry_error: '复制失败',
Click_Select: '点击选择',
Quick_Start: '快速开始',
Select_Plugins: '选择插件',
Search: '搜索',
Reset: '重置',
Update_From_Github: '更新Github插件',
Upload: '上传',
Market_Plugins: '插件市场',
My_Plugins: '我的插件',
Del_Knowledge_Tips: '你确定删除该知识库吗',
Del_Document_Tips: '你确定删除该文档吗',
Tips: '提示',
Limit_Upload_File_Count_Tips: '一次只能上传一个文件',
To_Plugin_Market: '前往插件市场',
Summary: '总结',
stacked_column_chart: '堆叠柱状图',
column_chart: '柱状图',
percent_stacked_column_chart: '百分比堆叠柱状图',
grouped_column_chart: '簇形柱状图',
time_column: '簇形柱状图',
pie_chart: '饼图',
line_chart: '折线图',
area_chart: '面积图',
stacked_area_chart: '堆叠面积图',
scatter_plot: '散点图',
bubble_chart: '气泡图',
stacked_bar_chart: '堆叠条形图',
bar_chart: '条形图',
percent_stacked_bar_chart: '百分比堆叠条形图',
grouped_bar_chart: '簇形条形图',
water_fall_chart: '瀑布图',
table: '表格',
multi_line_chart: '多折线图',
multi_measure_column_chart: '多指标柱形图',
multi_measure_line_chart: '多指标折线图',
Advices: '自动推荐',
Retry: '重试',
Load_more: '加载更多',
new_chat: '创建会话',
choice_agent_tip: '请选择代理',
no_context_tip: '请输入你的问题',
Terminal: '终端',
awel_flow: 'AWEL 工作流',
save: '保存',
add_node: '添加节点',
no_node: '没有可编排节点',
connect_warning: '节点无法连接',
flow_modal_title: '保存工作流',
flow_name: '工作流名称',
flow_description: '工作流描述',
flow_name_required: '请输入工作流名称',
flow_description_required: '请输入工作流描述',
save_flow_success: '保存工作流成功',
delete_flow_confirm: '确定删除该工作流吗?',
related_nodes: '关联节点',
language_select_tips: '请选择语言',
add_resource: '添加资源',
team_modal: '工作模式',
App: '应用程序',
resource: '资源',
resource_name: '资源名',
resource_type: '资源类型',
resource_value: '参数',
resource_dynamic: '动态',
Please_input_the_work_modal: '请选择工作模式',
available_resources: '可用资源',
edit_new_applications: '编辑新的应用',
collect: '收藏',
collected: '已收藏',
create: '创建',
Agents: '智能体',
edit_application: '编辑应用',
add_application: '添加应用',
app_name: '应用名称',
LLM_strategy: '模型策略',
LLM_strategy_value: '模型策略参数',
operators: '算子',
Chinese: '中文',
English: '英文',
} as const;
i18n.use(initReactI18next).init({
resources: {
en: {
translation: en,
},
zh: {
translation: zh,
},
},
lng: 'en',
interpolation: {
escapeValue: false,
},
});
export default i18n;
declare module 'i18next' {
interface CustomTypeOptions {
resources: Resources;
}
}
================================================
FILE: client/api/index.ts
================================================
import axios, { AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios';
export type ResponseType = {
data: T;
err_code: string | null;
err_msg: string | null;
success: boolean;
};
export type ApiResponse = AxiosResponse, D>;
export type SuccessTuple = [null, T, ResponseType, ApiResponse];
export type FailedTuple = [Error | AxiosError, null, null, null];
const ins = axios.create({
baseURL: process.env.API_BASE_URL ?? '',
});
const LONG_TIME_API: string[] = [
'/db/add',
'/db/test/connect',
'/db/summary',
'/params/file/load',
'/chat/prepare',
'/model/start',
'/model/stop',
'/editor/sql/run',
'/sql/editor/submit',
'/editor/chart/run',
'/chart/editor/submit',
'/document/upload',
'/document/sync',
'/agent/install',
'/agent/uninstall',
'/personal/agent/upload',
];
ins.interceptors.request.use((request) => {
const isLongTimeApi = LONG_TIME_API.some((item) => request.url && request.url.indexOf(item) >= 0);
if (!request.timeout) {
request.timeout = isLongTimeApi ? 60000 : 10000;
}
return request;
});
export const GET = (url: string, params?: Params, config?: AxiosRequestConfig) => {
return ins.get>(url, { params, ...config });
};
export const POST = (url: string, data?: Data, config?: AxiosRequestConfig) => {
return ins.post>(url, data, config);
};
export const PATCH = (url: string, data?: Data, config?: AxiosRequestConfig) => {
return ins.patch>(url, data, config);
};
export const PUT = (url: string, data?: Data, config?: AxiosRequestConfig) => {
return ins.put>(url, data, config);
};
export const DELETE = (url: string, params?: Params, config?: AxiosRequestConfig) => {
return ins.delete>(url, { params, ...config });
};
export * from './tools';
export * from './request';
================================================
FILE: client/api/request.ts
================================================
import { AxiosRequestConfig } from 'axios';
import { DELETE, GET, POST, PUT } from '.';
import { DbListResponse, DbSupportTypeResponse, PostDbParams, ChatFeedBackSchema } from '@/types/db';
import { DialogueListResponse, IChatDialogueSchema, NewDialogueParam, SceneResponse, ChatHistoryResponse, FeedBack, IDB } from '@/types/chat';
import { IModelData, StartModelParams, BaseModelParams, SupportModel } from '@/types/model';
import {
GetEditorSQLRoundRequest,
GetEditorySqlParams,
PostEditorChartRunParams,
PostEditorChartRunResponse,
PostEditorSQLRunParams,
PostSQLEditorSubmitParams,
} from '@/types/editor';
import {
PostAgentHubUpdateParams,
PostAgentQueryParams,
PostAgentPluginResponse,
PostAgentMyPluginResponse,
GetDBGPTsListResponse,
} from '@/types/agent';
import {
AddKnowledgeParams,
ArgumentsParams,
ChunkListParams,
DocumentParams,
IArguments,
IChunkList,
IChunkStrategyResponse,
IDocumentResponse,
ISpace,
ISyncBatchParameter,
ISyncBatchResponse,
} from '@/types/knowledge';
import { UpdatePromptParams, IPrompt, PromptParams } from '@/types/prompt';
import { IFlow, IFlowNode, IFlowResponse, IFlowUpdateParam } from '@/types/flow';
import { IAgent, IApp, IAppData, ITeamModal } from '@/types/app';
/** App */
export const postScenes = () => {
return POST>('/api/v1/chat/dialogue/scenes');
};
export const newDialogue = (data: NewDialogueParam) => {
return POST('/api/v1/chat/dialogue/new', data);
};
/** Database Page */
export const getDbList = () => {
return GET('/api/v1/chat/db/list');
};
export const getDbSupportType = () => {
return GET('/api/v1/chat/db/support/type');
};
export const postDbDelete = (dbName: string) => {
return POST(`/api/v1/chat/db/delete?db_name=${dbName}`);
};
export const postDbEdit = (data: PostDbParams) => {
return POST('/api/v1/chat/db/edit', data);
};
export const postDbAdd = (data: PostDbParams) => {
return POST('/api/v1/chat/db/add', data);
};
export const postDbTestConnect = (data: PostDbParams) => {
return POST('/api/v1/chat/db/test/connect', data);
};
/** Chat Page */
export const getDialogueList = () => {
return GET('/api/v1/chat/dialogue/list');
};
export const getUsableModels = () => {
return GET>('/api/v1/model/types');
};
export const postChatModeParamsList = (chatMode: string) => {
return POST(`/api/v1/chat/mode/params/list?chat_mode=${chatMode}`);
};
export const postChatModeParamsInfoList = (chatMode: string) => {
return POST>(`/api/v1/chat/mode/params/info?chat_mode=${chatMode}`);
};
export const getChatHistory = (convId: string) => {
return GET(`/api/v1/chat/dialogue/messages/history?con_uid=${convId}`);
};
export const postChatModeParamsFileLoad = ({
convUid,
chatMode,
data,
config,
model,
}: {
convUid: string;
chatMode: string;
data: FormData;
model: string;
config?: Omit;
}) => {
return POST(
`/api/v1/chat/mode/params/file/load?conv_uid=${convUid}&chat_mode=${chatMode}&model_name=${model}`,
data,
{
headers: {
'Content-Type': 'multipart/form-data',
},
...config,
},
);
};
/** Menu */
export const delDialogue = (conv_uid: string) => {
return POST(`/api/v1/chat/dialogue/delete?con_uid=${conv_uid}`);
};
/** Editor */
export const getEditorSqlRounds = (id: string) => {
return GET(`/api/v1/editor/sql/rounds?con_uid=${id}`);
};
export const postEditorSqlRun = (data: PostEditorSQLRunParams) => {
return POST(`/api/v1/editor/sql/run`, data);
};
export const postEditorChartRun = (data: PostEditorChartRunParams) => {
return POST(`/api/v1/editor/chart/run`, data);
};
export const postSqlEditorSubmit = (data: PostSQLEditorSubmitParams) => {
return POST(`/api/v1/sql/editor/submit`, data);
};
export const getEditorSql = (id: string, round: string | number) => {
return POST>('/api/v1/editor/sql', { con_uid: id, round });
};
/** knowledge */
export const getArguments = (knowledgeName: string) => {
return POST(`/knowledge/${knowledgeName}/arguments`, {});
};
export const saveArguments = (knowledgeName: string, data: ArgumentsParams) => {
return POST(`/knowledge/${knowledgeName}/argument/save`, data);
};
export const getSpaceList = () => {
return POST>('/knowledge/space/list', {});
};
export const getDocumentList = (spaceName: string, data: Record>) => {
return POST>, IDocumentResponse>(`/knowledge/${spaceName}/document/list`, data);
};
export const addDocument = (knowledgeName: string, data: DocumentParams) => {
return POST(`/knowledge/${knowledgeName}/document/add`, data);
};
export const addSpace = (data: AddKnowledgeParams) => {
return POST>(`/knowledge/space/add`, data);
};
export const getChunkStrategies = () => {
return GET>('/knowledge/document/chunkstrategies');
};
export const syncDocument = (spaceName: string, data: Record>) => {
return POST>, string | null>(`/knowledge/${spaceName}/document/sync`, data);
};
export const syncBatchDocument = (spaceName: string, data: Array) => {
return POST, ISyncBatchResponse>(`/knowledge/${spaceName}/document/sync_batch`, data);
};
export const uploadDocument = (knowLedgeName: string, data: FormData) => {
return POST(`/knowledge/${knowLedgeName}/document/upload`, data);
};
export const getChunkList = (spaceName: string, data: ChunkListParams) => {
return POST(`/knowledge/${spaceName}/chunk/list`, data);
};
export const delDocument = (spaceName: string, data: Record) => {
return POST, null>(`/knowledge/${spaceName}/document/delete`, data);
};
export const delSpace = (data: Record) => {
return POST, null>(`/knowledge/space/delete`, data);
};
/** models */
export const getModelList = () => {
return GET>('/api/v1/worker/model/list');
};
export const stopModel = (data: BaseModelParams) => {
return POST('/api/v1/worker/model/stop', data);
};
export const startModel = (data: StartModelParams) => {
return POST('/api/v1/worker/model/start', data);
};
export const getSupportModels = () => {
return GET>('/api/v1/worker/model/params');
};
/** Agent */
export const postAgentQuery = (data: PostAgentQueryParams) => {
return POST('/api/v1/agent/query', data);
};
export const postAgentHubUpdate = (data?: PostAgentHubUpdateParams) => {
return POST('/api/v1/agent/hub/update', data ?? { channel: '', url: '', branch: '', authorization: '' });
};
export const postAgentMy = (user?: string) => {
return POST('/api/v1/agent/my', undefined, { params: { user } });
};
export const postAgentInstall = (pluginName: string, user?: string) => {
return POST('/api/v1/agent/install', undefined, { params: { plugin_name: pluginName, user }, timeout: 60000 });
};
export const postAgentUninstall = (pluginName: string, user?: string) => {
return POST('/api/v1/agent/uninstall', undefined, { params: { plugin_name: pluginName, user }, timeout: 60000 });
};
export const postAgentUpload = (user = '', data: FormData, config?: Omit) => {
return POST('/api/v1/personal/agent/upload', data, {
params: { user },
headers: {
'Content-Type': 'multipart/form-data',
},
...config,
});
};
export const getDbgptsList = () => {
return GET('/api/v1/dbgpts/list');
};
/** chat feedback **/
export const getChatFeedBackSelect = () => {
return GET(`/api/v1/feedback/select`, undefined);
};
export const getChatFeedBackItme = (conv_uid: string, conv_index: number) => {
return GET>(`/api/v1/feedback/find?conv_uid=${conv_uid}&conv_index=${conv_index}`, undefined);
};
export const postChatFeedBackForm = ({ data, config }: { data: ChatFeedBackSchema; config?: Omit }) => {
return POST(`/api/v1/feedback/commit`, data, {
headers: {
'Content-Type': 'application/json',
},
...config,
});
};
/** prompt */
export const getPromptList = (data: PromptParams) => {
return POST>('/prompt/list', data);
};
export const updatePrompt = (data: UpdatePromptParams) => {
return POST('/prompt/update', data);
};
export const addPrompt = (data: UpdatePromptParams) => {
return POST('/prompt/add', data);
};
/** AWEL Flow */
export const addFlow = (data: IFlowUpdateParam) => {
return POST('/api/v1/serve/awel/flows', data);
};
export const getFlows = () => {
return GET('/api/v1/serve/awel/flows');
};
export const getFlowById = (id: string) => {
return GET(`/api/v1/serve/awel/flows/${id}`);
};
export const updateFlowById = (id: string, data: IFlowUpdateParam) => {
return PUT(`/api/v1/serve/awel/flows/${id}`, data);
};
export const deleteFlowById = (id: string) => {
return DELETE(`/api/v1/serve/awel/flows/${id}`);
};
export const getFlowNodes = () => {
return GET>(`/api/v1/serve/awel/nodes`);
};
/** app */
export const addApp = (data: IApp) => {
return POST('/api/v1/app/create', data);
};
export const getAppList = (data: Record) => {
return POST, IAppData>('/api/v1/app/list', data);
};
export const collectApp = (data: Record) => {
return POST, []>('/api/v1/app/collect', data);
};
export const unCollectApp = (data: Record) => {
return POST, []>('/api/v1/app/uncollect', data);
};
export const delApp = (data: Record) => {
return POST, []>('/api/v1/app/remove', data);
};
export const getAgents = () => {
return GET