use pillow
This commit is contained in:
parent
3008ecb2a9
commit
c83fe2f92a
7
azure.py
7
azure.py
@ -14,7 +14,7 @@ from azure.ai.inference.aio import ChatCompletionsClient
|
|||||||
from azure.ai.inference.models import SystemMessage, UserMessage, TextContentItem, ImageContentItem, ImageUrl
|
from azure.ai.inference.models import SystemMessage, UserMessage, TextContentItem, ImageContentItem, ImageUrl
|
||||||
from azure.core.credentials import AzureKeyCredential
|
from azure.core.credentials import AzureKeyCredential
|
||||||
from .__init__ import __plugin_meta__
|
from .__init__ import __plugin_meta__
|
||||||
import imghdr
|
from PIL import Image
|
||||||
from .config import config
|
from .config import config
|
||||||
changemdl = on_command("changemodel",permission=SUPERUSER)
|
changemdl = on_command("changemodel",permission=SUPERUSER)
|
||||||
resetmem = on_command("reset",permission=SUPERUSER)
|
resetmem = on_command("reset",permission=SUPERUSER)
|
||||||
@ -102,7 +102,7 @@ async def neko(
|
|||||||
await download_file(str(imgurl))
|
await download_file(str(imgurl))
|
||||||
picmsg = ImageContentItem(image_url=ImageUrl.load(
|
picmsg = ImageContentItem(image_url=ImageUrl.load(
|
||||||
image_file="./azureaipic.png",
|
image_file="./azureaipic.png",
|
||||||
image_format=imghdr.what("azureaipic.png")
|
image_format=Image.open("azureaipic.png").format
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
usermsg.append(picmsg)
|
usermsg.append(picmsg)
|
||||||
@ -114,12 +114,13 @@ async def neko(
|
|||||||
messages=context+[UserMessage(content=usermsg)],
|
messages=context+[UserMessage(content=usermsg)],
|
||||||
model=model_name
|
model=model_name
|
||||||
)
|
)
|
||||||
#await UniMessage(str(response)).send()
|
#await UniMessage(str(response)).send()
|
||||||
choice = response.choices[0]
|
choice = response.choices[0]
|
||||||
if choice["finish_reason"] == "stop":
|
if choice["finish_reason"] == "stop":
|
||||||
context.append(UserMessage(content=usermsg))
|
context.append(UserMessage(content=usermsg))
|
||||||
context.append(choice.message)
|
context.append(choice.message)
|
||||||
context_count += 1
|
context_count += 1
|
||||||
|
#await UniMessage(str(choice)).send()
|
||||||
await UniMessage(str(choice.message.content)).send(reply_to=True)
|
await UniMessage(str(choice.message.content)).send(reply_to=True)
|
||||||
#requests_limit = response.headers.get('x-ratelimit-limit-requests')
|
#requests_limit = response.headers.get('x-ratelimit-limit-requests')
|
||||||
#request_id = response.headers.get('x-request-id')
|
#request_id = response.headers.get('x-request-id')
|
||||||
|
Reference in New Issue
Block a user