summaryrefslogtreecommitdiff
path: root/py/utils.py
diff options
context:
space:
mode:
authorMartin Bielik <martin.bielik@instea.sk>2024-12-22 14:55:15 +0100
committerMartin Bielik <martin.bielik@instea.sk>2024-12-22 14:55:15 +0100
commitfbc2bfb445c71985e9fc399d3fac2def2fc6854e (patch)
treee93db9bf177d8790c608e3871d9f55d259510855 /py/utils.py
parent4f1c95386437c8fa6e189c136681950a91fb25c9 (diff)
downloadvim-ai-fbc2bfb445c71985e9fc399d3fac2def2fc6854e.tar.gz
added image generation
Diffstat (limited to 'py/utils.py')
-rw-r--r--py/utils.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/py/utils.py b/py/utils.py
index d118326..8cd204f 100644
--- a/py/utils.py
+++ b/py/utils.py
@@ -250,7 +250,7 @@ def openai_request(url, data, options):
)
with urllib.request.urlopen(req, timeout=request_timeout) as response:
- if not data['stream']:
+ if not data.get('stream', 0):
yield json.loads(response.read().decode())
return
for line_bytes in response:
@@ -354,3 +354,8 @@ def read_role_files():
roles = configparser.ConfigParser()
roles.read([default_roles_config_path, roles_config_path])
return roles
+
+def save_b64_to_file(path, b64_data):
+ f = open(path, "wb")
+ f.write(base64.b64decode(b64_data))
+ f.close()