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
fd0c65d6
authored
2023-02-14 17:16:09 +0800
by
RSA
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
fix conflict
2 parents
3e569df6
044faa07
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
13 deletions
README.md
client/src/App.css
client/src/App.js
README.md
View file @
fd0c65d
...
...
@@ -10,8 +10,8 @@ Create an .env file in the root directory of your application.
Duplicate the env-template and rename to .env
In the .env file, define the environment variables you want to use in your application. ex.
`API_KEY="sk-xxxxxxxx"`
`API_ORG="org-xxxxxxx"`
`
OPENAI_
API_KEY="sk-xxxxxxxx"`
`
OPENAI_
API_ORG="org-xxxxxxx"`
## Run server
...
...
client/src/App.css
View file @
fd0c65d
...
...
@@ -104,7 +104,7 @@
padding
:
12px
;
padding-left
:
24px
;
padding-right
:
24px
;
}
.avatar
{
background
:
white
;
...
...
@@ -114,7 +114,7 @@
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
padding
:
5px
;
padding
:
1
5px
;
font-size
:
14px
;
color
:
#444654
;
}
...
...
client/src/App.js
View file @
fd0c65d
...
...
@@ -47,8 +47,8 @@ function App() {
const
userInputRegex
=
new
RegExp
(
`\\b(
${
userInput
.
join
(
'|'
)}
)\\b`
,
'gi'
);
const
inputMatches
=
chatInput
.
match
(
userInputRegex
);
const
userPunctuation
=
[
'.'
,
'?'
,
'!'
,
':'
,
';'
,
','
];
const
userPunctuationRegex
=
new
RegExp
(
`
${
userPunctuation
.
join
(
''
)}
$`
,
'gi'
);
const
userPunctuation
=
[
'
\
.'
,
'?'
,
'!'
,
':'
,
';'
,
','
];
const
userPunctuationRegex
=
new
RegExp
(
`
[
${
userPunctuation
.
join
(
''
)}
]$`
);
const
punctuationMatches
=
chatInput
.
match
(
userPunctuationRegex
);
// console.log(punctuationMatches)
...
...
@@ -84,20 +84,14 @@ 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);
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!")
//.replace('<?','<' + '?').replace('?>','?'+'>')
}
setChatLog
([...
chatLogNew
,
{
user
:
"gpt"
,
message
:
`
${
replaceTags
}
`
}
])
...
...
@@ -106,7 +100,6 @@ function App() {
}
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>`
}
])
// res.status(500).send(error || 'Something went wrong');
}
}
...
...
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