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
3ae8a87d
authored
2023-02-09 11:13:48 +0800
by
RSA
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix
1 parent
1e0ad578
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
10 deletions
client/src/App.js
client/src/App.js
View file @
3ae8a87
...
...
@@ -51,16 +51,16 @@ function App() {
const
userPunctuationRegex
=
new
RegExp
(
`
${
userPunctuation
.
join
(
''
)}
$`
,
'gi'
);
const
punctuationMatches
=
chatInput
.
match
(
userPunctuationRegex
);
//
console.log(punctuationMatches)
console
.
log
(
punctuationMatches
)
var
userModifiedInput
=
chatInput
if
(
!
punctuationMatches
)
{
if
(
!
inputMatches
)
{
userModifiedInput
=
chatInput
+
"."
;
//
console.log("not a question!")
console
.
log
(
"not a question!"
)
}
else
{
userModifiedInput
=
chatInput
+
"?"
;
//
console.log("its a question!")
console
.
log
(
"its a question!"
)
}
}
...
...
@@ -83,24 +83,20 @@ function App() {
});
const
data
=
await
response
.
json
();
const
parsedData
=
data
.
message
.
trim
();
// console.log(parsedData)
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);
console
.
log
(
matches
);
if
(
!
matches
)
{
var
replaceTags
=
(
parsedData
.
replace
(
/
(?:\r\n
|
\r
|
\n)
/g
,
'<br>'
).
replace
(
/
\.
/g
,
'. '
))
//
console.log("not programming!")
console
.
log
(
"not programming!"
)
}
else
{
replaceTags
=
(
parsedData
.
replace
(
':'
,
':<code>'
).
replace
(
'<?'
,
'<?'
).
replace
(
'?>'
,
'?>'
).
replace
(
/
\n
/g
,
'<br>'
))
// console.log("programming!")
//.replace('<?','<' + '?').replace('?>','?'+'>')
console
.
log
(
"programming!"
)
}
setChatLog
([...
chatLogNew
,
{
user
:
"gpt"
,
message
:
`
${
replaceTags
}
`
}
])
// setChatLog([...chatLogNew, { user: "gpt", message: `<div>${parsedData}</div>`} ])
var
scrollToTheBottomChatLog
=
document
.
getElementsByClassName
(
"chat-log"
)[
0
];
scrollToTheBottomChatLog
.
scrollTop
=
scrollToTheBottomChatLog
.
scrollHeight
;
}
...
...
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