agenta 0.5.4__py3-none-any.whl → 0.5.6__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.

Potentially problematic release.


This version of agenta might be problematic. Click here for more details.

agenta/__init__.py CHANGED
@@ -7,6 +7,7 @@ from .sdk.types import (
7
7
  InFile,
8
8
  IntParam,
9
9
  MultipleChoiceParam,
10
+ MessagesInput,
10
11
  TextParam,
11
12
  )
12
13
  from .sdk.utils.preinit import PreInitObject
agenta/cli/helper.py CHANGED
@@ -83,16 +83,18 @@ def get_api_key() -> str:
83
83
  return api_key
84
84
  elif confirm_api_key is None: # User pressed Ctrl+C
85
85
  sys.exit(0)
86
- else:
87
- api_key = questionary.text(
88
- "(You can get your API Key here: https://demo.agenta.ai/settings?tab=apiKeys) "
89
- "Please provide your API key:"
90
- ).ask()
91
86
 
92
- if api_key:
93
- set_global_config("api_key", api_key)
94
- elif api_key is None: # User pressed Ctrl+C
95
- sys.exit(0)
87
+ api_key = questionary.text(
88
+ "(You can get your API Key here: https://cloud.agenta.ai/settings?tab=apiKeys) "
89
+ "Please provide your API key:"
90
+ ).ask()
91
+
92
+ if api_key:
93
+ set_global_config("api_key", api_key)
94
+
95
+ return api_key
96
+ elif api_key is None: # User pressed Ctrl+C
97
+ sys.exit(0)
96
98
 
97
99
 
98
100
  def init_telemetry_config() -> None:
@@ -122,7 +124,6 @@ def update_variants_from_backend(
122
124
  Returns:
123
125
  a new config object later to be saved using toml.dump(config, config_file.open('w'))
124
126
  """
125
-
126
127
  try:
127
128
  variants: List[AppVariant] = client.list_variants(app_id, host, api_key)
128
129
  except Exception as ex:
agenta/cli/main.py CHANGED
@@ -91,7 +91,7 @@ def init(app_name: str):
91
91
  try:
92
92
  where_question = questionary.select(
93
93
  "Where are you running agenta?",
94
- choices=["On my local machine", "On a remote machine", "On agenta cloud"],
94
+ choices=["On agenta cloud", "On my local machine", "On a remote machine"],
95
95
  ).ask()
96
96
 
97
97
  if where_question == "On my local machine":
@@ -101,7 +101,7 @@ def init(app_name: str):
101
101
  "Please provide the IP or URL of your remote host"
102
102
  ).ask()
103
103
  elif where_question == "On agenta cloud":
104
- backend_host = "https://demo.agenta.ai"
104
+ backend_host = "https://cloud.agenta.ai"
105
105
 
106
106
  api_key = helper.get_api_key()
107
107
  client.validate_api_key(api_key, backend_host)
@@ -119,6 +119,9 @@ def add_variant(
119
119
  image: Image = client.send_docker_tar(
120
120
  app_id, base_name, tar_path, host, api_key
121
121
  )
122
+ if tar_path.exists():
123
+ tar_path.unlink()
124
+
122
125
  # docker_image: DockerImage = build_and_upload_docker_image(
123
126
  # folder=app_path, app_name=app_name, variant_name=variant_name)
124
127
  except Exception as ex:
agenta/client/client.py CHANGED
@@ -203,17 +203,21 @@ def list_variants(app_id: str, host: str, api_key: str = None) -> List[AppVarian
203
203
  headers={"Authorization": api_key} if api_key is not None else None,
204
204
  timeout=600,
205
205
  )
206
-
207
206
  # Check for successful request
208
207
  if response.status_code == 403:
209
208
  raise APIRequestError(
210
209
  f"No app by id {app_id} exists or you do not have access to it."
211
210
  )
211
+ elif response.status_code == 404:
212
+ raise APIRequestError(
213
+ f"No app by id {app_id} exists or you do not have access to it."
214
+ )
212
215
  elif response.status_code != 200:
213
216
  error_message = response.json()
214
217
  raise APIRequestError(
215
218
  f"Request to apps endpoint failed with status code {response.status_code} and error message: {error_message}."
216
219
  )
220
+
217
221
  app_variants = response.json()
218
222
  return [AppVariant(**variant) for variant in app_variants]
219
223
 
agenta/config.toml CHANGED
@@ -2,4 +2,4 @@ docker_registry_url="127.0.0.1:5001"
2
2
  database_url="localhost:5432"
3
3
  registry="agenta-server"
4
4
  backend_url_suffix="api"
5
- allow_origins="http://localhost:3000,http://localhost:3001,http://demo.agenta.ai"
5
+ allow_origins="http://localhost:3000,http://localhost:3001,http://cloud.agenta.ai,https://cloud.agenta.ai"
@@ -0,0 +1,8 @@
1
+ FROM public.ecr.aws/s2t9a1r1/agentaai/lambda_templates_public:main
2
+
3
+ COPY requirements.txt ${LAMBDA_TASK_ROOT}
4
+ RUN pip install --no-cache-dir --disable-pip-version-check -r requirements.txt
5
+ RUN pip install --no-cache-dir --disable-pip-version-check mangum
6
+ COPY . ${LAMBDA_TASK_ROOT}
7
+
8
+ CMD [ "lambda_function.handler" ]
@@ -0,0 +1,6 @@
1
+ import agenta
2
+ import _app
3
+ from mangum import Mangum
4
+
5
+
6
+ handler = Mangum(agenta.app)
@@ -12,6 +12,8 @@ from docker.models.images import Image
12
12
  logger = logging.getLogger(__name__)
13
13
  logger.setLevel(logging.DEBUG)
14
14
 
15
+ DEBUG = False
16
+
15
17
 
16
18
  def create_dockerfile(out_folder: Path):
17
19
  """Creates a dockerfile based on the template in the out_folder.
@@ -25,6 +27,12 @@ def create_dockerfile(out_folder: Path):
25
27
  )
26
28
  dockerfile_path = out_folder / "Dockerfile"
27
29
  shutil.copy(dockerfile_template, dockerfile_path)
30
+ dockerfile_template = (
31
+ Path(__file__).parent / "docker-assets" / "Dockerfile.cloud.template"
32
+ )
33
+ dockerfile_path = out_folder / "Dockerfile.cloud"
34
+ shutil.copy(dockerfile_template, dockerfile_path)
35
+
28
36
  return dockerfile_path
29
37
 
30
38
 
@@ -41,9 +49,10 @@ def build_tar_docker_container(folder: Path, file_name: Path) -> Path:
41
49
  if tarfile_path.exists():
42
50
  tarfile_path.unlink()
43
51
 
44
- dockerfile_path = create_dockerfile(folder)
52
+ create_dockerfile(folder)
45
53
  shutil.copytree(Path(__file__).parent.parent, folder / "agenta", dirs_exist_ok=True)
46
54
  shutil.copy(Path(__file__).parent / "docker-assets" / "main.py", folder)
55
+ shutil.copy(Path(__file__).parent / "docker-assets" / "lambda_function.py", folder)
47
56
  shutil.copy(Path(__file__).parent / "docker-assets" / "entrypoint.sh", folder)
48
57
 
49
58
  # Read the contents of .gitignore file
@@ -75,6 +84,18 @@ def build_tar_docker_container(folder: Path, file_name: Path) -> Path:
75
84
  # Create the tar.gz file
76
85
  with tarfile.open(tarfile_path, "w:gz") as tar:
77
86
  tar.add(temp_path, arcname=folder.name)
87
+ if not DEBUG:
88
+ # Clean up - remove specified files and folders
89
+ for item in ["agenta", "main.py", "lambda_function.py", "entrypoint.sh"]:
90
+ path = folder / item
91
+ if path.exists():
92
+ if path.is_dir():
93
+ shutil.rmtree(path)
94
+ else:
95
+ path.unlink()
96
+
97
+ for dockerfile in folder.glob("Dockerfile*"):
98
+ dockerfile.unlink()
78
99
 
79
100
  # dockerfile_path.unlink()
80
101
  return tarfile_path
agenta/sdk/__init__.py CHANGED
@@ -10,6 +10,7 @@ from .types import (
10
10
  IntParam,
11
11
  MultipleChoiceParam,
12
12
  TextParam,
13
+ MessagesInput,
13
14
  )
14
15
  from .agenta_init import Config, init
15
16
 
@@ -25,6 +25,7 @@ from .types import (
25
25
  IntParam,
26
26
  MultipleChoiceParam,
27
27
  TextParam,
28
+ MessagesInput,
28
29
  )
29
30
 
30
31
  app = FastAPI()
@@ -313,6 +314,7 @@ def override_schema(openapi_schema: dict, func_name: str, endpoint: str, params:
313
314
  - The min and max values for each FloatParam instance
314
315
  - The min and max values for each IntParam instance
315
316
  - The default value for DictInput instance
317
+ - The default value for MessagesParam instance
316
318
  - ... [PLEASE ADD AT EACH CHANGE]
317
319
 
318
320
  Args:
@@ -374,3 +376,9 @@ def override_schema(openapi_schema: dict, func_name: str, endpoint: str, params:
374
376
  if isinstance(param_val, TextParam):
375
377
  subschema = find_in_schema(schema_to_override, param_name, "text")
376
378
  subschema["default"] = param_val
379
+ if (
380
+ isinstance(param_val, inspect.Parameter)
381
+ and param_val.annotation is MessagesInput
382
+ ):
383
+ subschema = find_in_schema(schema_to_override, param_name, "messages")
384
+ subschema["default"] = param_val.default
agenta/sdk/types.py CHANGED
@@ -98,6 +98,36 @@ class MultipleChoiceParam(str):
98
98
  )
99
99
 
100
100
 
101
+ class Message(BaseModel):
102
+ role: str
103
+ content: str
104
+
105
+
106
+ class MessagesInput(list):
107
+ """Messages Input for Chat-completion.
108
+
109
+ Parameters:
110
+ messages (List[Dict[str, str]]): The list of messages inputs.
111
+ Required. Each message should be a dictionary with "role" and "content" keys.
112
+
113
+ Raises:
114
+ ValueError: If `messages` is not specified or empty.
115
+
116
+ """
117
+
118
+ def __new__(cls, messages: List[Dict[str, str]] = None):
119
+ if not messages:
120
+ raise ValueError("Missing required parameter in MessagesInput")
121
+
122
+ instance = super().__new__(cls, messages)
123
+ instance.messages = messages
124
+ return instance
125
+
126
+ @classmethod
127
+ def __modify_schema__(cls, field_schema: dict[str, Any]):
128
+ field_schema.update({"x-parameter": "messages", "type": "array"})
129
+
130
+
101
131
  class Context(BaseModel):
102
132
  class Config:
103
133
  extra = Extra.allow
@@ -1,5 +1,7 @@
1
1
  import agenta as ag
2
- import openai
2
+ from openai import OpenAI
3
+
4
+ client = OpenAI()
3
5
  import json
4
6
 
5
7
  default_prompt = """You are a world class algorithm for extracting information in structured formats. Extract information and create a valid JSON from the following input: {text}"""
@@ -40,7 +42,7 @@ def generate(
40
42
 
41
43
  function = json.loads(ag.config.function_json)
42
44
 
43
- response = openai.ChatCompletion.create(
45
+ response = client.chat.completions.create(
44
46
  model="gpt-3.5-turbo-0613",
45
47
  messages=messages,
46
48
  temperature=ag.config.temperature,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: agenta
3
- Version: 0.5.4
3
+ Version: 0.5.6
4
4
  Summary: The SDK for agenta is an open-source LLMOps platform.
5
5
  Home-page: https://agenta.ai
6
6
  Keywords: LLMOps,LLM,evaluation,prompt engineering
@@ -13,6 +13,7 @@ Classifier: Programming Language :: Python :: 3
13
13
  Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
16
17
  Classifier: Topic :: Software Development :: Libraries
17
18
  Requires-Dist: click (>=8.1.3,<9.0.0)
18
19
  Requires-Dist: docker (>=6.1.1,<7.0.0)
@@ -1,25 +1,27 @@
1
- agenta/__init__.py,sha256=g757pwWie2vSuDQHmRqdgOGM2uF1m2t7nrZAYRZGzU0,375
2
- agenta/cli/helper.py,sha256=qHDwZ23bm_gbvulDrlNcCEK3c4fzRycDZ_oJzBglflg,5945
3
- agenta/cli/main.py,sha256=7YAHzSuZP9nF7bQsrXFXLfg1rFDCFZTWQ5lIq--CP4s,6392
1
+ agenta/__init__.py,sha256=grmSigSubGpmopSRm6W3bVVOdVR6tHNfqleJPecESak,394
2
+ agenta/cli/helper.py,sha256=Bexi77D5g9tbFND5Xh7u6KzbqKKD9jdZmiLTbXMCLgY,5928
3
+ agenta/cli/main.py,sha256=Kbt6eUsOrlg3B5_3lwQ0wBirJpAhXvGAFnGYddKlzJI,6393
4
4
  agenta/cli/telemetry.py,sha256=TiI4Nd1F1f1eSrs3fumDhcl8iu56aI4emyaGo5BQwMU,1165
5
- agenta/cli/variant_commands.py,sha256=J1m1jpz82UEIDuK6zRQskRKDsvVWb1rxanJP6I98svs,15919
5
+ agenta/cli/variant_commands.py,sha256=wsY5dD2_3hX6HN2d-f1L4BtbjhvGiiw8rThxy_63A1A,15980
6
6
  agenta/client/Readme.md,sha256=umhMce1Gq_der9pH4M_pP4NQ8rHa3MENJLM9OrdUZ50,131
7
7
  agenta/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  agenta/client/api_models.py,sha256=2mcG6jKAaJFmbxeCppt_5z66UnfrR4Vj3l8CJyTt4aM,599
9
- agenta/client/client.py,sha256=EnnAo53dhD4t4xSm4l29GeYXNXjHGzw7Bb9pLIHthYk,17258
9
+ agenta/client/client.py,sha256=BvILFH-z_atsQW1rnj4-OnwkKO_6loNuErJZhVFJRks,17414
10
10
  agenta/config.py,sha256=toEpBx8PjBC6P_22vLRlyMn0gu-P4CR0qPTgrUMFoiw,630
11
- agenta/config.toml,sha256=un4IS3NUcJczZS2LrjPCOShx8W9aw0XIoabZKfqZAWw,198
11
+ agenta/config.toml,sha256=ptE0P49bwsu3Luyn7OLFmk2buPhj5D-MA-O_ErOGoLg,223
12
+ agenta/docker/docker-assets/Dockerfile.cloud.template,sha256=CwJbCTezOYCGowA-Hh19f85YXgynT89CrWxjNxLJJfg,317
12
13
  agenta/docker/docker-assets/Dockerfile.template,sha256=KMQOmJ0F9zBY-1d5d4FZYIOnoTFGAJgqUwsAnIpDVak,285
13
14
  agenta/docker/docker-assets/README.md,sha256=XHxwh2ks_ozrtAU7SLbL3J14SB2holG6buoTxwmMiZM,102
14
15
  agenta/docker/docker-assets/entrypoint.sh,sha256=29XK8VQjQsx4hN2j-4JDy-6kQb5y4LCqZEa7PD4eqCQ,74
16
+ agenta/docker/docker-assets/lambda_function.py,sha256=h4UZSSfqwpfsCgERv6frqwm_4JrYu9rLz3I-LxCfeEg,83
15
17
  agenta/docker/docker-assets/main.py,sha256=BbmbFByRQ8MzL8402pJryEF34t6ba1i_JrMtWMAQDQ4,327
16
- agenta/docker/docker_utils.py,sha256=SU3Yi867ttx9AxXASfmnhD_GMP8c6f2l9oQ3mIJSSxQ,4939
17
- agenta/sdk/__init__.py,sha256=hvwv4nSQdvGFJBC-OdiFsdtNFdri-y-_MB_QGZh5w9c,451
18
- agenta/sdk/agenta_decorator.py,sha256=rASBH5yQzqc5Bwl9gSpbSiOSFXhSFI4RlLqr4Gys1Kw,13017
18
+ agenta/docker/docker_utils.py,sha256=oK51dmJLUXcR0iEi3knDqt5BZxF3somqWHVOpTQ8rOI,5681
19
+ agenta/sdk/__init__.py,sha256=QgjkiERHsprd59qx1bYOKD21DSQr3Bftetfgozdoe7I,470
20
+ agenta/sdk/agenta_decorator.py,sha256=psRjROXtus2huHNOeGWvf-4Nnig5EEaJKEFCOXnEIJI,13354
19
21
  agenta/sdk/agenta_init.py,sha256=3-0WRpRSveWUcLhosTuym-YKV9gKVNrOTxGjSa6SxyI,7152
20
22
  agenta/sdk/context.py,sha256=q-PxL05-I84puunUAs9LGsffEXcYhDxhQxjuOz2vK90,901
21
23
  agenta/sdk/router.py,sha256=0sbajvn5C7t18anH6yNo7-oYxldHnYfwcbmQnIXBePw,269
22
- agenta/sdk/types.py,sha256=ZXtkmRnCCpu-Xvd6goMaqyyeRsBAewe8zQfoouF3jyA,3113
24
+ agenta/sdk/types.py,sha256=ep2ls42AxEIBcb0_NJVwDw2isNHFX_BNFBbom2ogP2w,3929
23
25
  agenta/sdk/utils/globals.py,sha256=lpgflY8xovZJtHfJf41dbNCZGwx07YNkG9ldruv6xoI,360
24
26
  agenta/sdk/utils/preinit.py,sha256=YlJL7RLfel0R7DFp-jK7OV-z4ZIQJM0oupYlk7g8b5o,1278
25
27
  agenta/templates/compose_email/README.md,sha256=ss7vZPpI1Hg0VmYtFliwq_r5LnqbCy_S5OQDXg8UoIA,308
@@ -28,7 +30,7 @@ agenta/templates/compose_email/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHT
28
30
  agenta/templates/compose_email/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
29
31
  agenta/templates/compose_email/template.toml,sha256=H0y1i4t-gHgc-dbiTWcf3QiMAOU92MgkY_V9x3Tob-E,47
30
32
  agenta/templates/extract_data_to_json/README.md,sha256=ss7vZPpI1Hg0VmYtFliwq_r5LnqbCy_S5OQDXg8UoIA,308
31
- agenta/templates/extract_data_to_json/app.py,sha256=FpPSXBwmd9qntRfUnMs2NX_-Ub4HsHYGm1JFHrOzFh8,1287
33
+ agenta/templates/extract_data_to_json/app.py,sha256=xNm9Gs2LzLujm1ox-T1Cn0JkU2tmYPqhwuAR9HnHa9Y,1320
32
34
  agenta/templates/extract_data_to_json/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
33
35
  agenta/templates/extract_data_to_json/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
34
36
  agenta/templates/extract_data_to_json/template.toml,sha256=5TpnTRmvHbIzANevDCCHc8AOJXL431TN2sBor6tosUY,60
@@ -37,7 +39,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
37
39
  agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
38
40
  agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
39
41
  agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
40
- agenta-0.5.4.dist-info/METADATA,sha256=gMf_vlP5nHTQ9dDbBUCoDBAIIOLGaQLWXB1V08B1kY4,10042
41
- agenta-0.5.4.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
42
- agenta-0.5.4.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
43
- agenta-0.5.4.dist-info/RECORD,,
42
+ agenta-0.5.6.dist-info/METADATA,sha256=ksRDmWD5pBVSMihSvOmv9lVlYoccoYB0QaTUOWJMcIo,10093
43
+ agenta-0.5.6.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
44
+ agenta-0.5.6.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
45
+ agenta-0.5.6.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.7.0
2
+ Generator: poetry-core 1.8.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any