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
bf1592d2
authored
Jun 14, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: admin set share
parent
c6259fca
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
77 additions
and
26 deletions
+77
-26
admin/service/route/app.js
+38
-9
admin/service/schema.js
+1
-0
admin/src/App.tsx
+20
-7
admin/src/fields.ts
+10
-6
client/src/pages/api/model/share/getModels.ts
+1
-1
client/src/pages/model/components/detail/components/ModelEditForm.tsx
+3
-3
client/src/service/models/model.ts
+4
-0
No files found.
admin/service/route/app.js
View file @
bf1592d2
import
{
User
,
Model
,
Kb
}
from
'../schema.js'
;
import
{
Model
,
Kb
}
from
'../schema.js'
;
import
{
auth
}
from
'./system.js'
;
import
{
auth
}
from
'./system.js'
;
export
const
useAppRoute
=
(
app
)
=>
{
export
const
useAppRoute
=
(
app
)
=>
{
...
@@ -8,18 +8,19 @@ export const useAppRoute = (app) => {
...
@@ -8,18 +8,19 @@ export const useAppRoute = (app) => {
const
start
=
parseInt
(
req
.
query
.
_start
)
||
0
;
const
start
=
parseInt
(
req
.
query
.
_start
)
||
0
;
const
end
=
parseInt
(
req
.
query
.
_end
)
||
20
;
const
end
=
parseInt
(
req
.
query
.
_end
)
||
20
;
const
order
=
req
.
query
.
_order
===
'DESC'
?
-
1
:
1
;
const
order
=
req
.
query
.
_order
===
'DESC'
?
-
1
:
1
;
const
sort
=
req
.
query
.
_sort
||
'_id'
;
const
sort
=
req
.
query
.
_sort
;
const
userId
=
req
.
query
.
userId
||
''
;
const
name
=
req
.
query
.
name
||
''
;
const
name
=
req
.
query
.
name
||
''
;
const
id
=
req
.
query
.
id
||
''
;
const
where
=
{
const
where
=
{
...(
userId
?
{
userId
:
userId
}
:
{
}),
...(
name
&&
{
name
:
{
$regex
:
name
,
$options
:
'i'
}
}),
name
...(
id
&&
{
_id
:
id
})
};
};
const
modelsRaw
=
await
Model
.
find
()
const
modelsRaw
=
await
Model
.
find
(
where
)
.
skip
(
start
)
.
skip
(
start
)
.
limit
(
end
-
start
)
.
limit
(
end
-
start
)
.
sort
({
[
sort
]:
order
});
.
sort
({
[
sort
]:
order
,
'share.isShare'
:
-
1
,
'share.collection'
:
-
1
});
const
models
=
[];
const
models
=
[];
...
@@ -37,15 +38,19 @@ export const useAppRoute = (app) => {
...
@@ -37,15 +38,19 @@ export const useAppRoute = (app) => {
id
:
model
.
_id
.
toString
(),
id
:
model
.
_id
.
toString
(),
userId
:
model
.
userId
,
userId
:
model
.
userId
,
name
:
model
.
name
,
name
:
model
.
name
,
model
:
model
.
chat
?.
chatModel
,
relatedKbs
:
kbNames
,
// 将relatedKbs的id转换为相应的Kb名称
relatedKbs
:
kbNames
,
// 将relatedKbs的id转换为相应的Kb名称
searchMode
:
model
.
chat
?.
searchMode
,
searchMode
:
model
.
chat
?.
searchMode
,
systemPrompt
:
model
.
chat
?.
systemPrompt
||
''
,
systemPrompt
:
model
.
chat
?.
systemPrompt
||
''
,
temperature
:
model
.
chat
?.
temperature
'share.topNum'
:
model
.
share
?.
topNum
||
0
,
'share.isShare'
:
model
.
share
?.
isShare
||
false
,
'share.intro'
:
model
.
share
?.
intro
,
'share.collection'
:
model
.
share
?.
collection
||
0
};
};
models
.
push
(
orderedModel
);
models
.
push
(
orderedModel
);
}
}
const
totalCount
=
await
Model
.
countDocuments
();
const
totalCount
=
await
Model
.
countDocuments
(
where
);
res
.
header
(
'Access-Control-Expose-Headers'
,
'X-Total-Count'
);
res
.
header
(
'Access-Control-Expose-Headers'
,
'X-Total-Count'
);
res
.
header
(
'X-Total-Count'
,
totalCount
);
res
.
header
(
'X-Total-Count'
,
totalCount
);
res
.
json
(
models
);
res
.
json
(
models
);
...
@@ -54,4 +59,28 @@ export const useAppRoute = (app) => {
...
@@ -54,4 +59,28 @@ export const useAppRoute = (app) => {
res
.
status
(
500
).
json
({
error
:
'Error fetching models'
,
details
:
err
.
message
});
res
.
status
(
500
).
json
({
error
:
'Error fetching models'
,
details
:
err
.
message
});
}
}
});
});
// 修改 app 信息
app
.
put
(
'/models/:id'
,
auth
(),
async
(
req
,
res
)
=>
{
try
{
const
_id
=
req
.
params
.
id
;
let
{
share
:
{
isShare
,
intro
,
topNum
}
}
=
req
.
body
;
await
Model
.
findByIdAndUpdate
(
_id
,
{
$set
:
{
'share.topNum'
:
Number
(
topNum
),
'share.isShare'
:
isShare
===
'true'
,
'share.intro'
:
intro
}
});
res
.
json
({});
}
catch
(
err
)
{
console
.
log
(
`Error updating user:
${
err
}
`
);
res
.
status
(
500
).
json
({
error
:
'Error updating user'
});
}
});
};
};
admin/service/schema.js
View file @
bf1592d2
...
@@ -69,6 +69,7 @@ const modelSchema = new mongoose.Schema({
...
@@ -69,6 +69,7 @@ const modelSchema = new mongoose.Schema({
chatModel
:
String
chatModel
:
String
},
},
share
:
{
share
:
{
topNum
:
Number
,
isShare
:
Boolean
,
isShare
:
Boolean
,
isShareDetail
:
Boolean
,
isShareDetail
:
Boolean
,
intro
:
String
,
intro
:
String
,
...
...
admin/src/App.tsx
View file @
bf1592d2
...
@@ -54,7 +54,25 @@ function App() {
...
@@ -54,7 +54,25 @@ function App() {
/>
/>
}
}
/>
/>
<
Resource
name=
"models"
icon=
{
<
IconApps
/>
}
label=
"应用"
list=
{
<
ListTable
filter=
{
[
createTextField
(
'id'
,
{
label
:
'id'
}),
createTextField
(
'name'
,
{
label
:
'name'
})
]
}
fields=
{
ModelFields
}
action=
{
{
detail
:
true
,
edit
:
true
}
}
/>
}
/>
<
Resource
<
Resource
name=
"pays"
name=
"pays"
label=
"支付记录"
label=
"支付记录"
...
@@ -90,12 +108,7 @@ function App() {
...
@@ -90,12 +108,7 @@ function App() {
/>
/>
}
}
/>
/>
<
Resource
name=
"models"
icon=
{
<
IconApps
/>
}
label=
"应用"
list=
{
<
ListTable
fields=
{
ModelFields
}
action=
{
{
detail
:
true
}
}
/>
}
/>
<
Resource
<
Resource
name=
"system"
name=
"system"
label=
"系统"
label=
"系统"
...
...
admin/src/fields.ts
View file @
bf1592d2
...
@@ -26,17 +26,21 @@ export const kbFields = [
...
@@ -26,17 +26,21 @@ export const kbFields = [
export
const
ModelFields
=
[
export
const
ModelFields
=
[
createTextField
(
'id'
,
{
label
:
'ID'
}),
createTextField
(
'id'
,
{
label
:
'ID'
}),
createTextField
(
'userId'
,
{
label
:
'所属用户'
}),
createTextField
(
'userId'
,
{
label
:
'所属用户'
,
list
:
{
hidden
:
true
}
}),
createTextField
(
'name'
,
{
label
:
'名字'
}),
createTextField
(
'name'
,
{
label
:
'名字'
}),
createTextField
(
'relatedKbs'
,
{
label
:
'引用的知识库'
}),
createTextField
(
'model'
,
{
label
:
'模型'
}),
createTextField
(
'searchMode'
,
{
label
:
'搜索模式'
}),
createTextField
(
'share.collection'
,
{
label
:
'收藏数'
,
list
:
{
sort
:
true
}
}),
createTextField
(
'share.topNum'
,
{
label
:
'置顶等级'
,
list
:
{
sort
:
true
}
}),
createTextField
(
'share.isShare'
,
{
label
:
'是否分享(true,false)'
}),
createTextField
(
'share.intro'
,
{
label
:
'介绍'
,
list
:
{
width
:
400
}
}),
createTextField
(
'relatedKbs'
,
{
label
:
'引用的知识库'
,
list
:
{
hidden
:
true
}
}),
createTextField
(
'systemPrompt'
,
{
createTextField
(
'systemPrompt'
,
{
label
:
'提示词'
,
label
:
'提示词'
,
list
:
{
list
:
{
width
:
400
width
:
400
,
hidden
:
true
}
}
}),
})
createTextField
(
'temperature'
,
{
label
:
'温度'
})
];
];
export
const
SystemFields
=
[
export
const
SystemFields
=
[
...
...
client/src/pages/api/model/share/getModels.ts
View file @
bf1592d2
...
@@ -77,7 +77,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
...
@@ -77,7 +77,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse<
}
}
},
},
{
{
$sort
:
{
'share.collection'
:
-
1
}
$sort
:
{
'share.
topNum'
:
-
1
,
'share.
collection'
:
-
1
}
},
},
{
{
$skip
:
(
pageNum
-
1
)
*
pageSize
$skip
:
(
pageNum
-
1
)
*
pageSize
...
...
client/src/pages/model/components/detail/components/ModelEditForm.tsx
View file @
bf1592d2
...
@@ -344,7 +344,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
...
@@ -344,7 +344,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
{
isOwner
&&
(
{
isOwner
&&
(
<>
<>
{
/* model share setting */
}
{
/* model share setting */
}
<
Card
p=
{
4
}
>
{
/*
<Card p={4}>
<Box fontWeight={'bold'}>分享设置</Box>
<Box fontWeight={'bold'}>分享设置</Box>
<Box>
<Box>
<Flex mt={5} alignItems={'center'}>
<Flex mt={5} alignItems={'center'}>
...
@@ -373,7 +373,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
...
@@ -373,7 +373,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
/>
/>
</Box>
</Box>
</Box>
</Box>
</
Card
>
</Card>
*/
}
<
Card
p=
{
4
}
>
<
Card
p=
{
4
}
>
<
Flex
justifyContent=
{
'space-between'
}
>
<
Flex
justifyContent=
{
'space-between'
}
>
<
Box
fontWeight=
{
'bold'
}
>
关联的知识库
</
Box
>
<
Box
fontWeight=
{
'bold'
}
>
关联的知识库
</
Box
>
...
@@ -411,7 +411,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
...
@@ -411,7 +411,7 @@ ${e.password ? `密码为: ${e.password}` : ''}`;
</>
</>
)
}
)
}
{
/* shareChat */
}
{
/* shareChat */
}
<
Card
p=
{
4
}
gridColumnStart=
{
1
}
gridColumnEnd=
{
[
2
,
3
]
}
>
<
Card
p=
{
4
}
>
<
Flex
justifyContent=
{
'space-between'
}
>
<
Flex
justifyContent=
{
'space-between'
}
>
<
Box
fontWeight=
{
'bold'
}
>
<
Box
fontWeight=
{
'bold'
}
>
免登录聊天窗口
免登录聊天窗口
...
...
client/src/service/models/model.ts
View file @
bf1592d2
...
@@ -61,6 +61,10 @@ const ModelSchema = new Schema({
...
@@ -61,6 +61,10 @@ const ModelSchema = new Schema({
}
}
},
},
share
:
{
share
:
{
topNum
:
{
type
:
Number
,
default
:
0
},
isShare
:
{
isShare
:
{
type
:
Boolean
,
type
:
Boolean
,
default
:
false
default
:
false
...
...
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