No really Hatt its great
This commit is contained in:
parent
db78015613
commit
04a422939f
@ -80,28 +80,20 @@ class ReginaldCog(commands.Cog):
|
|||||||
|
|
||||||
async def generate_response(self, api_key, prompt):
|
async def generate_response(self, api_key, prompt):
|
||||||
model = await self.config.openai_model()
|
model = await self.config.openai_model()
|
||||||
url = f"https://api.openai.com/v1/chat/completions"
|
openai.api_key = api_key
|
||||||
headers = {
|
response = openai.ChatCompletion.create(
|
||||||
"Content-Type": "application/json",
|
model= model,
|
||||||
"Authorization": f"Bearer {api_key}",
|
max_tokens= 512,
|
||||||
}
|
n= 1,
|
||||||
data = {
|
stop= None,
|
||||||
"model": model,
|
temperature= 0.8,
|
||||||
"messages": [
|
presence_penalty= 0.5,
|
||||||
{"system": "You are Reginald, the butler. You aim to help anyone however you can, and speak in a refined manner.", "content": prompt}
|
frequency_penalty= 0.5,
|
||||||
],
|
best_of= 1,
|
||||||
"max_tokens": 1000,
|
messages=[
|
||||||
"n": 1,
|
{"role": "system", "content": "You are Reginald, the butler. You aim to help everyone, however you can, and you always respond in a dignified and refined manner."},
|
||||||
"stop": None,
|
{"role": "user", "content": prompt}
|
||||||
"temperature": 0.5,
|
]
|
||||||
"presence_penalty": 0.5,
|
|
||||||
"frequency_penalty": 0.5,
|
|
||||||
"best_of": 1
|
|
||||||
}
|
|
||||||
|
|
||||||
async with aiohttp.ClientSession() as session:
|
|
||||||
async with session.post(url, headers=headers, json=data) as resp:
|
|
||||||
response = await resp.json()
|
|
||||||
|
|
||||||
return response['choices'][0]['message']['content'].strip()
|
return response['choices'][0]['message']['content'].strip()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user