diff --git a/client/app/factory/edit/[id]/page.tsx b/client/app/factory/edit/[id]/page.tsx index 8cf01ba3..6dfbb7d0 100644 --- a/client/app/factory/edit/[id]/page.tsx +++ b/client/app/factory/edit/[id]/page.tsx @@ -4,6 +4,7 @@ import { Tabs, Tab, Button, Input, Avatar } from '@nextui-org/react'; import BotCreateFrom from '@/app/factory/edit/components/BotCreateFrom'; import { toast, ToastContainer } from 'react-toastify'; import BackIcon from '@/public/icons/BackIcon'; +import { CopyToClipboard } from 'react-copy-to-clipboard'; import { useBotConfigGenerator, useBotConfig, @@ -80,6 +81,7 @@ export default function Edit({ params }: { params: { id: string } }) { draft.description = data.description; draft.starters = data.starters; draft.public = data.public; + draft.repoName = data.repoName; draft.helloMessage = data.hello_message; }); } @@ -109,6 +111,7 @@ export default function Edit({ params }: { params: { id: string } }) { draft.helloMessage = config.hello_message || ''; draft.prompt = config.prompt || ''; draft.public = config.public ?? false; + draft.repoName = config.repo_name ?? ''; }); }, [config]); @@ -214,6 +217,24 @@ export default function Edit({ params }: { params: { id: string } }) { /> ); + const manualConfigLabel = ( +
+ Github 项目名 + {botProfile.id && ( + { + toast.success('Token 已复制到剪贴板'); + }} + > + {/* @ts-ignore */} + + 复制 Token + + + )} +
+ ); const manualConfigContent = (
@@ -222,7 +243,7 @@ export default function Edit({ params }: { params: { id: string } }) { type="text" variant="bordered" name="repo_name" - label="Github 项目名" + label={manualConfigLabel} disabled={isEdit} value={botProfile?.repoName} placeholder="请输入 GitHub 项目名称 (ORG_NAME/REPO_NAME)" @@ -233,7 +254,9 @@ export default function Edit({ params }: { params: { id: string } }) { draft.repoName = repoName; }); }} + isDisabled={isEdit} required + classNames={{ label: 'w-full' }} className="mt-1 mb-6 block w-full border-gray-300 rounded-md shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50" />
diff --git a/client/app/factory/edit/components/KnowledgeBtn.tsx b/client/app/factory/edit/components/KnowledgeBtn.tsx index aa3cf95e..a455b6a1 100644 --- a/client/app/factory/edit/components/KnowledgeBtn.tsx +++ b/client/app/factory/edit/components/KnowledgeBtn.tsx @@ -18,12 +18,15 @@ type IProps = { const KnowledgeBtn = (props: IProps) => { const { onClick, botId, mode } = props; const { setTaskProfile } = useBotTask(); - const [isPolling, setIsPolling] = React.useState(true); + const [shouldGetTask, setShouldGetTask] = React.useState(!!botId); const [taskLoading, setTaskLoading] = React.useState(true); - const { data: taskList } = useGetBotRagTask(botId, isPolling, true); - const taskCnt = taskList?.length ?? 0; const [allowShowChunkList, setAllowShowChunkList] = React.useState(false); + + const { data: taskList } = useGetBotRagTask(botId, shouldGetTask, true); + const taskCnt = taskList?.length ?? 0; + + // compute task running status by taskList useEffect(() => { if (!taskList) return; let completeTaskCnt = 0; @@ -44,12 +47,13 @@ const KnowledgeBtn = (props: IProps) => { setTaskProfile({ running: taskRunning }); }, [taskList]); + // close the interval query useEffect(() => { - setIsPolling(true); return () => { - setIsPolling(false); + setShouldGetTask(false); }; }, []); + if (mode === 'pageHeader') { return ( <> diff --git a/client/app/market/page.tsx b/client/app/market/page.tsx index 4f018a0e..efe94961 100644 --- a/client/app/market/page.tsx +++ b/client/app/market/page.tsx @@ -67,7 +67,7 @@ export default function Home() { return (
- + {!isEmpty(bots) && map(bots, (bot: Bot) => ( diff --git a/client/components/Navbar.tsx b/client/components/Navbar.tsx index 9c9114cd..90925ae3 100644 --- a/client/components/Navbar.tsx +++ b/client/components/Navbar.tsx @@ -113,7 +113,7 @@ export function Navbar() { />
- {!pathname.includes('/factory/list') && } + {!pathname.includes('/factory/list') && } {pathname.includes('/factory/list') && ( )} - {type === 'list' && } + {area === 'list' && } ( + + + + +); diff --git a/client/types/database.types.ts b/client/types/database.types.ts index 66163df9..5279aae9 100644 --- a/client/types/database.types.ts +++ b/client/types/database.types.ts @@ -45,6 +45,7 @@ export type Database = { name: string prompt: string | null public: boolean | null + repo_name:string | null starters: string[] | null uid: string | null updated_at: string | null @@ -59,6 +60,7 @@ export type Database = { name?: string prompt?: string | null public?: boolean | null + repo_name?:string | null starters?: string[] | null uid?: string | null updated_at?: string | null @@ -73,6 +75,7 @@ export type Database = { name?: string prompt?: string | null public?: boolean | null + repo_name?:string | null starters?: string[] | null uid?: string | null updated_at?: string | null diff --git a/client/yarn.lock b/client/yarn.lock index 6ae61175..ed5fe836 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -4731,6 +4731,13 @@ resolved "https://registry.npmjs.org/@types/qs/-/qs-6.9.15.tgz#adde8a060ec9c305a82de1babc1056e73bd64dce" integrity sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg== +"@types/react-copy-to-clipboard@^5.0.7": + version "5.0.7" + resolved "https://registry.yarnpkg.com/@types/react-copy-to-clipboard/-/react-copy-to-clipboard-5.0.7.tgz#0cb724d4228f1c2f8f5675671b3971c8801d5f45" + integrity sha512-Gft19D+as4M+9Whq1oglhmK49vqPhcLzk8WfvfLvaYMIPYanyfLy0+CwFucMJfdKoSFyySPmkkWn8/E6voQXjQ== + dependencies: + "@types/react" "*" + "@types/react-dom@18.2.7": version "18.2.7" resolved "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.7.tgz#67222a08c0a6ae0a0da33c3532348277c70abb63" @@ -9093,7 +9100,7 @@ re-resizable@6.9.17, re-resizable@^6.9.16: react-copy-to-clipboard@^5.1.0: version "5.1.0" - resolved "https://registry.npmjs.org/react-copy-to-clipboard/-/react-copy-to-clipboard-5.1.0.tgz#09aae5ec4c62750ccb2e6421a58725eabc41255c" + resolved "https://registry.yarnpkg.com/react-copy-to-clipboard/-/react-copy-to-clipboard-5.1.0.tgz#09aae5ec4c62750ccb2e6421a58725eabc41255c" integrity sha512-k61RsNgAayIJNoy9yDsYzDe/yAZAzEbEgcz3DZMhF686LEyukcE1hzurxe85JandPUG+yTfGVFzuEw3xt8WP/A== dependencies: copy-to-clipboard "^3.3.1" @@ -9688,7 +9695,16 @@ string-convert@^0.2.0: resolved "https://registry.npmjs.org/string-convert/-/string-convert-0.2.1.tgz#6982cc3049fbb4cd85f8b24568b9d9bf39eeff97" integrity sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A== -"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: +"string-width-cjs@npm:string-width@^4.2.0": + version "4.2.3" + resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" + integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== + dependencies: + emoji-regex "^8.0.0" + is-fullwidth-code-point "^3.0.0" + strip-ansi "^6.0.1" + +string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3: version "4.2.3" resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== @@ -9780,7 +9796,14 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" -"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: +"strip-ansi-cjs@npm:strip-ansi@^6.0.1": + version "6.0.1" + resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" + integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== + dependencies: + ansi-regex "^5.0.1" + +strip-ansi@^6.0.0, strip-ansi@^6.0.1: version "6.0.1" resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== @@ -10502,7 +10525,16 @@ word-wrap@^1.2.5: resolved "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34" integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA== -"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: +"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": + version "7.0.0" + resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" + integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== + dependencies: + ansi-styles "^4.0.0" + string-width "^4.1.0" + strip-ansi "^6.0.0" + +wrap-ansi@^7.0.0: version "7.0.0" resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== diff --git a/server/bot/builder.py b/server/bot/builder.py index a1884508..366ea3df 100644 --- a/server/bot/builder.py +++ b/server/bot/builder.py @@ -11,10 +11,10 @@ async def bot_info_generator( - uid: str, - repo_name: str, - starters: Optional[List[str]] = None, - hello_message: Optional[str] = None + uid: str, + repo_name: str, + starters: Optional[List[str]] = None, + hello_message: Optional[str] = None, ): try: # Step1:Get the repository object @@ -31,10 +31,22 @@ async def bot_info_generator( "prompt": prompt, "uid": uid, "label": "Assistant", - "starters": starters if starters else [f"介绍一下 {repo.name} 这个项目", f"查看 {repo_name} 的贡献指南", - "我该怎样快速上手"], + "starters": ( + starters + if starters + else [ + f"介绍一下 {repo.name} 这个项目", + f"查看 {repo_name} 的贡献指南", + "我该怎样快速上手", + ] + ), "public": False, - "hello_message": hello_message if hello_message else "我是你专属的答疑机器人,你可以问我关于当前项目的任何问题~" + "hello_message": ( + hello_message + if hello_message + else "我是你专属的答疑机器人,你可以问我关于当前项目的任何问题~" + ), + "repo_name": repo_name, } return bot_data @@ -60,10 +72,10 @@ def trigger_rag_task(repo_name: str, bot_id: str): async def bot_builder( - uid: str, - repo_name: str, - starters: Optional[List[str]] = None, - hello_message: Optional[str] = None + uid: str, + repo_name: str, + starters: Optional[List[str]] = None, + hello_message: Optional[str] = None, ): """ create a bot based on the given github repository. diff --git a/server/requirements.txt b/server/requirements.txt index 21845f6f..c9420f15 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -7,7 +7,7 @@ langserve langchain_community>=0.2.11 langchain>=0.2.12 langchain_google_genai -PyGithub +PyGithub==2.3.0 GitPython python-multipart httpx[socks] @@ -18,14 +18,15 @@ boto3>=1.34.84 pytest-cov PyJWT pydantic>=2.7.0 -unstructured[md] +unstructured>=0.15.9 python-dotenv -python-jose -six -jose -itsdangerous -fastapi_auth0 +python-jose>=3.3.0 +six>=1.16.0 +jose>=1.0.0 +itsdangerous==2.2.0 +fastapi_auth0==0.5.0 requests pytest httpx +urllib3>=2.2.2 petercat_utils>=0.1.31 \ No newline at end of file