autonomous-app 0.3.9__py3-none-any.whl → 0.3.11__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.9"
1
+ __version__ = "0.3.11"
2
2
 
3
3
  from dotenv import load_dotenv
4
4
 
@@ -1,12 +1,11 @@
1
1
  from autonomous import log
2
2
  from autonomous.model.autoattr import ReferenceAttr, StringAttr
3
- from autonomous.model.automodel import AutoModel
3
+ from autonomous.ai.baseagent import BaseAgent
4
4
 
5
5
  from .models.openai import OpenAIModel
6
6
 
7
7
 
8
- class AudioAgent(AutoModel):
9
- client = ReferenceAttr(choices=[OpenAIModel])
8
+ class AudioAgent(BaseAgent):
10
9
  name = StringAttr(default="audioagent")
11
10
  instructions = StringAttr(
12
11
  default="You are highly skilled AI trained to assist with generating audio files."
@@ -15,18 +14,5 @@ class AudioAgent(AutoModel):
15
14
  default="A helpful AI assistant trained to assist with generating audio files."
16
15
  )
17
16
 
18
- _ai_model = OpenAIModel
19
-
20
- def get_client(self):
21
- if self.client is None:
22
- self.client = self._ai_model(
23
- name=self.name,
24
- instructions=self.instructions,
25
- description=self.description,
26
- )
27
- self.client.save()
28
- self.save()
29
- return self.client
30
-
31
17
  def generate(self, prompt, file_path, **kwargs):
32
18
  return self.get_client().generate_audio(prompt, file_path, **kwargs)
@@ -5,16 +5,24 @@ from autonomous.model.automodel import AutoModel
5
5
  from .models.openai import OpenAIModel
6
6
 
7
7
 
8
- # class BaseAgent(AutoModel):
9
- # client_model = ReferenceAttr(choices=[OpenAIModel])
10
- # _ai_model = OpenAIModel
11
-
12
- # @property
13
- # def client(self):
14
- # if self.client_model is None:
15
- # self.client_model = self._ai_model()
16
- # self.save()
17
- # return self.client_model
8
+ class BaseAgent(AutoModel):
9
+ meta = {"abstract": True, "allow_inheritance": True, "strict": False}
10
+
11
+ client = ReferenceAttr(choices=[OpenAIModel])
12
+
13
+ _ai_model = OpenAIModel
14
+
15
+ def get_client(self):
16
+ if self.client is None:
17
+ self.client = self._ai_model(
18
+ name=self.name,
19
+ instructions=self.instructions,
20
+ description=self.description,
21
+ )
22
+ self.client.save()
23
+ self.save()
24
+ return self.client
25
+
18
26
 
19
27
  # def clear_files(self, file_id=None):
20
28
  # return self.client.clear_files(file_id)
@@ -1,11 +1,10 @@
1
1
  from autonomous.model.autoattr import ReferenceAttr, StringAttr
2
2
  from autonomous.model.automodel import AutoModel
3
-
3
+ from autonomous.ai.baseagent import BaseAgent
4
4
  from .models.openai import OpenAIModel
5
5
 
6
6
 
7
- class ImageAgent(AutoModel):
8
- client = ReferenceAttr(choices=[OpenAIModel])
7
+ class ImageAgent(BaseAgent):
9
8
  name = StringAttr(default="imageagent")
10
9
  instructions = StringAttr(
11
10
  default="You are highly skilled AI trained to assist with generating images."
@@ -14,18 +13,5 @@ class ImageAgent(AutoModel):
14
13
  default="A helpful AI assistant trained to assist with generating images."
15
14
  )
16
15
 
17
- _ai_model = OpenAIModel
18
-
19
- def get_client(self):
20
- if self.client is None:
21
- self.client = self._ai_model(
22
- name=self.name,
23
- instructions=self.instructions,
24
- description=self.description,
25
- )
26
- self.client.save()
27
- self.save()
28
- return self.client
29
-
30
16
  def generate(self, prompt, **kwargs):
31
17
  return self.get_client().generate_image(prompt, **kwargs)
@@ -2,12 +2,11 @@ import json
2
2
 
3
3
  from autonomous.model.autoattr import ReferenceAttr, StringAttr
4
4
  from autonomous.model.automodel import AutoModel
5
-
5
+ from autonomous.ai.baseagent import BaseAgent
6
6
  from .models.openai import OpenAIModel
7
7
 
8
8
 
9
- class JSONAgent(AutoModel):
10
- client = ReferenceAttr(choices=[OpenAIModel])
9
+ class JSONAgent(BaseAgent):
11
10
  name = StringAttr(default="jsonagent")
12
11
  instructions = StringAttr(
13
12
  default="You are highly skilled AI trained to assist with generating JSON formatted data."
@@ -16,24 +15,11 @@ class JSONAgent(AutoModel):
16
15
  default="A helpful AI assistant trained to assist with generating JSON formatted data."
17
16
  )
18
17
 
19
- _ai_model = OpenAIModel
20
-
21
18
  def clear_files(self, file_id=None):
22
- return self.client.clear_files(file_id)
19
+ return self.get_client().clear_files(file_id)
23
20
 
24
21
  def attach_file(self, file_contents, filename="dbdata.json"):
25
- return self.client.attach_file(file_contents, filename)
26
-
27
- def get_client(self):
28
- if self.client is None:
29
- self.client = self._ai_model(
30
- name=self.name,
31
- instructions=self.instructions,
32
- description=self.description,
33
- )
34
- self.client.save()
35
- self.save()
36
- return self.client
22
+ return self.get_client().attach_file(file_contents, filename)
37
23
 
38
24
  def generate(self, messages, function, additional_instructions=""):
39
25
  result = self.get_client().generate_json(
@@ -55,7 +55,11 @@ class OpenAIModel(AutoModel):
55
55
  self.save()
56
56
 
57
57
  def _get_agent_id(self):
58
- if not self.agent_id or not self.client.beta.assistants.retrieve(self.agent_id):
58
+ try:
59
+ self.client.beta.assistants.retrieve(self.agent_id)
60
+ except openai.NotFoundError as e:
61
+ self.clear_files()
62
+ log("no agent found, creating a new one")
59
63
  agent = self.client.beta.assistants.create(
60
64
  instructions=self.instructions,
61
65
  description=self.description,
@@ -183,7 +187,7 @@ IMPORTANT: Always use the function 'response' tool to respond to the user with o
183
187
  ]:
184
188
  running_job = False
185
189
 
186
- except openai.error.BadRequestError as e:
190
+ except openai.BadRequestError as e:
187
191
  # Handle specific bad request errors
188
192
  error_message = e.json_body.get("error", {}).get("message", "")
189
193
  if "already has an active run" in error_message:
@@ -226,6 +230,7 @@ IMPORTANT: Always use the function 'response' tool to respond to the user with o
226
230
  return results
227
231
 
228
232
  def generate_text(self, messages, additional_instructions=""):
233
+ self._get_agent_id()
229
234
  formatted_messages = self._format_messages(messages)
230
235
  thread = self.client.beta.threads.create(messages=formatted_messages)
231
236
 
@@ -1,12 +1,11 @@
1
1
  from autonomous import log
2
2
  from autonomous.model.autoattr import ReferenceAttr, StringAttr
3
3
  from autonomous.model.automodel import AutoModel
4
-
4
+ from autonomous.ai.baseagent import BaseAgent
5
5
  from .models.openai import OpenAIModel
6
6
 
7
7
 
8
- class TextAgent(AutoModel):
9
- client = ReferenceAttr(choices=[OpenAIModel])
8
+ class TextAgent(BaseAgent):
10
9
  name = StringAttr(default="textagent")
11
10
  instructions = StringAttr(
12
11
  default="You are highly skilled AI trained to assist with generating text according to the given requirements."
@@ -15,24 +14,11 @@ class TextAgent(AutoModel):
15
14
  default="A helpful AI assistant trained to assist with generating text according to the given requirements."
16
15
  )
17
16
 
18
- _ai_model = OpenAIModel
19
-
20
17
  def clear_files(self, file_id=None):
21
- return self.client.clear_files(file_id)
18
+ return self.get_client().clear_files(file_id)
22
19
 
23
20
  def attach_file(self, file_contents, filename="dbdata.json"):
24
- return self.client.attach_file(file_contents, filename)
25
-
26
- def get_client(self):
27
- if self.client is None:
28
- self.client = self._ai_model(
29
- name=self.name,
30
- instructions=self.instructions,
31
- description=self.description,
32
- )
33
- self.client.save()
34
- self.save()
35
- return self.client
21
+ return self.get_client().attach_file(file_contents, filename)
36
22
 
37
23
  def summarize_text(self, text, primer=""):
38
24
  return self.get_client().summarize_text(text, primer)
autonomous/db/fields.py CHANGED
@@ -1533,7 +1533,6 @@ class GenericReferenceField(BaseField):
1533
1533
  auto_dereference = instance._fields[self.name]._auto_dereference
1534
1534
  if auto_dereference and isinstance(value, dict) and "_cls" in value:
1535
1535
  doc_cls = get_document(value["_cls"])
1536
- log(self.name, value, doc_cls)
1537
1536
  instance._data[self.name] = self._lazy_load_ref(doc_cls, value["_ref"])
1538
1537
 
1539
1538
  return super().__get__(instance, owner)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: autonomous-app
3
- Version: 0.3.9
3
+ Version: 0.3.11
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,14 +1,14 @@
1
- autonomous/__init__.py,sha256=AqKjL-FUNxKedFZdrhtQNbU9-WwXrbvSHKU2J-1bGDU,94
1
+ autonomous/__init__.py,sha256=LqPKmIGRGZ_91hBOzfCLYFqx_Af2TrUidswoUQeiBhQ,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=uZEhJ8_ctEvzshxJewaGdw-gh2Ts8lIcEysh0rlL62w,1040
6
- autonomous/ai/baseagent.py,sha256=Wfo0n0M9_eCSb9s0QbFelDlANH-o1lgZiRXZf7VeOP0,710
7
- autonomous/ai/imageagent.py,sha256=Y3n4OFD-UC9lSg1j-U9wRnyLLaRl0LjibHbriJwYF2c,981
8
- autonomous/ai/jsonagent.py,sha256=gJVFFKuH6yBiSG0U1WBCyjDeT7kCvW3bxeU6TpkhPLM,1542
9
- autonomous/ai/textagent.py,sha256=bi9v5pawylY6p43wYoaAEs-qyMOskFBnR21-_lJo7Aw,1441
5
+ autonomous/ai/audioagent.py,sha256=Vqh_1YxfZ1T7sU27BR06d_d618heA0mRlOa0440_NHs,635
6
+ autonomous/ai/baseagent.py,sha256=NE3OjDqu2e9Wy-cQEzzQoHPUrtFo__WPpPAN0v3zOxs,905
7
+ autonomous/ai/imageagent.py,sha256=Tn02Hk7WX53pqvK-2Xd2xOuyHKaNuAS_yr7lRdct3rc,624
8
+ autonomous/ai/jsonagent.py,sha256=wlTULEBlrAAb8ELMxik1b7YOgHD4ARmbWLUWc5pgxB8,1197
9
+ autonomous/ai/textagent.py,sha256=8iVuY-cSJsJgyWKrpCoj46c0MIsB13PFPNYdxSyqlKI,1096
10
10
  autonomous/ai/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- autonomous/ai/models/openai.py,sha256=npavtBRWaxZuO3EtdFK1pm64wporJcTb_JDdxhMyhPI,11732
11
+ autonomous/ai/models/openai.py,sha256=fVfPsintow3fl7DVChMwcoiq83lpUZqFkNR7XBXJIZw,11870
12
12
  autonomous/apis/version_control/GHCallbacks.py,sha256=AyiUlYfV5JePi11GVyqYyXoj5UTbPKzS-HRRI94rjJo,1069
13
13
  autonomous/apis/version_control/GHOrganization.py,sha256=mi2livdsGurKiifbvuLwiFbdDzL77IlEfhwEa-tG77I,1155
14
14
  autonomous/apis/version_control/GHRepo.py,sha256=hTFHMkxSbSlVELfh8S6mq6ijkIKPRQO-Q5775ZjRKD4,4622
@@ -26,7 +26,7 @@ autonomous/db/context_managers.py,sha256=_nH2ajCL8Xy90AuB2rKaryR4iF8Q8ksU3Nei_mZ
26
26
  autonomous/db/dereference.py,sha256=EgbpPCXtDZqD_ZuY1Wd4o3ltRy8qEo3C5yRh5_c9fLE,12776
27
27
  autonomous/db/document.py,sha256=oZKdTaoqwv9fCHiv450rIxgINASQF3J9FzIsUOUXHhw,44428
28
28
  autonomous/db/errors.py,sha256=_QeCotid1kmr7_W0QyH6NUrwwYN9eced_yyyiop0Xlw,4108
29
- autonomous/db/fields.py,sha256=ZX1AdxuvSbXbl1Zn-Ma-PvoXsjkM63JhBjGU9nJUBX0,93611
29
+ autonomous/db/fields.py,sha256=YMeXO5C8hiWKrknmQtaWOKDF-b1pMVEvCnlZrjMBamE,93568
30
30
  autonomous/db/mongodb_support.py,sha256=u0X-zpqTIZZP8o2-IDyKRKHL8ALLhvW1VSGtK3fLyos,626
31
31
  autonomous/db/pymongo_support.py,sha256=UEZ4RHAGb_t1nuMUAJXMNs0vdH3dutxAH5mwFCmG6jI,2951
32
32
  autonomous/db/signals.py,sha256=BM-M4hh4SrTbV9bZVIEWTG8mxgKn9Lo2rC7owLJz4yQ,1791
@@ -53,8 +53,8 @@ autonomous/storage/localstorage.py,sha256=FzrR6O9mMGAZt5dDgqzkeOQVfGRXCygR0kksz2
53
53
  autonomous/tasks/__init__.py,sha256=pn7iZ14MhcHUdzcLkfkd4-45wgPP0tXahAz_cFgb_Tg,32
54
54
  autonomous/tasks/autotask.py,sha256=aK5iapDhgcAic3F5ZYMAhNKJkOepj8yWwbMizKDzUwQ,4153
55
55
  autonomous/utils/markdown.py,sha256=tf8vlHARiQO1X_aGbqlYozzP_TbdiDRT9EEP6aFRQo0,2153
56
- autonomous_app-0.3.9.dist-info/LICENSE,sha256=-PHHSuDRkodHo3PEdMkDtoIdmLAOomMq6lsLaOetU8g,1076
57
- autonomous_app-0.3.9.dist-info/METADATA,sha256=uZZNCYit6hfJhjTD0MUAi3via-Cv_a9NTL8YZ838glQ,4188
58
- autonomous_app-0.3.9.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
59
- autonomous_app-0.3.9.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
60
- autonomous_app-0.3.9.dist-info/RECORD,,
56
+ autonomous_app-0.3.11.dist-info/LICENSE,sha256=-PHHSuDRkodHo3PEdMkDtoIdmLAOomMq6lsLaOetU8g,1076
57
+ autonomous_app-0.3.11.dist-info/METADATA,sha256=V2_Kp07O8jKpLexpAT-hcg8-phZQ2U8ZO5gbCshDbSE,4189
58
+ autonomous_app-0.3.11.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
59
+ autonomous_app-0.3.11.dist-info/top_level.txt,sha256=ZyxWWDdbvZekF3UFunxl4BQsVDb_FOW3eTn0vun_jb4,11
60
+ autonomous_app-0.3.11.dist-info/RECORD,,