agenta 0.5.5__py3-none-any.whl → 0.5.7__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
@@ -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:
@@ -18,6 +18,7 @@ class Variant(BaseModel):
18
18
 
19
19
 
20
20
  class Image(BaseModel):
21
+ type: Optional[str]
21
22
  docker_id: str
22
23
  tags: str
23
24
 
@@ -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.
@@ -47,7 +49,7 @@ def build_tar_docker_container(folder: Path, file_name: Path) -> Path:
47
49
  if tarfile_path.exists():
48
50
  tarfile_path.unlink()
49
51
 
50
- dockerfile_path = create_dockerfile(folder)
52
+ create_dockerfile(folder)
51
53
  shutil.copytree(Path(__file__).parent.parent, folder / "agenta", dirs_exist_ok=True)
52
54
  shutil.copy(Path(__file__).parent / "docker-assets" / "main.py", folder)
53
55
  shutil.copy(Path(__file__).parent / "docker-assets" / "lambda_function.py", folder)
@@ -82,6 +84,18 @@ def build_tar_docker_container(folder: Path, file_name: Path) -> Path:
82
84
  # Create the tar.gz file
83
85
  with tarfile.open(tarfile_path, "w:gz") as tar:
84
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()
85
99
 
86
100
  # dockerfile_path.unlink()
87
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.5
3
+ Version: 0.5.7
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,11 +1,11 @@
1
- agenta/__init__.py,sha256=g757pwWie2vSuDQHmRqdgOGM2uF1m2t7nrZAYRZGzU0,375
1
+ agenta/__init__.py,sha256=grmSigSubGpmopSRm6W3bVVOdVR6tHNfqleJPecESak,394
2
2
  agenta/cli/helper.py,sha256=Bexi77D5g9tbFND5Xh7u6KzbqKKD9jdZmiLTbXMCLgY,5928
3
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
- agenta/client/api_models.py,sha256=2mcG6jKAaJFmbxeCppt_5z66UnfrR4Vj3l8CJyTt4aM,599
8
+ agenta/client/api_models.py,sha256=zebfE2-0-SW1SvzyarzmSJMXqyiCLKrX2sHpzoX-RnU,623
9
9
  agenta/client/client.py,sha256=BvILFH-z_atsQW1rnj4-OnwkKO_6loNuErJZhVFJRks,17414
10
10
  agenta/config.py,sha256=toEpBx8PjBC6P_22vLRlyMn0gu-P4CR0qPTgrUMFoiw,630
11
11
  agenta/config.toml,sha256=ptE0P49bwsu3Luyn7OLFmk2buPhj5D-MA-O_ErOGoLg,223
@@ -15,13 +15,13 @@ agenta/docker/docker-assets/README.md,sha256=XHxwh2ks_ozrtAU7SLbL3J14SB2holG6buo
15
15
  agenta/docker/docker-assets/entrypoint.sh,sha256=29XK8VQjQsx4hN2j-4JDy-6kQb5y4LCqZEa7PD4eqCQ,74
16
16
  agenta/docker/docker-assets/lambda_function.py,sha256=h4UZSSfqwpfsCgERv6frqwm_4JrYu9rLz3I-LxCfeEg,83
17
17
  agenta/docker/docker-assets/main.py,sha256=BbmbFByRQ8MzL8402pJryEF34t6ba1i_JrMtWMAQDQ4,327
18
- agenta/docker/docker_utils.py,sha256=viOYUpra2uknJGE6DKj6AV79n1mrmKFerwK9KBI7vmM,5248
19
- agenta/sdk/__init__.py,sha256=hvwv4nSQdvGFJBC-OdiFsdtNFdri-y-_MB_QGZh5w9c,451
20
- 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
21
21
  agenta/sdk/agenta_init.py,sha256=3-0WRpRSveWUcLhosTuym-YKV9gKVNrOTxGjSa6SxyI,7152
22
22
  agenta/sdk/context.py,sha256=q-PxL05-I84puunUAs9LGsffEXcYhDxhQxjuOz2vK90,901
23
23
  agenta/sdk/router.py,sha256=0sbajvn5C7t18anH6yNo7-oYxldHnYfwcbmQnIXBePw,269
24
- agenta/sdk/types.py,sha256=ZXtkmRnCCpu-Xvd6goMaqyyeRsBAewe8zQfoouF3jyA,3113
24
+ agenta/sdk/types.py,sha256=ep2ls42AxEIBcb0_NJVwDw2isNHFX_BNFBbom2ogP2w,3929
25
25
  agenta/sdk/utils/globals.py,sha256=lpgflY8xovZJtHfJf41dbNCZGwx07YNkG9ldruv6xoI,360
26
26
  agenta/sdk/utils/preinit.py,sha256=YlJL7RLfel0R7DFp-jK7OV-z4ZIQJM0oupYlk7g8b5o,1278
27
27
  agenta/templates/compose_email/README.md,sha256=ss7vZPpI1Hg0VmYtFliwq_r5LnqbCy_S5OQDXg8UoIA,308
@@ -30,7 +30,7 @@ agenta/templates/compose_email/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHT
30
30
  agenta/templates/compose_email/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
31
31
  agenta/templates/compose_email/template.toml,sha256=H0y1i4t-gHgc-dbiTWcf3QiMAOU92MgkY_V9x3Tob-E,47
32
32
  agenta/templates/extract_data_to_json/README.md,sha256=ss7vZPpI1Hg0VmYtFliwq_r5LnqbCy_S5OQDXg8UoIA,308
33
- 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
34
34
  agenta/templates/extract_data_to_json/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
35
35
  agenta/templates/extract_data_to_json/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
36
36
  agenta/templates/extract_data_to_json/template.toml,sha256=5TpnTRmvHbIzANevDCCHc8AOJXL431TN2sBor6tosUY,60
@@ -39,7 +39,7 @@ agenta/templates/simple_prompt/app.py,sha256=kODgF6lhzsaJPdgL5b21bUki6jkvqjWZzWR
39
39
  agenta/templates/simple_prompt/env.example,sha256=g9AE5bYcGPpxawXMJ96gh8oenEPCHTabsiOnfQo3c5k,70
40
40
  agenta/templates/simple_prompt/requirements.txt,sha256=ywRglRy7pPkw8bljmMEJJ4aOOQKrt9FGKULZ-DGkoBU,23
41
41
  agenta/templates/simple_prompt/template.toml,sha256=DQBtRrF4GU8LBEXOZ-GGuINXMQDKGTEG5y37tnvIUIE,60
42
- agenta-0.5.5.dist-info/METADATA,sha256=nPag6mukqc005Qa6-bUysS00I02trU9qcLvOKBlyPeA,10042
43
- agenta-0.5.5.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
44
- agenta-0.5.5.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
45
- agenta-0.5.5.dist-info/RECORD,,
42
+ agenta-0.5.7.dist-info/METADATA,sha256=j9igj6WwUZ0uVXOKgcZTqrY12jneFGdMIlToYV1m4WQ,10093
43
+ agenta-0.5.7.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
44
+ agenta-0.5.7.dist-info/entry_points.txt,sha256=PDiu8_8AsL7ibU9v4iNoOKR1S7F2rdxjlEprjM9QOgo,46
45
+ agenta-0.5.7.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