Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Administrator
/
chatgpt.ai-pro.org
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
3
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
55cd85e1
authored
2023-02-10 10:46:11 +0800
by
RSA
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
fix conflict
2 parents
dc3576bd
37b3831b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
30 deletions
client/src/App.js
client/src/color_theme_1.css
client/src/App.js
View file @
55cd85e
...
...
@@ -42,7 +42,6 @@ function App() {
async
function
handleSubmit
(
e
){
e
.
preventDefault
();
console
.
log
(
chatInput
)
const
userInput
=
[
'what'
,
'why'
,
'when'
,
'where'
,
'which'
,
'did'
,
'do'
,
'how'
,
'can'
,
'are'
,
'who'
,
'hey'
];
const
userInputRegex
=
new
RegExp
(
`\\b(
${
userInput
.
join
(
'|'
)}
)\\b`
,
'gi'
);
const
inputMatches
=
chatInput
.
match
(
userInputRegex
);
...
...
@@ -51,16 +50,13 @@ function App() {
const
userPunctuationRegex
=
new
RegExp
(
`[
${
userPunctuation
.
join
(
''
)}
]$`
);
const
punctuationMatches
=
chatInput
.
match
(
userPunctuationRegex
);
console
.
log
(
punctuationMatches
)
var
userModifiedInput
=
chatInput
if
(
!
punctuationMatches
)
{
if
(
!
inputMatches
)
{
userModifiedInput
=
chatInput
+
"."
;
console
.
log
(
"not a question!"
)
}
else
{
userModifiedInput
=
chatInput
+
"?"
;
console
.
log
(
"its a question!"
)
}
}
...
...
@@ -71,34 +67,36 @@ function App() {
// fetch response to the api combining the chat log array of messages and seinding it as a message to localhost:3000 as a post
const
messages
=
chatLogNew
.
map
((
message
)
=>
message
.
message
).
join
(
"\n"
)
const
response
=
await
fetch
(
process
.
env
.
REACT_APP_SERVER_URL
+
"/api"
,
{
method
:
"POST"
,
headers
:
{
"Content-Type"
:
"application/json"
},
body
:
JSON
.
stringify
({
message
:
messages
,
currentModel
,
})
try
{
const
response
=
await
fetch
(
process
.
env
.
REACT_APP_SERVER_URL
+
"/api"
,
{
method
:
"POST"
,
headers
:
{
"Content-Type"
:
"application/json"
},
body
:
JSON
.
stringify
({
message
:
messages
,
currentModel
,
})
});
const
data
=
await
response
.
json
();
const
parsedData
=
data
.
message
.
trim
();
const
programmingKeywords
=
[
'code'
,
'application'
,
'controller'
,
'rails'
,
'PHP'
,
'java'
,
'javascript'
,
'script'
,
'console'
,
'python'
,
'programming'
,
'table'
];
const
regex
=
new
RegExp
(
`\\b(
${
programmingKeywords
.
join
(
'|'
)}
)\\b`
,
'gi'
);
// console.log(regex)
const
matches
=
parsedData
.
match
(
regex
);
console
.
log
(
matches
);
if
(
!
matches
)
{
var
replaceTags
=
(
parsedData
.
replace
(
/
(?:\r\n
|
\r
|
\n)
/g
,
'<br>'
).
replace
(
/
\.
/g
,
'. '
))
console
.
log
(
"not programming!"
)
}
else
{
replaceTags
=
(
parsedData
.
replace
(
':'
,
':<code>'
).
replace
(
'<?'
,
'<?'
).
replace
(
'?>'
,
'?>'
).
replace
(
/
\n
/g
,
'<br>'
))
console
.
log
(
"programming!"
)
const
data
=
await
response
.
json
();
const
parsedData
=
data
.
message
.
trim
();
const
programmingKeywords
=
[
'code'
,
'application'
,
'controller'
,
'rails'
,
'PHP'
,
'java'
,
'javascript'
,
'script'
,
'console'
,
'python'
,
'programming'
,
'table'
];
const
regex
=
new
RegExp
(
`\\b(
${
programmingKeywords
.
join
(
'|'
)}
)\\b`
,
'gi'
);
const
matches
=
parsedData
.
match
(
regex
);
if
(
!
matches
)
{
var
replaceTags
=
(
parsedData
.
replace
(
/
(?:\r\n
|
\r
|
\n)
/g
,
'<br>'
).
replace
(
/
\.
/g
,
'. '
))
}
else
{
replaceTags
=
(
parsedData
.
replace
(
':'
,
':<code>'
).
replace
(
'<?'
,
'<?'
).
replace
(
'?>'
,
'?>'
).
replace
(
/
\n
/g
,
'<br>'
))
}
setChatLog
([...
chatLogNew
,
{
user
:
"gpt"
,
message
:
`
${
replaceTags
}
`
}
])
var
scrollToTheBottomChatLog
=
document
.
getElementsByClassName
(
"chat-log"
)[
0
];
scrollToTheBottomChatLog
.
scrollTop
=
scrollToTheBottomChatLog
.
scrollHeight
;
}
catch
(
error
)
{
const
errorMsg
=
"We apologize for any inconvenience caused due to the delay in the response time. Please try again."
;
setChatLog
([...
chatLogNew
,
{
user
:
"gpt"
,
message
:
`<div class="errormsg"><span>i</span><div class="msg">
${
errorMsg
}
</div></div>`
}
])
}
setChatLog
([...
chatLogNew
,
{
user
:
"gpt"
,
message
:
`
${
replaceTags
}
`
}
])
var
scrollToTheBottomChatLog
=
document
.
getElementsByClassName
(
"chat-log"
)[
0
];
scrollToTheBottomChatLog
.
scrollTop
=
scrollToTheBottomChatLog
.
scrollHeight
;
}
function
handleTemp
(
temp
)
{
...
...
client/src/color_theme_1.css
View file @
55cd85e
...
...
@@ -2,6 +2,33 @@
background-color
:
#101827
!important
;
}
.errormsg
{
border
:
1px
solid
#7ac5ff
;
padding
:
15px
25px
;
border-radius
:
10px
;
background
:
rgb
(
0
139
245
/
6%
);
}
.errormsg
.msg
{
display
:
inline-block
;
width
:
90%
;
font-weight
:
600
;
}
.errormsg
span
{
background
:
#008BF5
;
padding
:
1px
11px
;
border-radius
:
50px
;
width
:
25px
;
height
:
25px
;
margin-right
:
10px
;
color
:
#fff
;
font-weight
:
900
;
display
:
inline-block
;
vertical-align
:
top
;
font-family
:
auto
;
font-size
:
15px
;
}
.side-menu-button
{
border
:
0
solid
white
;
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#cedbe9+0,aac5de+17,6199c7+50,3a84c3+51,419ad6+59,4bb8f0+71,3a8bc2+84,26558b+100;Blue+Gloss */
...
...
@@ -175,6 +202,10 @@ code br:nth-child(-n+2) {
.message
{
font-size
:
14px
;
}
.errormsg
{
padding
:
10px
;
width
:
80%
;
}
.chat-message-center
{
padding
:
20px
5vw
!important
;
}
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
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 post a comment