Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Unverified
Commit
a04b6618
authored
Jul 06, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: kb un refresh
parent
56977214
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
28 deletions
+42
-28
client/src/pages/api/openapi/v1/chat/completions.ts
+4
-0
client/src/pages/kb/components/DataCard.tsx
+7
-7
client/src/pages/kb/components/Detail.tsx
+26
-18
client/src/pages/kb/index.tsx
+5
-3
No files found.
client/src/pages/api/openapi/v1/chat/completions.ts
View file @
a04b6618
...
...
@@ -167,6 +167,8 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
return
res
.
json
({
id
:
chatId
||
''
,
model
:
model
.
chat
.
chatModel
,
object
:
'chat.completion'
,
created
:
1688608930
,
usage
:
{
prompt_tokens
:
0
,
completion_tokens
:
0
,
total_tokens
:
0
},
choices
:
[
{
message
:
{
role
:
'assistant'
,
content
:
response
},
finish_reason
:
'stop'
,
index
:
0
}
...
...
@@ -296,6 +298,8 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
: {}),
newChatId,
id: chatId || '',
object: 'chat.completion',
created: 1688608930,
model: model.chat.chatModel,
usage: { prompt_tokens: 0, completion_tokens: 0, total_tokens: tokens },
choices: [
...
...
client/src/pages/kb/components/DataCard.tsx
View file @
a04b6618
import
React
,
{
useCallback
,
useState
,
useRef
}
from
'react'
;
import
React
,
{
useCallback
,
useState
,
useRef
,
useEffect
}
from
'react'
;
import
{
Box
,
Card
,
...
...
@@ -50,11 +50,11 @@ const DataCard = ({ kbId }: { kbId: string }) => {
}
=
usePagination
<
KbDataItemType
>
({
api
:
getKbDataList
,
pageSize
:
24
,
defaultRequest
:
false
,
params
:
{
kbId
,
searchText
},
defaultRequest
:
false
}
});
const
[
editInputData
,
setEditInputData
]
=
useState
<
InputDataType
>
();
...
...
@@ -133,11 +133,11 @@ const DataCard = ({ kbId }: { kbId: string }) => {
refetchInterval
:
5000
,
enabled
:
qaListLen
>
0
||
vectorListLen
>
0
});
useQuery
([
'getKbData'
,
kbId
],
()
=>
{
useEffect
(()
=>
{
setSearchText
(
''
);
getData
(
1
);
return
null
;
});
},
[
kbId
]);
return
(
<
Box
position=
{
'relative'
}
px=
{
5
}
pb=
{
[
1
,
5
]
}
>
...
...
@@ -314,4 +314,4 @@ const DataCard = ({ kbId }: { kbId: string }) => {
);
};
export
default
DataCard
;
export
default
React
.
memo
(
DataCard
)
;
client/src/pages/kb/components/Detail.tsx
View file @
a04b6618
...
...
@@ -8,7 +8,7 @@ import { useUserStore } from '@/store/user';
import
{
KbItemType
}
from
'@/types/plugin'
;
import
{
useScreen
}
from
'@/hooks/useScreen'
;
import
{
getErrText
}
from
'@/utils/tools'
;
import
Info
,
{
type
ComponentRef
}
from
'./Info'
;
import
{
type
ComponentRef
}
from
'./Info'
;
import
Tabs
from
'@/components/Tabs'
;
import
dynamic
from
'next/dynamic'
;
import
DataCard
from
'./DataCard'
;
...
...
@@ -16,6 +16,9 @@ import DataCard from './DataCard';
const
Test
=
dynamic
(()
=>
import
(
'./Test'
),
{
ssr
:
false
});
const
Info
=
dynamic
(()
=>
import
(
'./Info'
),
{
ssr
:
false
});
enum
TabEnum
{
data
=
'data'
,
...
...
@@ -28,7 +31,7 @@ const Detail = ({ kbId }: { kbId: string }) => {
const
router
=
useRouter
();
const
{
isPc
}
=
useScreen
();
const
BasicInfo
=
useRef
<
ComponentRef
>
(
null
);
const
{
setLastKbId
,
kbDetail
,
getKbDetail
,
loadKbList
,
myKbList
}
=
useUserStore
();
const
{
setLastKbId
,
kbDetail
,
getKbDetail
,
loadKbList
}
=
useUserStore
();
const
[
currentTab
,
setCurrentTab
]
=
useState
(
TabEnum
.
data
);
const
form
=
useForm
<
KbItemType
>
({
...
...
@@ -36,25 +39,30 @@ const Detail = ({ kbId }: { kbId: string }) => {
});
const
{
reset
}
=
form
;
useQuery
([
kbId
],
()
=>
getKbDetail
(
kbId
),
{
onSuccess
(
res
)
{
kbId
&&
setLastKbId
(
kbId
);
if
(
res
)
{
setCurrentTab
(
TabEnum
.
data
);
useQuery
(
[
kbId
],
()
=>
{
setCurrentTab
(
TabEnum
.
data
);
return
getKbDetail
(
kbId
);
},
{
onSuccess
(
res
)
{
if
(
!
res
)
return
;
kbId
&&
setLastKbId
(
kbId
);
reset
(
res
);
BasicInfo
.
current
?.
initInput
?.(
res
.
tags
);
},
onError
(
err
:
any
)
{
loadKbList
(
true
);
setLastKbId
(
''
);
router
.
replace
(
`/kb`
);
toast
({
title
:
getErrText
(
err
,
'获取知识库异常'
),
status
:
'error'
});
}
},
onError
(
err
:
any
)
{
loadKbList
(
true
);
setLastKbId
(
''
);
router
.
replace
(
`/kb`
);
toast
({
title
:
getErrText
(
err
,
'获取知识库异常'
),
status
:
'error'
});
}
}
);
);
return
(
<
Flex
...
...
@@ -88,4 +96,4 @@ const Detail = ({ kbId }: { kbId: string }) => {
);
};
export
default
Detail
;
export
default
React
.
memo
(
Detail
)
;
client/src/pages/kb/index.tsx
View file @
a04b6618
...
...
@@ -28,9 +28,11 @@ const Kb = () => {
<
KbList
kbId=
{
kbId
}
/>
</
SideBar
>
)
}
<
Box
flex=
{
'1 0 0'
}
w=
{
0
}
h=
{
'100%'
}
position=
{
'relative'
}
>
{
kbId
&&
<
KbDetail
kbId=
{
kbId
}
/>
}
</
Box
>
{
!!
kbId
&&
(
<
Box
flex=
{
'1 0 0'
}
w=
{
0
}
h=
{
'100%'
}
position=
{
'relative'
}
>
<
KbDetail
kbId=
{
kbId
}
/>
</
Box
>
)
}
</
Flex
>
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment