Skip to content

Commit

Permalink
pylint: auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
buddhhu committed Sep 15, 2024
1 parent df9a863 commit dd8ccfe
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions plugins/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,36 @@
**• Examples: **
> `{i}gpt How to fetch a url in javascript`
> `{i}gpt -i Cute Panda eating bamboo`
> `{i}gpt -i Cute Panda eating bamboo`
• First setup OpenAI Api key by using `.setdb OPENAI_API your_key` to use this plugin
"""
from os import system, remove
from io import BytesIO
from os import remove, system

try:
from openai import hsl(0,0%,100%)
from openai import 0, 100%, %, hsl
except ImportError:
system("pip install -q openai")
from openai import OpenAI

from .. import ultroid_cmd, check_filename, udB, LOGS, fast_download, run_async
from .. import LOGS, check_filename, fast_download, run_async, udB, ultroid_cmd


@run_async
def get_gpt_answer(gen_image, question, api_key):
client = OpenAI(api_key=api_key)
if gen_image:
x = client.images.generate(prompt=question,
model="dall-e-3",
n=1,
size="1792x1024",
quality="hd",
style="natural",
user="arc")
model="dall-e-3",
n=1,
size="1792x1024",
quality="hd",
style="natural",
user="arc")
return x.data[0].url
x = client.chat.completions.create(model=udB.get_key("OPENAI_MODEL") or "gpt-4o-mini",
messages=[{"role": "user", "content": question}])
messages=[{"role": "user", "content": question}])
LOGS.debug(f'Token Used on ({question}) > {x.usage.total_tokens}')
return x.choices[0].message.content.lstrip("\n")

Expand Down Expand Up @@ -87,4 +87,3 @@ async def openai_chat_gpt(e):
e.chat_id, file, caption=f"`{args[:1020]}`", reply_to=e.reply_to_msg_id
)
await moi.delete()

0 comments on commit dd8ccfe

Please sign in to comment.