0.0.3
GeneralApp add
This commit is contained in:
31
BaseModels/openAI/openAI_funcs.py
Normal file
31
BaseModels/openAI/openAI_funcs.py
Normal file
@@ -0,0 +1,31 @@
|
||||
import requests
|
||||
def send_request(msg):
|
||||
# url = 'https://api.openai.com/v1/chat/completions'
|
||||
# headers = {
|
||||
# 'Content-Type': 'application/json',
|
||||
# 'Authorization': 'Bearer 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'
|
||||
# }
|
||||
# data = {
|
||||
# "model": "gpt-3.5-turbo",
|
||||
# "messages": [{
|
||||
# "role": "user",
|
||||
# "content": msg
|
||||
# }]
|
||||
# }
|
||||
# res = requests.post(url=url, headers=headers, data=data)
|
||||
|
||||
import os
|
||||
import openai
|
||||
openai.api_key = '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'
|
||||
|
||||
res = openai.ChatCompletion.create(
|
||||
model="gpt-3.5-turbo",
|
||||
messages=[
|
||||
{
|
||||
"role": "user",
|
||||
"content": msg
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
return res
|
||||
Reference in New Issue
Block a user