autonomous-app 0.2.17__py3-none-any.whl → 0.2.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
autonomous/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = "0.2.17"
1
+ __version__ = "0.2.18"
2
2
 
3
3
  from .logger import log
4
4
  from .model.automodel import AutoModel
autonomous/ai/oaiagent.py CHANGED
@@ -194,7 +194,7 @@ class OAIAgent(AutoModel):
194
194
  },
195
195
  {"role": "user", "content": text},
196
196
  ]
197
- response = self.client.chat.completions.create(model="gpt-4", messages=message)
197
+ response = self.client.chat.completions.create(model="gpt-4o", messages=message)
198
198
  try:
199
199
  result = response.choices[0].message.content
200
200
  except Exception as e:
@@ -3,7 +3,7 @@ import os
3
3
  import shutil
4
4
  import uuid
5
5
 
6
- from PIL import Image
6
+ from PIL import Image, UnidentifiedImageError
7
7
 
8
8
  from autonomous import log
9
9
 
@@ -24,13 +24,17 @@ class ImageStorage:
24
24
  def _resize_image(self, asset_id, max_size=1024):
25
25
  # log("Resizing image", asset_id, max_size)
26
26
  file_path = f"{self.get_path(asset_id)}/orig.webp"
27
- with Image.open(file_path) as img:
28
- resized_img = img.copy()
29
- max_size = self._sizes.get(max_size) or int(max_size)
30
- resized_img.thumbnail((max_size, max_size))
31
- img_byte_arr = io.BytesIO()
32
- resized_img.save(img_byte_arr, format="WEBP")
33
- return img_byte_arr.getvalue()
27
+ try:
28
+ with Image.open(file_path) as img:
29
+ resized_img = img.copy()
30
+ max_size = self._sizes.get(max_size) or int(max_size)
31
+ resized_img.thumbnail((max_size, max_size))
32
+ img_byte_arr = io.BytesIO()
33
+ resized_img.save(img_byte_arr, format="WEBP")
34
+ return img_byte_arr.getvalue()
35
+ except UnidentifiedImageError as e:
36
+ log(f"Error resizing image: {e}")
37
+ return None
34
38
 
35
39
  def _convert_image(self, raw, crop=False):
36
40
  with Image.open(io.BytesIO(raw)) as img:
@@ -66,25 +70,40 @@ class ImageStorage:
66
70
  original_path = f"{self.get_path(asset_id)}"
67
71
  # log(f"Getting image: {asset_id}.{size}", original_path)
68
72
  if not os.path.exists(original_path):
69
- # log(f"Original image not found: {original_path}")
73
+ log(f"Original image not found: {original_path}")
70
74
  return ""
71
75
  file_path = f"{original_path}/{size}.webp"
72
76
  # log(file_path)
77
+ result_url = f"/{file_path}"
78
+ # log(
79
+ # f"{asset_id}",
80
+ # size,
81
+ # os.path.exists(original_path),
82
+ # os.path.exists(file_path),
83
+ # )
73
84
  if (
74
85
  size != "orig"
75
86
  and os.path.exists(original_path)
76
87
  and not os.path.exists(file_path)
77
88
  ):
78
89
  # If the file doesn't exist, create it
79
- result = self._resize_image(asset_id, size)
80
- with open(file_path, "wb") as asset:
81
- asset.write(result)
82
- result_url = (
83
- f"/{file_path}"
84
- if not full_url
85
- else f"{os.environ.get('APP_BASE_URL', '')}/{file_path}"
86
- )
87
- # log(f"Returning image url: {result_url}")
90
+ if result := self._resize_image(asset_id, size):
91
+ with open(file_path, "wb") as asset:
92
+ asset.write(result)
93
+ result_url = (
94
+ f"/{file_path}"
95
+ if not full_url
96
+ else f"{os.environ.get('APP_BASE_URL', '')}/{file_path}"
97
+ )
98
+ else:
99
+ log(
100
+ f"Error resizing image: {asset_id}",
101
+ size,
102
+ os.path.exists(original_path),
103
+ os.path.exists(file_path),
104
+ )
105
+ self.remove(asset_id)
106
+ # log(f"Returning image: {result_url}")
88
107
  return result_url
89
108
 
90
109
  def get_path(self, asset_id):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: autonomous-app
3
- Version: 0.2.17
3
+ Version: 0.2.18
4
4
  Summary: Containerized application framework built on Flask with additional libraries and tools for rapid development of web applications.
5
5
  Author-email: Steven A Moore <samoore@binghamton.edu>
6
6
  License: MIT License
@@ -1,8 +1,8 @@
1
- autonomous/__init__.py,sha256=ZlVHlQd6mQ5oZiv98AWlh3CaYpftWM29G0dnvPzJkWA,87
1
+ autonomous/__init__.py,sha256=k6591xprvdGn8dyTo1ckGzxECbwYVk2QFo68FshoZBA,87
2
2
  autonomous/cli.py,sha256=z4AaGeWNW_uBLFAHng0J_lfS9v3fXemK1PeT85u4Eo4,42
3
3
  autonomous/logger.py,sha256=hDX3gvbcWiGPvA8pfarih3xHS4aHG_NuNkF8PQfq_pM,1844
4
4
  autonomous/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- autonomous/ai/oaiagent.py,sha256=T2cUbDdyTZCjr0B9Apr_O_nZWJp4yHcYLv94QAbH4yY,7196
5
+ autonomous/ai/oaiagent.py,sha256=jOfAK6FIJN2n8CKrcrAcL8t1Jh5bgxk4bnBt0NwTXBE,7197
6
6
  autonomous/auth/__init__.py,sha256=IW5tQ8VYwHIbDfMYA0wYgx4PprwcjUWV4EoIJ8HTlMU,161
7
7
  autonomous/auth/autoauth.py,sha256=Q2DfcWjh0vTSSpf5SqyK4SElVDcxu8435GhLSPqTYco,3724
8
8
  autonomous/auth/github.py,sha256=dHf84bJdV9rXGcvRLzWCPW9CvuA-VEmqYi_QQFwd2kY,886
@@ -19,7 +19,7 @@ autonomous/model/automodel.py,sha256=Z8iDZB7frSV_lQ09HL-l0ff0_ePEuPwjLzWnpbdCsJw
19
19
  autonomous/model/orm.py,sha256=IJrbp15RmBgF61vLsqcS_VdnAnw9736sLW75_xFYE9Y,2521
20
20
  autonomous/model/serializer.py,sha256=0nfmw4-QNP-ozL4IVbgQyfPRF2i0-uG9pQZwgEPYuxU,3026
21
21
  autonomous/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- autonomous/storage/imagestorage.py,sha256=WOBvnpW3VhvliT2pXtaD_Msh1XEAVxqEBELblsvfdtA,3970
22
+ autonomous/storage/imagestorage.py,sha256=RlZ6F4s7FGpcyzJq8IstN-CDhhSigEQjJL5L7OVCxUM,4671
23
23
  autonomous/storage/localstorage.py,sha256=FzrR6O9mMGAZt5dDgqzkeOQVfGRXCygR0kksz2MPpwE,2286
24
24
  autonomous/storage/markdown.py,sha256=tf8vlHARiQO1X_aGbqlYozzP_TbdiDRT9EEP6aFRQo0,2153
25
25
  autonomous/storage/version_control/GHCallbacks.py,sha256=AyiUlYfV5JePi11GVyqYyXoj5UTbPKzS-HRRI94rjJo,1069
@@ -29,8 +29,8 @@ autonomous/storage/version_control/GHVersionControl.py,sha256=VIhVRxe6gJgozFWyhy
29
29
  autonomous/storage/version_control/__init__.py,sha256=tP0bAWYl1RwBRi62HsIidmgyqHuSlCUqwGuKUKKRugc,117
30
30
  autonomous/tasks/__init__.py,sha256=pn7iZ14MhcHUdzcLkfkd4-45wgPP0tXahAz_cFgb_Tg,32
31
31
  autonomous/tasks/autotask.py,sha256=_WQ8w1LyV2FVJ0Ct0FoF9q1W8ClXfS57-omnBb0LNWE,4910
32
- autonomous_app-0.2.17.dist-info/LICENSE,sha256=-PHHSuDRkodHo3PEdMkDtoIdmLAOomMq6lsLaOetU8g,1076
33
- autonomous_app-0.2.17.dist-info/METADATA,sha256=3lmrmZ2854E5DBMmbfEAhDLLMxw_iKGQq22Z24sStCo,4229
34
- autonomous_app-0.2.17.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
35
- autonomous_app-0.2.17.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
36
- autonomous_app-0.2.17.dist-info/RECORD,,
32
+ autonomous_app-0.2.18.dist-info/LICENSE,sha256=-PHHSuDRkodHo3PEdMkDtoIdmLAOomMq6lsLaOetU8g,1076
33
+ autonomous_app-0.2.18.dist-info/METADATA,sha256=wJg_NtpIqVNuLuIJyb7ymhUxNIYtbO0DGF7afA3Dyts,4229
34
+ autonomous_app-0.2.18.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
35
+ autonomous_app-0.2.18.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
36
+ autonomous_app-0.2.18.dist-info/RECORD,,