pygeai 0.2.7b38__py3-none-any.whl → 0.2.7b39__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.
@@ -1,4 +1,5 @@
1
1
  from pygeai import logger
2
+ from pygeai.admin.clients import AdminClient
2
3
  from pygeai.core.base.mappers import ErrorMapper, ResponseMapper
3
4
  from pygeai.core.base.responses import EmptyResponse
4
5
  from pygeai.core.files.clients import FileClient
@@ -28,8 +29,26 @@ class FileManager:
28
29
  base_url,
29
30
  alias
30
31
  )
31
- self.__organization_id = organization_id
32
- self.__project_id = project_id
32
+ self.organization_id = self.__get_organization_id() if not organization_id else organization_id
33
+ self.project_id = self.__get_project_id() if not project_id else project_id
34
+
35
+ def __get_organization_id(self):
36
+ response = None
37
+ try:
38
+ response = AdminClient().validate_api_token()
39
+ return response.get("organizationId")
40
+ except Exception as e:
41
+ logger.error(f"Error retrieving organization_id from GEAI. Response: {response}: {e}")
42
+ raise APIError(f"Error retrieving organization_id from GEAI: {e}")
43
+
44
+ def __get_project_id(self):
45
+ response = None
46
+ try:
47
+ response = AdminClient().validate_api_token()
48
+ return response.get("projectId")
49
+ except Exception as e:
50
+ logger.error(f"Error retrieving project_id from GEAI. Response: {response}: {e}")
51
+ raise APIError(f"Error retrieving project_id from GEAI: {e}")
33
52
 
34
53
  def upload_file(
35
54
  self,
@@ -47,8 +66,8 @@ class FileManager:
47
66
  """
48
67
  response_data = self.__client.upload_file(
49
68
  file_path=file.path,
50
- organization_id=self.__organization_id,
51
- project_id=self.__project_id,
69
+ organization_id=self.organization_id,
70
+ project_id=self.project_id,
52
71
  folder=file.folder,
53
72
  file_name=file.name,
54
73
  )
@@ -75,8 +94,8 @@ class FileManager:
75
94
  :raises APIError: If the API returns errors.
76
95
  """
77
96
  response_data = self.__client.get_file(
78
- organization=self.__organization_id,
79
- project=self.__project_id,
97
+ organization=self.organization_id,
98
+ project=self.project_id,
80
99
  file_id=file_id
81
100
  )
82
101
  if ErrorHandler.has_errors(response_data):
@@ -101,8 +120,8 @@ class FileManager:
101
120
  :raises APIError: If the API returns errors.
102
121
  """
103
122
  response_data = self.__client.delete_file(
104
- organization=self.__organization_id,
105
- project=self.__project_id,
123
+ organization=self.organization_id,
124
+ project=self.project_id,
106
125
  file_id=file_id
107
126
  )
108
127
  if ErrorHandler.has_errors(response_data):
@@ -128,8 +147,8 @@ class FileManager:
128
147
  :raises APIError: If the API returns errors.
129
148
  """
130
149
  response_data = self.__client.get_file_content(
131
- organization=self.__organization_id,
132
- project=self.__project_id,
150
+ organization=self.organization_id,
151
+ project=self.project_id,
133
152
  file_id=file_id
134
153
  )
135
154
  if isinstance(response_data, dict) and "errors" in response_data:
@@ -151,8 +170,8 @@ class FileManager:
151
170
  :raises APIError: If the API returns errors.
152
171
  """
153
172
  response_data = self.__client.get_file_list(
154
- organization=self.__organization_id,
155
- project=self.__project_id
173
+ organization=self.organization_id,
174
+ project=self.project_id
156
175
  )
157
176
  if ErrorHandler.has_errors(response_data):
158
177
  error = ErrorHandler.extract_error(response_data)
@@ -1,12 +1,9 @@
1
- from pygeai.core.models import Organization, Project
2
1
  from pygeai.core.files.managers import FileManager
3
2
  from pygeai.core.files.models import File
4
3
 
5
- organization = Organization(id="4aa15b61-d3c7-4a5c-99b8-052d18a04ff2")
6
- project = Project(id="1956c032-3c66-4435-acb8-6a06e52f819f")
7
4
  file = File(id="7fe2393d-8f86-4020-a51f-bc14ab957e1e")
8
5
 
9
- file_manager = FileManager(organization_id=organization.id, project_id=project.id)
6
+ file_manager = FileManager()
10
7
 
11
8
  response = file_manager.delete_file(file_id=file.id)
12
9
  print(response)
@@ -1,12 +1,10 @@
1
- from pygeai.core.models import Organization, Project
2
1
  from pygeai.core.files.managers import FileManager
3
2
  from pygeai.core.files.models import File
4
3
 
5
- organization = Organization(id="4aa15b61-d3c7-4a5c-99b8-052d18a04ff2")
6
- project = Project(id="1956c032-3c66-4435-acb8-6a06e52f819f")
4
+
7
5
  file = File(id="7fe2393d-8f86-4020-a51f-bc14ab957e1e")
8
6
 
9
- file_manager = FileManager(organization_id=organization.id, project_id=project.id)
7
+ file_manager = FileManager()
10
8
 
11
9
  response = file_manager.get_file_content(file_id=file.id)
12
10
  print(response)
@@ -1,12 +1,9 @@
1
- from pygeai.core.models import Organization, Project
2
1
  from pygeai.core.files.managers import FileManager
3
2
  from pygeai.core.files.models import File
4
3
 
5
- organization = Organization(id="4aa15b61-d3c7-4a5c-99b8-052d18a04ff2")
6
- project = Project(id="1956c032-3c66-4435-acb8-6a06e52f819f")
7
4
  file = File(id="9984b837-fe88-4014-ad14-91e1596c8ead")
8
5
 
9
- file_manager = FileManager(organization_id=organization.id, project_id=project.id)
6
+ file_manager = FileManager()
10
7
 
11
8
  response = file_manager.get_file_data(file_id=file.id)
12
9
  print(response)
@@ -1,11 +1,6 @@
1
- from pygeai.core.models import Organization, Project
2
1
  from pygeai.core.files.managers import FileManager
3
2
 
4
- organization = Organization(id="4aa15b61-d3c7-4a5c-99b8-052d18a04ff2")
5
- project = Project(id="1956c032-3c66-4435-acb8-6a06e52f819f")
6
-
7
-
8
- file_manager = FileManager(organization_id=organization.id, project_id=project.id)
3
+ file_manager = FileManager()
9
4
 
10
5
  response = file_manager.get_file_list()
11
6
  print(response)
@@ -1,17 +1,13 @@
1
- from pygeai.core.models import Organization, Project
2
1
  from pygeai.core.files.managers import FileManager
3
2
  from pygeai.core.files.models import UploadFile
4
3
 
5
- organization = Organization(id="4aa15b61-d3c7-4a5c-99b8-052d18a04ff2")
6
- project = Project(id="1956c032-3c66-4435-acb8-6a06e52f819f")
7
-
8
4
  file = UploadFile(
9
5
  path="test.txt",
10
6
  name="TestyFile",
11
7
  folder="TestyTestTemp"
12
8
  )
13
9
 
14
- file_manager = FileManager(organization_id=organization.id, project_id=project.id)
10
+ file_manager = FileManager()
15
11
 
16
12
  response = file_manager.upload_file(file)
17
13
  print(response)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pygeai
3
- Version: 0.2.7b38
3
+ Version: 0.2.7b39
4
4
  Summary: Software Development Kit to interact with Globant Enterprise AI.
5
5
  Author-email: Globant <geai-sdk@globant.com>
6
6
  License-Expression: MIT
@@ -91,7 +91,7 @@ pygeai/core/feedback/models.py,sha256=VdeVVWTQ8qc4TEPbL2XbYI4-UP2m2eh1pkBptw_do1
91
91
  pygeai/core/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
92
92
  pygeai/core/files/clients.py,sha256=gjmm5H_BOEK_QRNb55s4CBGMA_IRV-xvkwf9YCjdEAY,6564
93
93
  pygeai/core/files/endpoints.py,sha256=hAUC28hYVcHyEyEfoLaLae76TpuVSLexPVjLJYjSWYQ,337
94
- pygeai/core/files/managers.py,sha256=rzkJr9pOJYV4_y_3SRhd7gAZ4n3ziH_4TLN9gwIs_EY,6269
94
+ pygeai/core/files/managers.py,sha256=Hzq-XMEJnnNrh3pG5PViQqSt1WrbO-z5wHXsoGrSQxA,7158
95
95
  pygeai/core/files/mappers.py,sha256=8PXXsQJZEH45yLISn_xsOZmcRUEe_F6ELkUeR1lzc-M,1462
96
96
  pygeai/core/files/models.py,sha256=QOLV5kUrHOvhJXzkoFqNQX4qmVPLy6KKBk6u7oE5ttU,438
97
97
  pygeai/core/files/responses.py,sha256=fnNLK-stnXGnB9d38szWrZMu7JLTtXghAoRZnFTFJCE,356
@@ -343,11 +343,11 @@ pygeai/tests/snippets/embeddings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
343
343
  pygeai/tests/snippets/embeddings/generate_embeddings.py,sha256=IyIlO6UDGMjT-E9uK91NdYsuWI4fCRGwqlaFr0iUzSc,785
344
344
  pygeai/tests/snippets/evaluation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
345
345
  pygeai/tests/snippets/files/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
346
- pygeai/tests/snippets/files/delete_file.py,sha256=7GvC_aKPUExTt7-AApe9LnTRxo3CriWYn6vLZlk4Q24,488
347
- pygeai/tests/snippets/files/get_file_content.py,sha256=o1o81A3_3UrHFjBtNUyVYUJgPmRKgmylR5tfNWEhRpU,493
348
- pygeai/tests/snippets/files/get_file_data.py,sha256=Tnki6VpnRAMXAFQEEsRYXTqWhT2AfH-Gpyu3c5rXG00,490
349
- pygeai/tests/snippets/files/get_file_list.py,sha256=nlPsdEFTAYtIMx7N4CnrWhkkzt-vdzGw4ZmfxkU2ITY,379
350
- pygeai/tests/snippets/files/upload_file.py,sha256=SOgnkFg6FRsBfQSspHdx7oRgcth2b7-H05krs9Sb8H4,520
346
+ pygeai/tests/snippets/files/delete_file.py,sha256=ORpPkrL9FllDonCHfoqf6LJUGyPHBoTdm1zpopzqbqU,249
347
+ pygeai/tests/snippets/files/get_file_content.py,sha256=LM8DEmtE4MebEptcR_SUrbMfKuR9zfKfxsY9JspLVvc,255
348
+ pygeai/tests/snippets/files/get_file_data.py,sha256=DGxbH155IcquE0t2uOifJRI6o5JQ8-DT5zQJ9MubIG4,251
349
+ pygeai/tests/snippets/files/get_file_list.py,sha256=NItZBEqzHsS8HQEpAI2yoI5URhZB0F5eAys5Okbled8,138
350
+ pygeai/tests/snippets/files/upload_file.py,sha256=In6XIvIFSbctrqOD8r_WMmGlXYGju4syNrBAZULjFow,280
351
351
  pygeai/tests/snippets/gam/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
352
352
  pygeai/tests/snippets/gam/gam_access_token.py,sha256=168cZwF3IcAZ3neCdvh1jRxi1acpIDXHuyBZnuWwHQY,3122
353
353
  pygeai/tests/snippets/lab/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -475,9 +475,9 @@ pygeai/vendor/a2a/utils/helpers.py,sha256=6Tbd8SVfXvdNEk6WYmLOjrAxkzFf1aIg8dkFfB
475
475
  pygeai/vendor/a2a/utils/message.py,sha256=gc_EKO69CJ4HkR76IFgsy-kENJz1dn7CfSgWJWvt-gs,2197
476
476
  pygeai/vendor/a2a/utils/task.py,sha256=BYRA_L1HpoUGJAVlyHML0lCM9Awhf2Ovjj7oPFXKbh0,1647
477
477
  pygeai/vendor/a2a/utils/telemetry.py,sha256=VvSp1Ztqaobkmq9-3sNhhPEilJS32-JTSfKzegkj6FU,10861
478
- pygeai-0.2.7b38.dist-info/licenses/LICENSE,sha256=eHfqo7-AWS8cMq0cg03lq7owsLeCmZA-xS5L0kuHnl8,1474
479
- pygeai-0.2.7b38.dist-info/METADATA,sha256=rl5fe-KL2smKocKPp1mlDZhHGTUhwRnbj9XX17fJjG8,6883
480
- pygeai-0.2.7b38.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
481
- pygeai-0.2.7b38.dist-info/entry_points.txt,sha256=OAmwuXVCQBTCE3HeVegVd37hbhCcp9TPahvdrCuMYWw,178
482
- pygeai-0.2.7b38.dist-info/top_level.txt,sha256=bJFwp2tURmCfB94yXDF7ylvdSJXFDDJsyUOb-7PJgwc,7
483
- pygeai-0.2.7b38.dist-info/RECORD,,
478
+ pygeai-0.2.7b39.dist-info/licenses/LICENSE,sha256=eHfqo7-AWS8cMq0cg03lq7owsLeCmZA-xS5L0kuHnl8,1474
479
+ pygeai-0.2.7b39.dist-info/METADATA,sha256=Rs88NXHwjCB6i5OIyNq7FChpuoFUxR3TFIdn3X8DNEY,6883
480
+ pygeai-0.2.7b39.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
481
+ pygeai-0.2.7b39.dist-info/entry_points.txt,sha256=OAmwuXVCQBTCE3HeVegVd37hbhCcp9TPahvdrCuMYWw,178
482
+ pygeai-0.2.7b39.dist-info/top_level.txt,sha256=bJFwp2tURmCfB94yXDF7ylvdSJXFDDJsyUOb-7PJgwc,7
483
+ pygeai-0.2.7b39.dist-info/RECORD,,