autonomous-app 0.3.19__py3-none-any.whl → 0.3.20__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.3.19"
1
+ __version__ = "0.3.20"
2
2
 
3
3
  from dotenv import load_dotenv
4
4
 
@@ -17,5 +17,10 @@ class AudioAgent(BaseAgent):
17
17
  def generate(self, prompt, **kwargs):
18
18
  return self.get_client().generate_audio(prompt, **kwargs)
19
19
 
20
+ ## DEPRECATED - use transcribe instead
20
21
  def generate_text(self, audio, **kwargs):
22
+ log("AudioAgent.generate_text is deprecated; use transcribe instead.")
23
+ return self.get_client().generate_audio_text(audio, **kwargs)
24
+
25
+ def transcribe(self, audio, **kwargs):
21
26
  return self.get_client().generate_audio_text(audio, **kwargs)
@@ -1,11 +1,14 @@
1
+ import datetime
1
2
  import io
2
3
  import json
3
4
  import os
4
5
  import random
5
6
  import wave
7
+ from http import client
6
8
 
7
9
  from google import genai
8
10
  from google.genai import types
11
+ from PIL import Image as PILImage
9
12
  from pydub import AudioSegment
10
13
 
11
14
  from autonomous import log
@@ -15,11 +18,11 @@ from autonomous.model.automodel import AutoModel
15
18
 
16
19
  class GeminiAIModel(AutoModel):
17
20
  _client = None
18
- _text_model = "gemini-2.5-pro"
21
+ _text_model = "gemini-3-pro-preview"
19
22
  _summary_model = "gemini-2.5-flash"
20
- _image_model = "gemini-2.5-flash-image-preview"
21
- _json_model = "gemini-2.5-pro"
22
- _stt_model = "gemini-2.5-flash"
23
+ _image_model = "gemini-3-pro-image-preview"
24
+ _json_model = "gemini-3-pro-preview"
25
+ _stt_model = "gemini-3-pro-preview"
23
26
  _tts_model = "gemini-2.5-flash-preview-tts"
24
27
  messages = ListAttr(StringAttr(default=[]))
25
28
  name = StringAttr(default="agent")
@@ -33,7 +36,9 @@ class GeminiAIModel(AutoModel):
33
36
  @property
34
37
  def client(self):
35
38
  if not self._client:
39
+ # log("=== Initializing Gemini AI Client ===", _print=True)
36
40
  self._client = genai.Client(api_key=os.environ.get("GOOGLEAI_KEY"))
41
+ # log("=== Gemini AI Client Initialized ===", _print=True)
37
42
  return self._client
38
43
 
39
44
  def _add_function(self, user_function):
@@ -118,15 +123,40 @@ class GeminiAIModel(AutoModel):
118
123
  # log("=================== END REPORT ===================", _print=True)
119
124
  return response.text
120
125
 
121
- def generate_audio_text(self, audio_file):
126
+ def summarize_text(self, text, primer=""):
127
+ primer = primer or self.instructions
128
+ response = self.client.models.generate_content(
129
+ model=self._summary_model,
130
+ config=types.GenerateContentConfig(
131
+ system_instruction=f"{primer}",
132
+ ),
133
+ contents=text,
134
+ )
135
+ log(response)
136
+ try:
137
+ result = response.candidates[0].content.parts[0].text
138
+ except Exception as e:
139
+ log(f"{type(e)}:{e}\n\n Unable to generate content ====")
140
+ return None
141
+
142
+ return result
143
+
144
+ def generate_audio_text(
145
+ self, audio_file, prompt="Transcribe this audio clip", **kwargs
146
+ ):
147
+ myfile = self.client.files.upload(
148
+ file=io.BytesIO(audio_file),
149
+ config={
150
+ "mime_type": "audio/mp3",
151
+ "display_name": kwargs.get("display_name", "audio.mp3"),
152
+ },
153
+ )
154
+
122
155
  response = self.client.models.generate_content(
123
156
  model=self._stt_model,
124
157
  contents=[
125
- "Transcribe this audio clip",
126
- types.Part.from_bytes(
127
- data=audio_file,
128
- mime_type="audio/mp3",
129
- ),
158
+ prompt,
159
+ myfile,
130
160
  ],
131
161
  )
132
162
  return response.text
@@ -208,37 +238,62 @@ class GeminiAIModel(AutoModel):
208
238
 
209
239
  def generate_image(self, prompt, **kwargs):
210
240
  image = None
241
+ contents = [prompt]
242
+
243
+ if kwargs.get("files"):
244
+ for fn, f in kwargs.get("files").items():
245
+ media = io.BytesIO(f)
246
+ myfile = self.client.files.upload(
247
+ file=media, config={"mime_type": "image/webp", "display_name": fn}
248
+ )
249
+ contents += [myfile]
250
+
211
251
  try:
252
+ # log(self._image_model, contents, _print=True)
212
253
  response = self.client.models.generate_content(
213
254
  model=self._image_model,
214
- contents=[prompt],
255
+ contents=contents,
256
+ config=types.GenerateContentConfig(
257
+ safety_settings=[
258
+ types.SafetySetting(
259
+ category=types.HarmCategory.HARM_CATEGORY_HATE_SPEECH,
260
+ threshold=types.HarmBlockThreshold.BLOCK_NONE,
261
+ ),
262
+ types.SafetySetting(
263
+ category=types.HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
264
+ threshold=types.HarmBlockThreshold.BLOCK_NONE,
265
+ ),
266
+ types.SafetySetting(
267
+ category=types.HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
268
+ threshold=types.HarmBlockThreshold.BLOCK_NONE,
269
+ ),
270
+ types.SafetySetting(
271
+ category=types.HarmCategory.HARM_CATEGORY_HARASSMENT,
272
+ threshold=types.HarmBlockThreshold.BLOCK_NONE,
273
+ ),
274
+ types.SafetySetting(
275
+ category=types.HarmCategory.HARM_CATEGORY_CIVIC_INTEGRITY,
276
+ threshold=types.HarmBlockThreshold.BLOCK_NONE,
277
+ ),
278
+ ],
279
+ image_config=types.ImageConfig(
280
+ aspect_ratio=kwargs.get("aspect_ratio", "3:4"),
281
+ image_size=kwargs.get("image_size", "2K"),
282
+ ),
283
+ ),
215
284
  )
285
+ # log(response, _print=True)
286
+ # log(response.candidates[0], _print=True)
216
287
  image_parts = [
217
288
  part.inline_data.data
218
289
  for part in response.candidates[0].content.parts
219
290
  if part.inline_data
220
291
  ]
221
- # log(image_parts, _print=True)
222
292
  image = image_parts[0]
223
293
  except Exception as e:
224
- log(f"==== Error: Unable to create image ====\n\n{e}", _print=True)
294
+ log(
295
+ f"==== Error: Unable to create image ====\n\n{e}",
296
+ _print=True,
297
+ )
225
298
  raise e
226
299
  return image
227
-
228
- def summarize_text(self, text, primer=""):
229
- primer = primer or self.instructions
230
- response = self.client.models.generate_content(
231
- model=self._summary_model,
232
- config=types.GenerateContentConfig(
233
- system_instruction=f"{primer}",
234
- ),
235
- contents=text,
236
- )
237
- log(response)
238
- try:
239
- result = response.candidates[0].content.parts[0].text
240
- except Exception as e:
241
- log(f"{type(e)}:{e}\n\n Unable to generate content ====")
242
- return None
243
-
244
- return result
autonomous/db/fields.py CHANGED
@@ -1493,7 +1493,7 @@ class GenericReferenceField(BaseField):
1493
1493
  get_document(value.get("_cls")), value.get("_ref")
1494
1494
  )
1495
1495
  except DoesNotExist:
1496
- log(f"{value} DoesNotExist")
1496
+ # log(f"{value} DoesNotExist")
1497
1497
  return
1498
1498
 
1499
1499
  if isinstance(value, Document):
@@ -16,7 +16,6 @@ username = urllib.parse.quote_plus(str(os.getenv("DB_USERNAME")))
16
16
  dbname = os.getenv("DB_DB")
17
17
  # log(f"Connecting to MongoDB at {host}:{port} with {username}:{password} for {dbname}")
18
18
  connect(host=f"mongodb://{username}:{password}@{host}:{port}/{dbname}?authSource=admin")
19
- # log(f"{db}")
20
19
 
21
20
 
22
21
  class AutoModel(Document):
@@ -114,12 +113,6 @@ class AutoModel(Document):
114
113
  visited_subclasses += [subclass]
115
114
  raise ValueError(f"Model {model} not found")
116
115
 
117
- @classmethod
118
- def get_model(cls, model, pk=None):
119
- # log(model, pk)
120
- Model = cls.load_model(model)
121
- return Model.get(pk) if Model and pk else Model
122
-
123
116
  @classmethod
124
117
  def get(cls, pk):
125
118
  """
@@ -1,36 +1,14 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: autonomous-app
3
- Version: 0.3.19
3
+ Version: 0.3.20
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
- License: MIT License
7
-
8
- Copyright (c) [2022] Steven Allen Moore
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
6
  Project-URL: homepage, https://github.com/Sallenmoore/autonomous
28
7
  Classifier: Programming Language :: Python :: 3.12
29
8
  Classifier: License :: OSI Approved :: MIT License
30
9
  Classifier: Operating System :: OS Independent
31
10
  Requires-Python: >=3.12
32
11
  Description-Content-Type: text/markdown
33
- License-File: LICENSE
34
12
  Requires-Dist: Flask
35
13
  Requires-Dist: setuptools
36
14
  Requires-Dist: python-dotenv
@@ -51,7 +29,6 @@ Requires-Dist: google-genai
51
29
  Requires-Dist: dateparser
52
30
  Requires-Dist: python-slugify
53
31
  Requires-Dist: pydub
54
- Dynamic: license-file
55
32
 
56
33
  # Autonomous
57
34
 
@@ -1,8 +1,8 @@
1
- autonomous/__init__.py,sha256=hNX5Dchz3TzAIocmN3NtQ2u4NwhcJ-nOjEGkDdAY_yc,95
1
+ autonomous/__init__.py,sha256=lgBgCoMYcfqa2rFXXDlQXY47095nfXVNXxXwNWYDzYU,95
2
2
  autonomous/cli.py,sha256=z4AaGeWNW_uBLFAHng0J_lfS9v3fXemK1PeT85u4Eo4,42
3
3
  autonomous/logger.py,sha256=NQtgEaTWNAWfLSgqSP7ksXj1GpOuCgoUV711kSMm-WA,2022
4
4
  autonomous/ai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- autonomous/ai/audioagent.py,sha256=Y5tz5IwHgFu3oZkOGrGiHCyMCFHrLi353ZROBTxfZjk,730
5
+ autonomous/ai/audioagent.py,sha256=9QsA-cwj3P4j730bvzUJ3nbucU8tsNLYk_swbkapVvI,966
6
6
  autonomous/ai/baseagent.py,sha256=HYCqC4HmK5afNMunmTkhRE8O0OaONl2GxXnISkdOM58,1094
7
7
  autonomous/ai/imageagent.py,sha256=bIOrgg_CM-rgfyLme7V9vPqP8WKVMIAVoB2E9lLtIRk,521
8
8
  autonomous/ai/jsonagent.py,sha256=a_l4HyyVRj3FB6py_P1xdc4Bj9uNI1YmJrWQXAksIvs,964
@@ -10,7 +10,7 @@ autonomous/ai/textagent.py,sha256=wI1-VC9zscKYyxYBg4pZ0ZyNJ5ZvKkLfWsIY1vJFChk,86
10
10
  autonomous/ai/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  autonomous/ai/models/aws.py,sha256=bGDjnGTm350zOqor9IsICzUkBUN2bubGI_ZssQuSXIw,12715
12
12
  autonomous/ai/models/deepseek.py,sha256=fkoi-hJp60yFlZ9Cb9PdUrmNSErYltQ5ezkUI75llXc,2734
13
- autonomous/ai/models/gemini.py,sha256=FCW7urSGtrc3Q_VgCcbfca2g4nUwA4T_MMfMxWjcUzQ,8473
13
+ autonomous/ai/models/gemini.py,sha256=XPnja5_gp6sNM5k8oR_kMHMafKKe_vbtiutoSWKqNr4,10890
14
14
  autonomous/ai/models/local.py,sha256=fkoi-hJp60yFlZ9Cb9PdUrmNSErYltQ5ezkUI75llXc,2734
15
15
  autonomous/ai/models/openai.py,sha256=2-LttCm6woGklaLbs1H5LjlbfM-7leDwGmC9vksSqW4,13135
16
16
  autonomous/apis/version_control/GHCallbacks.py,sha256=AyiUlYfV5JePi11GVyqYyXoj5UTbPKzS-HRRI94rjJo,1069
@@ -30,7 +30,7 @@ autonomous/db/context_managers.py,sha256=_nH2ajCL8Xy90AuB2rKaryR4iF8Q8ksU3Nei_mZ
30
30
  autonomous/db/dereference.py,sha256=EgbpPCXtDZqD_ZuY1Wd4o3ltRy8qEo3C5yRh5_c9fLE,12776
31
31
  autonomous/db/document.py,sha256=oZKdTaoqwv9fCHiv450rIxgINASQF3J9FzIsUOUXHhw,44428
32
32
  autonomous/db/errors.py,sha256=_QeCotid1kmr7_W0QyH6NUrwwYN9eced_yyyiop0Xlw,4108
33
- autonomous/db/fields.py,sha256=dp7mhnqhZNgM7pP50KS_yX9JK4DfbfSPmswWEV5Zh58,93549
33
+ autonomous/db/fields.py,sha256=2SrsdCXQYnNg9bPfKs9CGa1mTnu6cQFqu0KyFPSamNA,93551
34
34
  autonomous/db/mongodb_support.py,sha256=u0X-zpqTIZZP8o2-IDyKRKHL8ALLhvW1VSGtK3fLyos,626
35
35
  autonomous/db/pymongo_support.py,sha256=UEZ4RHAGb_t1nuMUAJXMNs0vdH3dutxAH5mwFCmG6jI,2951
36
36
  autonomous/db/signals.py,sha256=BM-M4hh4SrTbV9bZVIEWTG8mxgKn9Lo2rC7owLJz4yQ,1791
@@ -50,15 +50,14 @@ autonomous/db/queryset/transform.py,sha256=IIZKf_io60zPTIwJ5KcPcrJOOOOjD2yQU7coY
50
50
  autonomous/db/queryset/visitor.py,sha256=AN09lR6hWYUlKJC7G1sktvnWy5hrFnpoQhi58bOXbA4,5470
51
51
  autonomous/model/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
52
52
  autonomous/model/autoattr.py,sha256=FUnQrw65CcZumYiTsQ7U6G6UDGqbeekka-cjz6Sfchc,2675
53
- autonomous/model/automodel.py,sha256=ltCBs_1H6qL3Igx9nFqAeTcQq2DzLcADHxLOd_DF3hQ,8358
53
+ autonomous/model/automodel.py,sha256=F9rlsna1QYg8mVb-5ErKx5fEXxvaogVxWeeaJQBOOjs,8166
54
54
  autonomous/storage/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
55
55
  autonomous/storage/imagestorage.py,sha256=SmBjBNBlP1ZEjxdOnGVzCHZhbEhMKTUQC2TbpWbejDE,6168
56
56
  autonomous/storage/localstorage.py,sha256=FzrR6O9mMGAZt5dDgqzkeOQVfGRXCygR0kksz2MPpwE,2286
57
57
  autonomous/tasks/__init__.py,sha256=pn7iZ14MhcHUdzcLkfkd4-45wgPP0tXahAz_cFgb_Tg,32
58
58
  autonomous/tasks/autotask.py,sha256=aK5iapDhgcAic3F5ZYMAhNKJkOepj8yWwbMizKDzUwQ,4153
59
59
  autonomous/utils/markdown.py,sha256=tf8vlHARiQO1X_aGbqlYozzP_TbdiDRT9EEP6aFRQo0,2153
60
- autonomous_app-0.3.19.dist-info/licenses/LICENSE,sha256=-PHHSuDRkodHo3PEdMkDtoIdmLAOomMq6lsLaOetU8g,1076
61
- autonomous_app-0.3.19.dist-info/METADATA,sha256=U3zEdOwuCe2me-SLKY5zh_6EhldjaYqm1atT2QkHo1Y,4305
62
- autonomous_app-0.3.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
63
- autonomous_app-0.3.19.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
64
- autonomous_app-0.3.19.dist-info/RECORD,,
60
+ autonomous_app-0.3.20.dist-info/METADATA,sha256=GKNdh8UqT-1bTYkNOoWmlrfZz-UORszoXkcHwSZRn68,3015
61
+ autonomous_app-0.3.20.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
62
+ autonomous_app-0.3.20.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
63
+ autonomous_app-0.3.20.dist-info/RECORD,,
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) [2022] Steven Allen Moore
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.