change gpt4 to use gpt-4o, cuts costs in half
This commit is contained in:
parent
65e43dacad
commit
ebedb0962d
2 changed files with 6 additions and 5 deletions
|
|
@ -54,7 +54,8 @@ class ChatGPT(commands.Cog):
|
||||||
def text_cost_calc(self, model, input_tokens, output_tokens):
|
def text_cost_calc(self, model, input_tokens, output_tokens):
|
||||||
cost_table = {"gpt-3.5-turbo":{"input_tokens":0.0000005,"output_tokens":0.0000015},
|
cost_table = {"gpt-3.5-turbo":{"input_tokens":0.0000005,"output_tokens":0.0000015},
|
||||||
"gpt-4-turbo-preview":{"input_tokens":0.00001,"output_tokens":0.00003},
|
"gpt-4-turbo-preview":{"input_tokens":0.00001,"output_tokens":0.00003},
|
||||||
"gpt-4-vision-preview":{"input_tokens":0.00001,"output_tokens":0.00003}
|
"gpt-4-vision-preview":{"input_tokens":0.00001,"output_tokens":0.00003},
|
||||||
|
"gpt-4o":{"input_tokens":0.000005,"output_tokens":0.000015}
|
||||||
}
|
}
|
||||||
input_cost = cost_table[model]["input_tokens"] * input_tokens
|
input_cost = cost_table[model]["input_tokens"] * input_tokens
|
||||||
output_cost = cost_table[model]["output_tokens"] * output_tokens
|
output_cost = cost_table[model]["output_tokens"] * output_tokens
|
||||||
|
|
@ -410,7 +411,7 @@ class ChatGPT(commands.Cog):
|
||||||
async def question_gpt4(self, ctx):
|
async def question_gpt4(self, ctx):
|
||||||
await ctx.send("One moment, let me think...")
|
await ctx.send("One moment, let me think...")
|
||||||
question = ctx.message.content.split(" ", maxsplit=1)[1]
|
question = ctx.message.content.split(" ", maxsplit=1)[1]
|
||||||
answer = await self.answer_question(question, "gpt-4-turbo-preview")
|
answer = await self.answer_question(question, "gpt-4o")
|
||||||
chunks = [answer[i:i+1999] for i in range(0, len(answer), 1999)]
|
chunks = [answer[i:i+1999] for i in range(0, len(answer), 1999)]
|
||||||
for chunk in chunks:
|
for chunk in chunks:
|
||||||
await ctx.send(chunk)
|
await ctx.send(chunk)
|
||||||
|
|
@ -568,7 +569,7 @@ class ChatGPT(commands.Cog):
|
||||||
question = ctx.message.content.split(" ", maxsplit=2)[2]
|
question = ctx.message.content.split(" ", maxsplit=2)[2]
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"model": "gpt-4-vision-preview",
|
"model": "gpt-4o",
|
||||||
"messages": [{"role": "user", "content": [{"type": "text", "text": question},{"type": "image_url","image_url": {"url": image_link}}]}],
|
"messages": [{"role": "user", "content": [{"type": "text", "text": question},{"type": "image_url","image_url": {"url": image_link}}]}],
|
||||||
"max_tokens": 500
|
"max_tokens": 500
|
||||||
}
|
}
|
||||||
|
|
@ -702,7 +703,7 @@ class ChatGPT(commands.Cog):
|
||||||
if self.dalle_budget <= await self.get_monthly_cost():
|
if self.dalle_budget <= await self.get_monthly_cost():
|
||||||
self.logger.info("View_image failed due to budget")
|
self.logger.info("View_image failed due to budget")
|
||||||
return (1337, "View_image API call failed due to budget. Consider using !donate to fund the bot.")
|
return (1337, "View_image API call failed due to budget. Consider using !donate to fund the bot.")
|
||||||
model = "gpt-4-vision-preview"
|
model = "gpt-4o"
|
||||||
data = {
|
data = {
|
||||||
"model": model,
|
"model": model,
|
||||||
"messages": [{"role": "user", "content": [{"type": "text", "text": "Describe this"},{"type": "image_url","image_url": {"url": image_link}}]}],
|
"messages": [{"role": "user", "content": [{"type": "text", "text": "Describe this"},{"type": "image_url","image_url": {"url": image_link}}]}],
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ class PhixxyCom(commands.Cog):
|
||||||
title_prompt = 'generate an absurd essay title about ' + topic
|
title_prompt = 'generate an absurd essay title about ' + topic
|
||||||
title = await self.answer_question(title_prompt, model="gpt-3.5-turbo")
|
title = await self.answer_question(title_prompt, model="gpt-3.5-turbo")
|
||||||
prompt = 'Write a satirical essay with a serious tone titled: "' + title + '". Do not label parts of the essay.'
|
prompt = 'Write a satirical essay with a serious tone titled: "' + title + '". Do not label parts of the essay.'
|
||||||
content = await self.answer_question(prompt, model="gpt-4-turbo-preview")
|
content = await self.answer_question(prompt, model="gpt-4o")
|
||||||
if title in content[:len(title)]:
|
if title in content[:len(title)]:
|
||||||
content = content.replace(title, '', 1)
|
content = content.replace(title, '', 1)
|
||||||
with open(filepath, 'w') as f:
|
with open(filepath, 'w') as f:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue