фото исправить брат
This commit is contained in:
1 parent
a2c92651ce
commit
c961086f9e
1 file changed
+5
-2
+5
-2
@@ -4,6 +4,7 @@ import shelve
|
|||||||
import time
|
import time
|
||||||
import ai
|
import ai
|
||||||
import json
|
import json
|
||||||
|
import traceback
|
||||||
|
|
||||||
from configparser import DEFAULTSECT
|
from configparser import DEFAULTSECT
|
||||||
|
|
||||||
@@ -106,11 +107,11 @@ async def generate(
|
|||||||
if images:
|
if images:
|
||||||
if settings.get("vision"):
|
if settings.get("vision"):
|
||||||
for image in images:
|
for image in images:
|
||||||
content += [{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image}"}}]
|
content += [{"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image['data']}"}}]
|
||||||
else:
|
else:
|
||||||
for image in images:
|
for image in images:
|
||||||
try:
|
try:
|
||||||
image_text = await image2text(image)
|
image_text = await image2text(image["data"])
|
||||||
prompt = f"<фото>{image_text}</фото>\n{prompt}"
|
prompt = f"<фото>{image_text}</фото>\n{prompt}"
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"{RED} -- err photo - {e} : {model}{RESET}")
|
print(f"{RED} -- err photo - {e} : {model}{RESET}")
|
||||||
@@ -291,10 +292,12 @@ async def openai_generate_text(
|
|||||||
else:
|
else:
|
||||||
async for completion in ai.completions(**alo):
|
async for completion in ai.completions(**alo):
|
||||||
pass
|
pass
|
||||||
|
print(completion)
|
||||||
text = completion["choices"][0]["message"]["content"]
|
text = completion["choices"][0]["message"]["content"]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error = parse_response(str(e).lower())
|
error = parse_response(str(e).lower())
|
||||||
print(f"{RED} -- {error['type']} - {e}{RESET}")
|
print(f"{RED} -- {error['type']} - {e}{RESET}")
|
||||||
|
traceback.print_exc()
|
||||||
return error["message"]
|
return error["message"]
|
||||||
else:
|
else:
|
||||||
text, s = clean_tail_repeats(text)
|
text, s = clean_tail_repeats(text)
|
||||||
|
|||||||
Reference in new issue
Block a user