agenta 0.5.4__tar.gz → 0.5.6__tar.gz
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-0.5.4 → agenta-0.5.6}/PKG-INFO +2 -1
- {agenta-0.5.4 → agenta-0.5.6}/agenta/__init__.py +1 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/cli/helper.py +11 -10
- {agenta-0.5.4 → agenta-0.5.6}/agenta/cli/main.py +2 -2
- {agenta-0.5.4 → agenta-0.5.6}/agenta/cli/variant_commands.py +3 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/client/client.py +5 -1
- {agenta-0.5.4 → agenta-0.5.6}/agenta/config.toml +1 -1
- agenta-0.5.6/agenta/docker/docker-assets/Dockerfile.cloud.template +8 -0
- agenta-0.5.6/agenta/docker/docker-assets/lambda_function.py +6 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/docker/docker_utils.py +22 -1
- {agenta-0.5.4 → agenta-0.5.6}/agenta/sdk/__init__.py +1 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/sdk/agenta_decorator.py +8 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/sdk/types.py +30 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/extract_data_to_json/app.py +4 -2
- {agenta-0.5.4 → agenta-0.5.6}/pyproject.toml +1 -1
- {agenta-0.5.4 → agenta-0.5.6}/README.md +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/cli/telemetry.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/client/Readme.md +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/client/__init__.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/client/api_models.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/config.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/docker/docker-assets/Dockerfile.template +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/docker/docker-assets/README.md +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/docker/docker-assets/entrypoint.sh +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/docker/docker-assets/main.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/sdk/agenta_init.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/sdk/context.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/sdk/router.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/sdk/utils/globals.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/sdk/utils/preinit.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/compose_email/README.md +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/compose_email/app.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/compose_email/env.example +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/compose_email/requirements.txt +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/compose_email/template.toml +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/extract_data_to_json/README.md +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/extract_data_to_json/env.example +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/extract_data_to_json/template.toml +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/simple_prompt/README.md +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/simple_prompt/app.py +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/simple_prompt/env.example +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/simple_prompt/requirements.txt +0 -0
- {agenta-0.5.4 → agenta-0.5.6}/agenta/templates/simple_prompt/template.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: agenta
|
|
3
|
-
Version: 0.5.
|
|
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)
|
|
@@ -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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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:
|
|
@@ -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
|
|
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://
|
|
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:
|
|
@@ -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
|
|
|
@@ -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://
|
|
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" ]
|
|
@@ -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
|
-
|
|
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
|
|
@@ -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
|
|
@@ -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
|
|
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 =
|
|
45
|
+
response = client.chat.completions.create(
|
|
44
46
|
model="gpt-3.5-turbo-0613",
|
|
45
47
|
messages=messages,
|
|
46
48
|
temperature=ag.config.temperature,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|