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
e845bb19
Commit
e845bb19
authored
Apr 15, 2023
by
Ylg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put the modal component on the chat page
parent
1020b88c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
76 additions
and
29 deletions
+76
-29
index.less
src/components/loginModal/index.less
+0
-4
index.tsx
src/components/loginModal/index.tsx
+3
-0
index.tsx
src/pages/Chat/index.tsx
+31
-7
index.tsx
src/pages/PromptWord/index.tsx
+0
-10
api.ts
src/services/chatGLM/api.ts
+42
-8
No files found.
src/components/loginModal/index.less
View file @
e845bb19
...
...
@@ -62,10 +62,6 @@
}
}
:global(.ant-checkbox-inner) {
background-color: #009b95;
}
.modal_button {
width: 100%;
height: 44px;
...
...
src/components/loginModal/index.tsx
View file @
e845bb19
...
...
@@ -36,6 +36,8 @@ const LoginModal = (props: ILoginModalProps) => {
password
,
});
localStorage
.
setItem
(
'user'
,
JSON
.
stringify
(
result
||
{}));
console
.
log
(
'result'
,
result
);
setLoading
(
false
);
}
catch
(
error
)
{
...
...
@@ -60,6 +62,7 @@ const LoginModal = (props: ILoginModalProps) => {
height
:
'496px'
,
}
}
centered
maskClosable=
{
true
}
>
<
div
className=
{
styles
.
modal_login
}
>
<
div
className=
{
styles
.
modal_title
}
>
...
...
src/pages/Chat/index.tsx
View file @
e845bb19
/* eslint-disable @typescript-eslint/no-unused-expressions */
import
{
Layout
,
Form
,
Button
}
from
'antd'
;
import
React
,
{
useState
}
from
'react'
;
import
{
Layout
,
Form
,
Button
,
message
}
from
'antd'
;
import
React
,
{
use
Effect
,
use
State
}
from
'react'
;
import
styles
from
'./index.less'
;
import
ChatFirstContent
from
'./components/content'
;
import
ChatHeader
from
'./components/header'
;
...
...
@@ -13,6 +13,7 @@ import {
WechatOutlined
,
}
from
'@ant-design/icons'
;
import
classNames
from
'classnames'
;
import
LoginModal
from
"@/components/loginModal"
;
const
{
Sider
}
=
Layout
;
const
{
Item
}
=
Form
;
...
...
@@ -25,22 +26,37 @@ const Chat: React.FC = () => {
const
[
form
]
=
Form
.
useForm
();
const
[
selectSiderTabs
,
setSelectSiderTabs
]
=
useState
(
''
);
const
[
open
,
setOpen
]
=
useState
(
false
);
useEffect
(()
=>
{
let
token
=
''
;
if
(
localStorage
.
getItem
(
'user'
))
{
token
=
JSON
.
parse
(
localStorage
.
user
)?.
token
;
}
if
(
token
)
{
setOpen
(
false
);
}
else
{
setOpen
(
true
);
}
},
[]);
const
onSend
=
(
value
:
any
)
=>
{
console
.
log
(
value
);
form
.
setFieldValue
(
'chatInput'
,
''
);
setFirstChat
(
true
);
};
const
onChange
=
(
value
:
any
)
=>
{
value
?.
chatInput
&&
SetChat
(
value
?.
chatInput
);
value
?.
firstInput
&&
setInput
(
value
);
};
const
setInput
=
(
value
:
any
)
=>
{
form
.
setFieldValue
(
'chatInput'
,
value
?.
firstInput
);
setFirstChat
(
true
);
};
const
onChange
=
(
value
:
any
)
=>
{
value
?.
chatInput
&&
SetChat
(
value
?.
chatInput
);
value
?.
firstInput
&&
setInput
(
value
);
};
const
siderTabsList
=
[
{
icons
:
<
DeleteOutlined
/>,
...
...
@@ -70,6 +86,10 @@ const Chat: React.FC = () => {
return
(
<
Layout
>
<
LoginModal
open=
{
open
}
setOpen=
{
setOpen
}
/>
<
Sider
className=
{
styles
.
sider
}
>
<
div
className=
{
styles
.
siderChatContent
}
>
<
Button
size=
"large"
block
type=
"primary"
icon=
{
<
PlusOutlined
/>
}
>
...
...
@@ -132,3 +152,7 @@ const Chat: React.FC = () => {
};
export
default
Chat
;
function
async
()
{
throw
new
Error
(
'Function not implemented.'
);
}
src/pages/PromptWord/index.tsx
View file @
e845bb19
import
LoginModal
from
"@/components/loginModal"
;
import
{
Button
}
from
"antd"
;
import
{
useState
}
from
"react"
;
const
PromptWord
=
()
=>
{
const
[
open
,
setOpen
]
=
useState
(
false
);
return
(
<>
PromptWord
<
Button
onClick=
{
()
=>
setOpen
(
true
)
}
/>
<
LoginModal
open=
{
open
}
setOpen=
{
setOpen
}
/>
</>
)
...
...
src/services/chatGLM/api.ts
View file @
e845bb19
import
{
request
}
from
'umi
'
;
import
request
from
'umi-request
'
;
interface
LoginParams
{
interface
I
LoginParams
{
name
:
string
;
password
:
string
;
}
export
function
loginChatGLM
(
options
:
LoginParams
)
{
request
.
interceptors
.
request
.
use
((
url
,
options
)
=>
{
let
{
token
}
=
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)
||
''
);
if
(
null
===
token
)
{
token
=
''
;
}
const
authHeader
=
{
Authorization
:
`Bearer
${
token
}
`
,
'Content-Type'
:
'application/json'
,
'__tenant'
:
'3a0a90fe-9a0d-70f4-200d-a80a41fb6195'
// 用户id
};
return
{
url
:
url
,
options
:
{
...
options
,
interceptors
:
true
,
headers
:
authHeader
},
};
});
export
function
loginChatGLM
(
options
:
ILoginParams
)
{
return
request
(
'https://glm-mangement-api.baibaomen.com/api/app/account/login'
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
,
'__tenant'
:
'3a0a90fe-9a0d-70f4-200d-a80a41fb6195'
},
data
:
options
})
}
\ No newline at end of file
}
type
History
=
[
string
,
string
];
interface
ITalkParams
{
prompt
:
string
;
history
:
History
[];
max_length
?:
number
;
top_p
?:
number
;
temperature
?:
number
;
}
// export function talkChatGLM({ prompt, history, max_length = 2000, top_p = 0.9, temperature = 0.8 }: ITalkParams) {
// return request('https://glm-mangement-api.baibaomen.com/', {
// method: 'POST',
// data: {
// prompt,
// history,
// max_length,
// top_p,
// temperature
// }
// })
// }
\ No newline at end of file
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