Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(bot): update bot create text #488

Merged
merged 2 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions client/.kiwi/en/edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ export default {
chongXinShengChengPei: 'Regenerate Configuration',
ziDongShengChengPei: 'Automatically Generate Configuration',
diZhiYouWu: 'Invalid Address',
qingShuRuGI: 'Please enter the GitHub project address',
qingShuRuGI: 'Please enter the GitHub project URL',
fuZhiTOK: 'Copy Token',
tOKEN: 'Token has been copied to clipboard',
gITHU: 'GitHub Project Address',
bangWoPeiZhiYi: 'Help me configure a Q&A bot',
gITHU: 'GitHub Project URL',
bangWoPeiZhiYi: 'Help me create a Q&A bot',
chuCiJianMianXian:
'👋🏻 Hello! Nice to meet you. Let me introduce myself: I am PeterCat, a robot for an open-source project. You can configure a Q&A robot by talking to me.',
'👋🏻 Hello! Nice to meet you. Let me introduce myself: I am PeterCat, a robot for an open-source project. You can create a Q&A robot by talking to me.',
shengChengShiBai: 'Generation Failed',
shengChengChengGongE: 'Generation Successful',
baoCunShiBaiE: 'Save Failed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
SelectItem,
SelectSection,
Chip,
Image,
} from '@nextui-org/react';
import Collapse from './Collapse';
import { BotProfile } from '@/app/interface';
Expand Down Expand Up @@ -233,11 +234,12 @@ const BotCreateFrom = () => {
</label>
</Collapse>
<Collapse title={I18N.components.BotCreateFrom.weiXianCaoZuo}>
<Button
color="danger"
className="bg-[url('/images/delete.png')] h-[160px] w-[160px] bg-cover"
rounded-lg
onPress={onOpen}
<img
src="/images/delete-button.svg"
alt="delete bot"
width={160}
height={87}
onClick={onOpen}
/>
</Collapse>
</form>
Expand Down
41 changes: 31 additions & 10 deletions client/app/factory/edit/components/DeployBotModal/DeployContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export const DeployContent: React.FC<IDeployContentProps> = ({
<span className="text-gray-500 text-[14px]">
{isOpenApprovalStatus ? (
<div className="flex flex-col">
{I18N.DeployBotModal.DeployContent.shenHeZhong}{approval_path && (
{I18N.DeployBotModal.DeployContent.shenHeZhong}
{approval_path && (
<a href={approval_path} target="_blank">
{approval_path}
</a>
Expand All @@ -53,7 +54,8 @@ export const DeployContent: React.FC<IDeployContentProps> = ({
<span>{I18N.DeployBotModal.DeployContent.ninDeJiQiRen}</span>
) : (
<span>
{I18N.DeployBotModal.DeployContent.zheJiangTiJiaoYi}</span>
{I18N.DeployBotModal.DeployContent.zheJiangTiJiaoYi}
</span>
)}
</>
)}
Expand All @@ -65,16 +67,23 @@ export const DeployContent: React.FC<IDeployContentProps> = ({
const renderDeployMarket = () => {
const { deployWebsite } = deployInfo;
const { approval_path, approval_status } = websiteApproval;
let isChecked = false;
if (deployWebsite?.checked !== undefined) {
isChecked = deployWebsite?.checked;
} else if (deployWebsite?.targetUrl) {
isChecked = true;
}
return (
<DeployItem
canHide={true}
disabled={approval_status === 'open'}
checked={deployWebsite?.checked ?? !!approval_path}
disabled={approval_status === 'open' || !deployWebsite?.targetUrl}
ch-liuzhide marked this conversation as resolved.
Show resolved Hide resolved
checked={isChecked}
defaultIsHide={!approval_path}
key={'website'}
title={I18N.DeployBotModal.DeployContent.buShuDaoWoDe}
subTitle={I18N.DeployBotModal.DeployContent.dianJiKaiShiPei}
onChange={(key, checked) => {
// checkBox onChange
onChange({
...deployInfo,
deployWebsite: { ...deployWebsite, checked },
Expand All @@ -93,7 +102,8 @@ export const DeployContent: React.FC<IDeployContentProps> = ({
type="url"
label={
<span className="font-sans text-[14px] font-semibold leading-[20px] text-left">
{I18N.DeployBotModal.DeployContent.muBiaoWangZhanYu}</span>
{I18N.DeployBotModal.DeployContent.muBiaoWangZhanYu}
</span>
}
value={deployInfo?.deployWebsite?.targetUrl}
onChange={(e) => {
Expand Down Expand Up @@ -159,7 +169,10 @@ export const DeployContent: React.FC<IDeployContentProps> = ({
}}
>
{peterCatBotRepos?.map((repo: GithubRepoConfig) => (
<div className="w-full p-[8px] bg-[#F4F4F5] rounded-[8px]" key={repo.repo_id}>
<div
className="w-full p-[8px] bg-[#F4F4F5] rounded-[8px]"
key={repo.repo_id}
>
<Checkbox value={repo.repo_id!}>
<div
style={{ display: 'flex', flexDirection: 'column' }}
Expand All @@ -173,7 +186,11 @@ export const DeployContent: React.FC<IDeployContentProps> = ({
item.checked && item.repo_id === repo.repo_id,
) && (
<span className="text-[#EF4444] text-[12px]">
{I18N.DeployBotModal.DeployContent.zheJiangTiHuanCang}</span>
{
I18N.DeployBotModal.DeployContent
.zheJiangTiHuanCang
}
</span>
)}
</div>
</Checkbox>
Expand All @@ -183,11 +200,13 @@ export const DeployContent: React.FC<IDeployContentProps> = ({
) : (
<div>
<span>
{I18N.DeployBotModal.DeployContent.weiNengHuoQuNin}<a
{I18N.DeployBotModal.DeployContent.weiNengHuoQuNin}
<a
href="https://github.com/apps/petercat-assistant"
target="_blank"
>
{I18N.DeployBotModal.DeployContent.qianWangAnZhuang}</a>
{I18N.DeployBotModal.DeployContent.qianWangAnZhuang}
</a>
</span>
<span>{I18N.DeployBotModal.DeployContent.shuaXin}</span>
</div>
Expand All @@ -198,7 +217,9 @@ export const DeployContent: React.FC<IDeployContentProps> = ({
};
return (
<>
<span className="text-[14px] text-gray-800">{I18N.DeployBotModal.DeployContent.buShuDaoQiTa}</span>
<span className="text-[14px] text-gray-800">
{I18N.DeployBotModal.DeployContent.buShuDaoQiTa}
</span>
{renderPublicMarket()}
{renderDeployMarket()}
{renderBindRepo()}
Expand Down
4 changes: 2 additions & 2 deletions client/app/factory/edit/components/Knowledge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default function Knowledge({ repoName, goBack }: IProps) {
</div>
)}
</MySpinner>
{RagDocData?.total && RagDocData?.total > 12 && (
{RagDocData?.total && RagDocData?.total > 12 ? (
<Pagination
className="flex justify-center items-center mt-[60px] p-[0] w-full"
total={Math.ceil((RagDocData?.total ?? 0) / 12)}
Expand All @@ -145,7 +145,7 @@ export default function Knowledge({ repoName, goBack }: IProps) {
size="lg"
onChange={(page) => setPageNumber(page)}
/>
)}
) : null}
</div>
</div>
);
Expand Down
21 changes: 14 additions & 7 deletions client/app/factory/edit/components/KnowledgeBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ type IProps = {
const KnowledgeBtn = (props: IProps) => {
const { onClick, repoName, mode } = props;
const { setTaskProfile } = useBotTask();
const [shouldGetTask, setShouldGetTask] = React.useState<boolean>(!!repoName);
const [shouldGetTask, setShouldGetTask] = React.useState<boolean>();
const [taskLoading, setTaskLoading] = React.useState<boolean>(true);
const [allowShowChunkList, setAllowShowChunkList] =
React.useState<boolean>(false);

const { data: taskList } = useGetBotRagTask(repoName, shouldGetTask, true);
const taskCnt = taskList?.length ?? 0;
const { data: taskList } = useGetBotRagTask(
repoName,
// if repoName is not empty, query taskList
!!repoName,
// if task is running, query every 5s
// if task is completed, query once
taskLoading,
);

const taskCnt = taskList?.length ?? 0;
// compute task running status by taskList
useEffect(() => {
if (!taskList) return;
Expand All @@ -43,9 +50,9 @@ const KnowledgeBtn = (props: IProps) => {
if (completeTaskCnt > 0) {
setAllowShowChunkList(true);
}
const taskRunning = taskCnt === completeTaskCnt ? false : true;
setTaskLoading(taskRunning);
setTaskProfile({ running: taskRunning });
const isTaskRunning = taskList?.length === completeTaskCnt ? false : true;
setTaskLoading(isTaskRunning);
setTaskProfile({ running: isTaskRunning });
}, [taskList]);

// close the interval query
Expand Down Expand Up @@ -75,7 +82,7 @@ const KnowledgeBtn = (props: IProps) => {
startContent={taskLoading ? null : <RefreshIcon />}
onClick={(e) => {
e.preventDefault();
// TODO: reload knowledge
// TODO: reload knowledge embedding
}}
>
{taskLoading ? (
Expand Down
28 changes: 16 additions & 12 deletions client/app/factory/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import I18N from '@/app/utils/I18N';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { Tabs, Tab, Button, Input, Avatar } from '@nextui-org/react';
import BotCreateFrom from '@/app/factory/edit/components/BotCreateFrom';
import BotCreateFrom from '@/app/factory/edit/components/BotCreateForm';
import { toast, ToastContainer } from 'react-toastify';
import BackIcon from '@/public/icons/BackIcon';
import { CopyToClipboard } from 'react-copy-to-clipboard';
Expand Down Expand Up @@ -44,6 +44,7 @@ export default function Edit() {
const { language } = useGlobal();

const { botProfile, setBotProfile } = useBot();
console.log('botProfile', botProfile);
const { user, status } = useUser();
const router = useRouter();
const searchParams = useSearchParams();
Expand Down Expand Up @@ -91,6 +92,7 @@ export default function Edit() {
try {
const data = JSON.parse(response)?.data?.[0];
if (!isEmpty(data)) {
debugger;
setBotProfile((draft) => {
draft.id = data.id;
draft.name = data.name;
Expand Down Expand Up @@ -130,7 +132,7 @@ export default function Edit() {
);

useEffect(() => {
if (!isEmpty(config))
if (!isEmpty(config)) {
setBotProfile((draft) => {
draft.id = config.id;
draft.name = config.name || '';
Expand All @@ -143,6 +145,7 @@ export default function Edit() {
draft.repoName = config.repo_name ?? '';
draft.domain_whitelist = config.domain_whitelist ?? [];
});
}
}, [config]);

useEffect(() => {
Expand All @@ -158,14 +161,6 @@ export default function Edit() {
});
}, [generatorResponseData]);

const updateBot = async () => {
const params = {
...botProfile,
starters: botProfile?.starters?.filter((s) => s),
};
onUpdateBot(params);
};

useEffect(() => {
if (createSuccess) {
setDeployModalIsOpen(true);
Expand Down Expand Up @@ -206,7 +201,7 @@ export default function Edit() {
const botInfo = createResponseData?.[0];
if (!isEmpty(botInfo)) {
setBotProfile((draft) => {
draft.repoName = botProfile.repoName;
draft.repoName = botInfo.repo_name;
draft.id = botInfo.id;
draft.name = botInfo.name;
draft.avatar = botInfo.avatar;
Expand Down Expand Up @@ -282,6 +277,7 @@ export default function Edit() {
const url = e.target.value;
setGitUrl(url);
}}
value={gitUrl}
isDisabled={isEdit}
required
classNames={{ label: 'w-full' }}
Expand Down Expand Up @@ -328,7 +324,7 @@ export default function Edit() {
)}
{isEdit && activeTab === ConfigTypeEnum.MANUAL_CONFIG && (
<KnowledgeBtn
repoName={botProfile.repoName!}
repoName={botProfile.repoName}
onClick={() => {
setVisibleType(VisibleTypeEnum.KNOWLEDGE_DETAIL);
}}
Expand All @@ -342,6 +338,14 @@ export default function Edit() {
</div>
);

const updateBot = async () => {
const params = {
...botProfile,
starters: botProfile?.starters?.filter((s) => s),
};
onUpdateBot(params);
};

return (
<BotTaskProvider>
<div className="flex h-full w-full flex-col items-center bg-white mb-[-40px] overflow-hidden">
Expand Down
Loading
Loading