Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chatGLM
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘坚-丰林-DEV
chatGLM
Commits
8f0fc1f4
Commit
8f0fc1f4
authored
Apr 16, 2023
by
Ylg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unfinnished: add prompt
parent
6ed561ee
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
279 additions
and
10 deletions
+279
-10
index.less
src/components/deletePromptModal/index.less
+0
-0
index.tsx
src/components/deletePromptModal/index.tsx
+14
-0
index.less
src/components/editPromptModal/index.less
+0
-0
index.tsx
src/components/editPromptModal/index.tsx
+60
-0
index.tsx
src/pages/Chat/index.tsx
+2
-4
index.less
src/pages/PromptWord/index.less
+16
-0
index.tsx
src/pages/PromptWord/index.tsx
+160
-6
api.ts
src/services/chatGLM/api.ts
+27
-0
No files found.
src/components/deletePromptModal/index.less
0 → 100644
View file @
8f0fc1f4
src/components/deletePromptModal/index.tsx
0 → 100644
View file @
8f0fc1f4
import
{
Modal
}
from
"antd"
;
const
DeletePromptModal
=
()
=>
{
return
(
<
Modal
>
</
Modal
>
)
}
export
default
DeletePromptModal
;
\ No newline at end of file
src/components/editPromptModal/index.less
0 → 100644
View file @
8f0fc1f4
src/components/editPromptModal/index.tsx
0 → 100644
View file @
8f0fc1f4
import
{
Form
,
Modal
,
Select
}
from
"antd"
;
import
TextArea
from
"antd/lib/input/TextArea"
;
import
{
useState
}
from
"react"
;
import
styles
from
'./index.less'
;
import
{
CloseOutlined
}
from
"@ant-design/icons"
;
interface
IEditPromptModalProps
{
open
:
boolean
;
setOpen
:
(
value
:
boolean
)
=>
void
;
types
:
string
[];
}
const
EditPromptModal
=
(
props
:
IEditPromptModalProps
)
=>
{
const
{
open
,
setOpen
,
types
}
=
props
;
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
handleSavePrompt
=
()
=>
{
};
return
(
<
Modal
open=
{
open
}
centered
confirmLoading=
{
loading
}
wrapClassName=
{
styles
.
modal
}
title=
'编辑提示词语'
okText=
'保存'
onOk=
{
handleSavePrompt
}
onCancel=
{
()
=>
{
setOpen
(
false
);
}
}
width=
{
574
}
>
<
Form
>
<
Form
.
Item
>
<
span
>
类型
</
span
>
<
Select
onChange=
{
(
value
:
string
)
=>
{
console
.
log
(
value
);
}
}
value=
{
'市场营销'
}
>
{
types
.
map
(
item
=>
<
Select
.
Option
value=
{
item
}
key=
{
item
}
>
{
item
}
</
Select
.
Option
>)
}
</
Select
>
</
Form
.
Item
>
<
Form
.
Item
>
<
span
>
提示词语
</
span
>
<
TextArea
autoSize
style=
{
{
height
:
200
}
}
/>
</
Form
.
Item
>
</
Form
>
</
Modal
>
)
}
export
default
EditPromptModal
;
\ No newline at end of file
src/pages/Chat/index.tsx
View file @
8f0fc1f4
...
...
@@ -13,8 +13,8 @@ import {
}
from
'@ant-design/icons'
;
import
classNames
from
'classnames'
;
import
{
history
}
from
'umi'
;
import
LoginModal
from
'@/components/
l
oginModal'
;
import
NewSession
from
'@/components/
n
ewSession'
;
import
LoginModal
from
'@/components/
L
oginModal'
;
import
NewSession
from
'@/components/
N
ewSession'
;
import
{
useWebSocket
,
useRequest
}
from
'ahooks'
;
import
{
GetChatGLMToken
}
from
'@/services/chatGLM/api'
;
import
{
useAccess
}
from
'umi'
;
...
...
@@ -86,8 +86,6 @@ const Chat: React.FC = () => {
messageHistory
.
current
.
push
({
prompt
:
chat
,
answer
:
''
});
}
console
.
log
(
'access'
,
access
);
useEffect
(()
=>
{
if
(
access
?.
token
)
{
setOpen
(
false
);
...
...
src/pages/PromptWord/index.less
0 → 100644
View file @
8f0fc1f4
.table_action {
display: flex;
.table_action_edit {
color: #1890ff;
span {
margin-left: 3px;
}
}
.table_action_delete {
color: #F5222D;
span {
margin-left: 3px;
}
}
}
\ No newline at end of file
src/pages/PromptWord/index.tsx
View file @
8f0fc1f4
import
{
useState
}
from
"react"
;
import
{
DeleteOutlined
,
EditOutlined
,
PlusOutlined
}
from
'@ant-design/icons'
;
import
type
{
ActionType
}
from
'@ant-design/pro-components'
;
import
{
PageContainer
}
from
'@ant-design/pro-components'
;
import
{
ProTable
}
from
'@ant-design/pro-components'
;
import
{
Button
,
Col
,
Divider
,
Form
,
Input
,
Modal
,
Radio
,
Row
,
Switch
,
message
}
from
'antd'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
useEffect
,
useRef
,
useState
}
from
'react'
;
import
styles
from
'./index.less'
;
import
EditPromptModal
from
'@/components/editPromptModal'
;
import
{
pagePromptWords
,
createPromptWords
,
updatePromptWords
,
deletePromptWords
}
from
'@/services/chatGLM/api'
;
const
{
Item
}
=
Form
;
interface
DataType
{
key
:
string
;
sequenceNumber
:
number
;
promptWord
:
string
;
type
:
string
;
creationTime
:
string
;
}
const
data
:
DataType
[]
=
[
{
key
:
'1'
,
sequenceNumber
:
0
,
type
:
'会议记录'
,
promptWord
:
'请根据以下简要说明,为我撰写一份关于新员'
,
creationTime
:
'2023-03-21 09:12:00'
},
{
key
:
'2'
,
sequenceNumber
:
1
,
type
:
'会议记录'
,
promptWord
:
'请根据以下简要说明,为我撰写一份关于新员'
,
creationTime
:
'2023-03-21 09:12:00'
},
{
key
:
'3'
,
sequenceNumber
:
2
,
type
:
'会议记录'
,
promptWord
:
'请根据以下简要说明,为我撰写一份关于新员'
,
creationTime
:
'2023-03-21 09:12:00'
},
];
const
PromptWord
=
()
=>
{
const
actionRef
=
useRef
<
ActionType
>
();
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
editModalOpen
,
setEditModalOpen
]
=
useState
(
false
);
const
[
deleteModalOpen
,
setDeleteModalOpen
]
=
useState
(
false
);
const
[
promptList
,
setPromptList
]
=
useState
([]);
const
[
form
]
=
Form
.
useForm
();
const
columns
:
any
[]
=
[
{
title
:
'序号'
,
width
:
'10%'
,
key
:
'sequenceNumber'
,
dataIndex
:
'sequenceNumber'
,
search
:
false
,
},
{
title
:
'类型'
,
width
:
'15%'
,
key
:
'type'
,
dataIndex
:
'type'
,
search
:
false
,
},
{
title
:
'提示词语'
,
width
:
'50%'
,
key
:
'promptWord'
,
dataIndex
:
'promptWord'
,
ellipsis
:
true
,
search
:
false
,
},
{
title
:
'创建时间'
,
width
:
'10%'
,
key
:
'creationTime'
,
dataIndex
:
'creationTime'
,
valueType
:
'date'
,
search
:
false
,
},
{
title
:
'操作'
,
valueType
:
'option'
,
width
:
'15%'
,
key
:
'option'
,
render
:
(
_
:
unknown
,
record
:
any
)
=>
(
<
div
className=
{
styles
.
table_action
}
>
<
div
className=
{
styles
.
table_action_edit
}
onClick=
{
()
=>
setEditModalOpen
(
true
)
}
>
<
EditOutlined
/>
<
span
>
编辑
</
span
>
</
div
>
<
span
style=
{
{
margin
:
'0 9px'
}
}
>
|
</
span
>
<
div
className=
{
styles
.
table_action_delete
}
>
<
DeleteOutlined
/>
<
span
>
删除
</
span
>
</
div
>
</
div
>
),
},
];
const
fetchPromptList
=
async
()
=>
{
const
data
=
await
createPromptWords
({
})
};
useEffect
(()
=>
{
fetchPromptList
();
},
[]);
const
layout
=
{
labelCol
:
{
span
:
4
},
wrapperCol
:
{
span
:
18
},
};
const
showModal
=
()
=>
{
};
return
(
<>
PromptWord
</>
)
<
PageContainer
>
<
EditPromptModal
open=
{
editModalOpen
}
setOpen=
{
setEditModalOpen
}
types=
{
[
'会议记录'
,
'技术文档'
]
}
/>
<
ProTable
dataSource=
{
data
}
columns=
{
columns
}
actionRef=
{
actionRef
}
cardBordered
rowKey=
"id"
pagination=
{
{
pageSize
:
5
,
onChange
:
(
page
)
=>
{},
}
}
options=
{
false
}
dateFormatter=
"string"
headerTitle=
"账号列表"
toolBarRender=
{
()
=>
[
<
Button
key=
"button"
icon=
{
<
PlusOutlined
/>
}
onClick=
{
()
=>
{
}
}
type=
"primary"
>
添加提示语
</
Button
>,
]
}
/>
</
PageContainer
>
);
};
export
default
PromptWord
;
src/services/chatGLM/api.ts
View file @
8f0fc1f4
...
...
@@ -69,3 +69,30 @@ export const getUserMessage = (params?: any): Promise<string> => {
});
}
export
const
createPromptWords
=
(
params
:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com/PromptWords/create'
,
{
method
:
'POST'
,
data
:
params
})
}
export
const
updatePromptWords
=
(
params
:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com/PromptWords/update'
,
{
method
:
'POST'
,
data
:
params
})
}
export
const
deletePromptWords
=
(
params
:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com/PromptWords/delete'
,
{
method
:
'POST'
,
data
:
params
})
}
export
const
pagePromptWords
=
(
params
:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com/PromptWords/page'
,
{
method
:
'POST'
,
data
:
params
})
}
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