31 lines
796 B
Python
31 lines
796 B
Python
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 |