mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-07-20 19:36:08 +00:00
feat: basic entities of kb
This commit is contained in:
@@ -0,0 +1,107 @@
|
|||||||
|
.cardContainer {
|
||||||
|
width: 100%;
|
||||||
|
height: 10rem;
|
||||||
|
background-color: #fff;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0px 2px 2px 0 rgba(0, 0, 0, 0.2);
|
||||||
|
padding: 1.2rem;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cardContainer:hover {
|
||||||
|
box-shadow: 0px 2px 8px 0 rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.basicInfoContainer {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.4rem;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.basicInfoNameContainer {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.basicInfoNameText {
|
||||||
|
font-size: 1.4rem;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.basicInfoDescriptionText {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 400;
|
||||||
|
display: -webkit-box;
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
color: #b1b1b1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.basicInfoLastUpdatedTimeContainer {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.basicInfoUpdateTimeIcon {
|
||||||
|
width: 1.2rem;
|
||||||
|
height: 1.2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.basicInfoUpdateTimeText {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
.operationContainer {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-end;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 0.5rem;
|
||||||
|
width: 8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.operationDefaultBadge {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.operationDefaultBadgeIcon {
|
||||||
|
width: 1.2rem;
|
||||||
|
height: 1.2rem;
|
||||||
|
color: #ffcd27;
|
||||||
|
}
|
||||||
|
|
||||||
|
.operationDefaultBadgeText {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 400;
|
||||||
|
color: #ffcd27;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bigText {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
font-size: 1.4rem;
|
||||||
|
font-weight: bold;
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.debugButtonIcon {
|
||||||
|
width: 1.2rem;
|
||||||
|
height: 1.2rem;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { KnowledgeBaseVO } from '@/app/home/knowledge/components/kb-card/KBCardVO';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import styles from './KBCard.module.css';
|
||||||
|
|
||||||
|
export default function KBCard({ kbCardVO }: { kbCardVO: KnowledgeBaseVO }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
|
<div className={`${styles.cardContainer}`}>
|
||||||
|
<div className={`${styles.basicInfoContainer}`}>
|
||||||
|
<div className={`${styles.basicInfoNameContainer}`}>
|
||||||
|
<div className={`${styles.basicInfoNameText} ${styles.bigText}`}>
|
||||||
|
{kbCardVO.name}
|
||||||
|
</div>
|
||||||
|
<div className={`${styles.basicInfoDescriptionText}`}>
|
||||||
|
{kbCardVO.description}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className={`${styles.basicInfoLastUpdatedTimeContainer}`}>
|
||||||
|
<svg
|
||||||
|
className={`${styles.basicInfoUpdateTimeIcon}`}
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
fill="currentColor"
|
||||||
|
>
|
||||||
|
<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM13 12H17V14H11V7H13V12Z"></path>
|
||||||
|
</svg>
|
||||||
|
<div className={`${styles.basicInfoUpdateTimeText}`}>
|
||||||
|
{t('knowledge.bases.updateTime')}
|
||||||
|
{kbCardVO.lastUpdatedTimeAgo}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
export interface IKnowledgeBaseVO {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
embeddingModelUUID: string;
|
||||||
|
lastUpdatedTimeAgo: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class KnowledgeBaseVO implements IKnowledgeBaseVO {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
embeddingModelUUID: string;
|
||||||
|
lastUpdatedTimeAgo: string;
|
||||||
|
|
||||||
|
constructor(props: IKnowledgeBaseVO) {
|
||||||
|
this.id = props.id;
|
||||||
|
this.name = props.name;
|
||||||
|
this.description = props.description;
|
||||||
|
this.embeddingModelUUID = props.embeddingModelUUID;
|
||||||
|
this.lastUpdatedTimeAgo = props.lastUpdatedTimeAgo;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,8 +2,22 @@
|
|||||||
|
|
||||||
import CreateCardComponent from '@/app/infra/basic-component/create-card-component/CreateCardComponent';
|
import CreateCardComponent from '@/app/infra/basic-component/create-card-component/CreateCardComponent';
|
||||||
import styles from './knowledgeBase.module.css';
|
import styles from './knowledgeBase.module.css';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { KnowledgeBaseVO } from '@/app/home/knowledge/components/kb-card/KBCardVO';
|
||||||
|
import KBCard from '@/app/home/knowledge/components/kb-card/KBCard';
|
||||||
|
|
||||||
export default function KnowledgePage() {
|
export default function KnowledgePage() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const [knowledgeBaseList, setKnowledgeBaseList] = useState<KnowledgeBaseVO[]>(
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleKBCardClick = (kbId: string) => {
|
||||||
|
// setIsEditForm(false);
|
||||||
|
// setModalOpen(true);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<div className={styles.knowledgeListContainer}>
|
<div className={styles.knowledgeListContainer}>
|
||||||
@@ -16,6 +30,14 @@ export default function KnowledgePage() {
|
|||||||
// setModalOpen(true);
|
// setModalOpen(true);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{knowledgeBaseList.map((kb) => {
|
||||||
|
return (
|
||||||
|
<div key={kb.id} onClick={() => handleKBCardClick(kb.id)}>
|
||||||
|
<KBCard kbCardVO={kb} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -133,6 +133,23 @@ export interface Bot {
|
|||||||
updated_at?: string;
|
updated_at?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ApiRespKnowledgeBases {
|
||||||
|
bases: KnowledgeBase[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ApiRespKnowledgeBase {
|
||||||
|
base: KnowledgeBase;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface KnowledgeBase {
|
||||||
|
uuid?: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
embedding_model_uuid: string;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
// plugins
|
// plugins
|
||||||
export interface ApiRespPlugins {
|
export interface ApiRespPlugins {
|
||||||
plugins: Plugin[];
|
plugins: Plugin[];
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ import {
|
|||||||
AsyncTask,
|
AsyncTask,
|
||||||
ApiRespWebChatMessage,
|
ApiRespWebChatMessage,
|
||||||
ApiRespWebChatMessages,
|
ApiRespWebChatMessages,
|
||||||
|
ApiRespKnowledgeBases,
|
||||||
|
ApiRespKnowledgeBase,
|
||||||
|
KnowledgeBase,
|
||||||
} from '@/app/infra/entities/api';
|
} from '@/app/infra/entities/api';
|
||||||
import { GetBotLogsRequest } from '@/app/infra/http/requestParam/bots/GetBotLogsRequest';
|
import { GetBotLogsRequest } from '@/app/infra/http/requestParam/bots/GetBotLogsRequest';
|
||||||
import { GetBotLogsResponse } from '@/app/infra/http/requestParam/bots/GetBotLogsResponse';
|
import { GetBotLogsResponse } from '@/app/infra/http/requestParam/bots/GetBotLogsResponse';
|
||||||
@@ -427,6 +430,19 @@ class HttpClient {
|
|||||||
return this.post(`/api/v1/platform/bots/${botId}/logs`, request);
|
return this.post(`/api/v1/platform/bots/${botId}/logs`, request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ============ Knowledge Base API ============
|
||||||
|
public getKnowledgeBases(): Promise<ApiRespKnowledgeBases> {
|
||||||
|
return this.get('/api/v1/knowledge/bases');
|
||||||
|
}
|
||||||
|
|
||||||
|
public getKnowledgeBase(uuid: string): Promise<ApiRespKnowledgeBase> {
|
||||||
|
return this.get(`/api/v1/knowledge/bases/${uuid}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public createKnowledgeBase(base: KnowledgeBase): Promise<{ uuid: string }> {
|
||||||
|
return this.post('/api/v1/knowledge/bases', base);
|
||||||
|
}
|
||||||
|
|
||||||
// ============ Plugins API ============
|
// ============ Plugins API ============
|
||||||
public getPlugins(): Promise<ApiRespPlugins> {
|
public getPlugins(): Promise<ApiRespPlugins> {
|
||||||
return this.get('/api/v1/plugins');
|
return this.get('/api/v1/plugins');
|
||||||
|
|||||||
Reference in New Issue
Block a user