FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
chatgpt-wx-miniprogram/index.py at master · feixiangcode/chatgpt-wx-miniprogram · GitHub
feixiangcode
/
chatgpt-wx-miniprogram
Public
Notifications
You must be signed in to change notification settings
Fork
2
Star
14
Code
Issues
1
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
chatgpt-wx-miniprogram
/
index.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (31 loc) · 1015 Bytes
Breadcrumbs
chatgpt-wx-miniprogram
/
index.py
Copy path
File metadata and controls
35 lines (31 loc) · 1015 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from
flask
import
Flask
,
request
import
requests
import
json
import
random
import
openai
import
os
app
=
Flask
(
__name__
)
@
app
.
route
(
'/'
)
def
hello_world
():
return
'在此输入apikey 样式:sk-s5S5BoV...'
@
app
.
route
(
'/message'
,
methods
=
[
'POST'
])
def
mess
():
# put application's code here
message
=
request
.
json
.
get
(
'msg'
)
openai
.
api_key
=
"key"
#修改这里为自己申请的api_key
messages
=
[
{
"role"
:
"system"
,
"content"
:
"You are a coding tutor bot to help user write and optimize python code."
},
]
messages
.
append
({
"role"
:
"user"
,
"content"
:
message
})
completion
=
openai
.
ChatCompletion
.
create
(
model
=
"gpt-3.5-turbo"
,
messages
=
[{
"role"
:
"user"
,
"content"
:
message
}]
)
print
(
completion
)
#messages.append({"role": "assistant", "content": response["choices"][0]["message"].content})
res
=
{
"resmsg"
:
completion
,
"code"
:
200
}
return
res
if
__name__
==
'__main__'
:
app
.
run
(
threaded
=
False
,
processes
=
5
)
Back
|
FazBrowse Home
|
New Git URL