agenta 0.14.7__tar.gz → 0.14.7a1__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.14.7 → agenta-0.14.7a1}/PKG-INFO +2 -1
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/__init__.py +1 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/__init__.py +1 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/agenta_decorator.py +22 -8
- agenta-0.14.7a1/agenta/sdk/tracing/callbacks.py +129 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/tracing/llm_tracing.py +37 -10
- {agenta-0.14.7 → agenta-0.14.7a1}/pyproject.toml +2 -1
- {agenta-0.14.7 → agenta-0.14.7a1}/README.md +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/cli/evaluation_commands.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/cli/helper.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/cli/main.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/cli/telemetry.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/cli/variant_commands.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/cli/variant_configs.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/Readme.md +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/api.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/api_models.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/core/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/core/api_error.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/core/client_wrapper.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/core/datetime_utils.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/core/jsonable_encoder.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/core/remove_none_from_dict.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/errors/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/errors/unprocessable_entity_error.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/apps/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/apps/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/bases/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/bases/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/configs/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/configs/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/containers/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/containers/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/containers/types/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/containers/types/container_templates_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/environments/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/environments/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/evaluations/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/evaluations/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/evaluators/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/evaluators/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/observability/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/observability/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/testsets/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/testsets/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/variants/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/variants/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/variants/types/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/variants/types/add_variant_from_base_and_config_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/__init__.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/aggregated_result.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/aggregated_result_evaluator_config.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/app.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/app_variant_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/app_variant_revision.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/base_output.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/body_import_testset.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/config_db.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/create_app_output.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/create_span.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/create_trace_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/docker_env_vars.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/environment_output.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/environment_output_extended.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/environment_revision.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/error.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation_scenario.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation_scenario_input.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation_scenario_output.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation_scenario_result.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation_scenario_score_update.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation_status_enum.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation_type.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation_webhook.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluator.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluator_config.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/feedback.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/get_config_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/http_validation_error.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/human_evaluation.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/human_evaluation_scenario.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/human_evaluation_scenario_input.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/human_evaluation_scenario_output.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/human_evaluation_scenario_update.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/human_evaluation_update.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/image.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/invite_request.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/list_api_keys_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/llm_run_rate_limit.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/llm_tokens.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/new_human_evaluation.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/new_testset.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/organization.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/organization_output.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/permission.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/result.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/score.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/simple_evaluation_output.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/span.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/span_detail.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/span_kind.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/span_status_code.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/span_variant.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/template.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/template_image_info.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/test_set_output_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/test_set_simple_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/trace_detail.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/uri.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/validation_error.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/validation_error_loc_item.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/variant_action.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/variant_action_enum.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/with_pagination.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/workspace_member_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/workspace_permission.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/workspace_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/workspace_role.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/workspace_role_response.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/exceptions.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/config.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/config.toml +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/docker/docker-assets/Dockerfile.cloud.template +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/docker/docker-assets/Dockerfile.template +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/docker/docker-assets/README.md +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/docker/docker-assets/entrypoint.sh +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/docker/docker-assets/lambda_function.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/docker/docker-assets/main.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/docker/docker_utils.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/agenta_init.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/client.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/context.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/router.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/tracing/context_manager.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/tracing/decorators.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/tracing/logger.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/tracing/tasks_manager.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/types.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/utils/globals.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/utils/helper/openai_cost.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/sdk/utils/preinit.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/compose_email/README.md +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/compose_email/app.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/compose_email/env.example +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/compose_email/requirements.txt +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/compose_email/template.toml +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/extract_data_to_json/README.md +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/extract_data_to_json/app.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/extract_data_to_json/env.example +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/extract_data_to_json/requirements.txt +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/extract_data_to_json/template.toml +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/simple_prompt/README.md +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/simple_prompt/app.py +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/simple_prompt/env.example +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/agenta/templates/simple_prompt/requirements.txt +0 -0
- {agenta-0.14.7 → agenta-0.14.7a1}/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.14.
|
|
3
|
+
Version: 0.14.7a1
|
|
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
|
|
@@ -22,6 +22,7 @@ Requires-Dist: fastapi (>=0.96.1)
|
|
|
22
22
|
Requires-Dist: httpx (>=0.24,<0.28)
|
|
23
23
|
Requires-Dist: importlib-metadata (>=6.7.0,<7.0.0)
|
|
24
24
|
Requires-Dist: ipdb (>=0.13)
|
|
25
|
+
Requires-Dist: litellm (>=1.35.33,<2.0.0)
|
|
25
26
|
Requires-Dist: posthog (>=3.1.0,<4.0.0)
|
|
26
27
|
Requires-Dist: pydantic (==1.10.13)
|
|
27
28
|
Requires-Dist: pymongo (>=4.6.3,<5.0.0)
|
|
@@ -16,6 +16,7 @@ from .sdk.types import (
|
|
|
16
16
|
)
|
|
17
17
|
from .sdk.tracing.decorators import span
|
|
18
18
|
from .sdk.agenta_init import Config, init, llm_tracing
|
|
19
|
+
from .sdk.tracing.callbacks import agenta_litellm_handler
|
|
19
20
|
from .sdk.utils.helper.openai_cost import calculate_token_usage
|
|
20
21
|
from .sdk.client import Agenta
|
|
21
22
|
|
|
@@ -17,6 +17,7 @@ from fastapi import Body, FastAPI, UploadFile, HTTPException
|
|
|
17
17
|
|
|
18
18
|
import agenta
|
|
19
19
|
from .context import save_context
|
|
20
|
+
from .tracing.llm_tracing import Tracing
|
|
20
21
|
from .router import router as router
|
|
21
22
|
from .types import (
|
|
22
23
|
Context,
|
|
@@ -155,10 +156,7 @@ def entrypoint(func: Callable[..., Any]) -> Callable[..., Any]:
|
|
|
155
156
|
|
|
156
157
|
if is_main_script(func):
|
|
157
158
|
handle_terminal_run(
|
|
158
|
-
func,
|
|
159
|
-
func_signature.parameters,
|
|
160
|
-
config_params,
|
|
161
|
-
ingestible_files,
|
|
159
|
+
func, func_signature.parameters, config_params, ingestible_files, tracing
|
|
162
160
|
)
|
|
163
161
|
return None
|
|
164
162
|
|
|
@@ -350,6 +348,7 @@ def handle_terminal_run(
|
|
|
350
348
|
func_params: Dict[str, Any],
|
|
351
349
|
config_params: Dict[str, Any],
|
|
352
350
|
ingestible_files: Dict,
|
|
351
|
+
tracing: Tracing,
|
|
353
352
|
) -> None:
|
|
354
353
|
"""
|
|
355
354
|
Parses command line arguments and sets configuration when script is run from the terminal.
|
|
@@ -357,9 +356,8 @@ def handle_terminal_run(
|
|
|
357
356
|
Args:
|
|
358
357
|
func_params (dict): A dictionary containing the function parameters and their annotations.
|
|
359
358
|
config_params (dict): A dictionary containing the configuration parameters.
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
handle_terminal_run(func_params=inspect.signature(my_function).parameters, config_params=config.all())
|
|
359
|
+
ingestible_files (dict): A dictionary containing the files that should be ingested.
|
|
360
|
+
tracing (Tracing): The tracing object
|
|
363
361
|
"""
|
|
364
362
|
|
|
365
363
|
# For required parameters, we add them as arguments
|
|
@@ -398,13 +396,29 @@ def handle_terminal_run(
|
|
|
398
396
|
)
|
|
399
397
|
agenta.config.set(**args_config_params)
|
|
400
398
|
|
|
399
|
+
# Start tracing
|
|
400
|
+
tracing.start_parent_span(
|
|
401
|
+
name=func.__name__,
|
|
402
|
+
inputs=args_func_params,
|
|
403
|
+
config=args_config_params,
|
|
404
|
+
environment="shell", # type: ignore
|
|
405
|
+
)
|
|
406
|
+
|
|
401
407
|
loop = asyncio.get_event_loop()
|
|
402
408
|
result = loop.run_until_complete(
|
|
403
409
|
execute_function(
|
|
404
410
|
func, **{"params": args_func_params, "config_params": args_config_params}
|
|
405
411
|
)
|
|
406
412
|
)
|
|
407
|
-
|
|
413
|
+
|
|
414
|
+
# End trace recording
|
|
415
|
+
tracing.end_recording(
|
|
416
|
+
outputs=result.dict(),
|
|
417
|
+
span=tracing.active_trace, # type: ignore
|
|
418
|
+
)
|
|
419
|
+
print(
|
|
420
|
+
f"\n========== Result ==========\n\nMessage: {result.message}\nCost: {result.cost}\nToken Usage: {result.usage}"
|
|
421
|
+
)
|
|
408
422
|
|
|
409
423
|
|
|
410
424
|
def override_schema(openapi_schema: dict, func_name: str, endpoint: str, params: dict):
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
# Own Imports
|
|
2
|
+
from agenta.sdk import llm_tracing
|
|
3
|
+
|
|
4
|
+
# Third Party Imports
|
|
5
|
+
from litellm.utils import ModelResponse
|
|
6
|
+
from litellm.integrations.custom_logger import CustomLogger as LitellmCustomLogger
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class AgentaLiteLLMHandler(LitellmCustomLogger):
|
|
10
|
+
"""This handler is responsible for logging certain events when using litellm to call LLMs.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
LitellmCustomLogger (object): custom logger that allows us to override the events to capture.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def _trace(self):
|
|
18
|
+
return llm_tracing()
|
|
19
|
+
|
|
20
|
+
def log_pre_api_call(self, model, messages, kwargs):
|
|
21
|
+
self._trace.start_span(
|
|
22
|
+
name="pre_api_call",
|
|
23
|
+
input=(
|
|
24
|
+
{"messages": messages}
|
|
25
|
+
if isinstance(messages, list)
|
|
26
|
+
else {"inputs": messages}
|
|
27
|
+
),
|
|
28
|
+
spankind=(
|
|
29
|
+
"llm"
|
|
30
|
+
if kwargs.get("call_type") in ["completion", "acompletion"]
|
|
31
|
+
else (
|
|
32
|
+
"embedding"
|
|
33
|
+
if kwargs.get("call_type") in ["embedding", "aembedding"]
|
|
34
|
+
else "unset"
|
|
35
|
+
)
|
|
36
|
+
),
|
|
37
|
+
)
|
|
38
|
+
self._trace.set_span_attribute(
|
|
39
|
+
"model_config",
|
|
40
|
+
{
|
|
41
|
+
"model": kwargs.get("model"),
|
|
42
|
+
"temperature": kwargs["optional_params"]["temperature"],
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
def log_stream_event(self, kwargs, response_obj, start_time, end_time):
|
|
47
|
+
self._trace.update_span_status(span=self._trace.active_span, value="OK")
|
|
48
|
+
self._trace.end_span(
|
|
49
|
+
outputs={
|
|
50
|
+
"message": kwargs("complete_streaming_response"),
|
|
51
|
+
"usage": kwargs.get("usage"),
|
|
52
|
+
"cost": kwargs.get("response_cost"),
|
|
53
|
+
},
|
|
54
|
+
span=self._trace.active_span,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
def log_success_event(
|
|
58
|
+
self, kwargs, response_obj: ModelResponse, start_time, end_time
|
|
59
|
+
):
|
|
60
|
+
self._trace.update_span_status(span=self._trace.active_span, value="OK")
|
|
61
|
+
self._trace.end_span(
|
|
62
|
+
outputs={
|
|
63
|
+
"message": kwargs["message"],
|
|
64
|
+
"usage": kwargs.get("usage"),
|
|
65
|
+
"cost": kwargs.get("response_cost"),
|
|
66
|
+
},
|
|
67
|
+
span=self._trace.active_span,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
def log_failure_event(
|
|
71
|
+
self, kwargs, response_obj: ModelResponse, start_time, end_time
|
|
72
|
+
):
|
|
73
|
+
self._trace.update_span_status(span=self._trace.active_span, value="ERROR")
|
|
74
|
+
self._trace.set_span_attribute(
|
|
75
|
+
attributes={
|
|
76
|
+
"traceback_exception": kwargs["traceback_exception"],
|
|
77
|
+
"call_end_time": kwargs["end_time"],
|
|
78
|
+
},
|
|
79
|
+
)
|
|
80
|
+
self._trace.end_span(
|
|
81
|
+
outputs={
|
|
82
|
+
"message": kwargs["exception"],
|
|
83
|
+
"usage": kwargs.get("usage"),
|
|
84
|
+
"cost": kwargs.get("response_cost"),
|
|
85
|
+
},
|
|
86
|
+
span=self._trace.active_span,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
async def async_log_stream_event(self, kwargs, response_obj, start_time, end_time):
|
|
90
|
+
self._trace.update_span_status(span=self._trace.active_span, value="OK")
|
|
91
|
+
self._trace.end_span(
|
|
92
|
+
outputs={
|
|
93
|
+
"message": kwargs("complete_streaming_response"),
|
|
94
|
+
"usage": kwargs.get("usage"),
|
|
95
|
+
"cost": kwargs.get("response_cost"),
|
|
96
|
+
},
|
|
97
|
+
span=self._trace.active_span,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
async def async_log_success_event(self, kwargs, response_obj, start_time, end_time):
|
|
101
|
+
self._trace.update_span_status(span=self._trace.active_span, value="OK")
|
|
102
|
+
self._trace.end_span(
|
|
103
|
+
outputs={
|
|
104
|
+
"message": kwargs["message"],
|
|
105
|
+
"usage": kwargs.get("usage"),
|
|
106
|
+
"cost": kwargs.get("response_cost"),
|
|
107
|
+
},
|
|
108
|
+
span=self._trace.active_span,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
async def async_log_failure_event(self, kwargs, response_obj, start_time, end_time):
|
|
112
|
+
self._trace.update_span_status(span=self._trace.active_span, value="ERROR")
|
|
113
|
+
self._trace.set_span_attribute(
|
|
114
|
+
attributes={
|
|
115
|
+
"traceback_exception": kwargs["traceback_exception"],
|
|
116
|
+
"call_end_time": kwargs["end_time"],
|
|
117
|
+
},
|
|
118
|
+
)
|
|
119
|
+
self._trace.end_span(
|
|
120
|
+
outputs={
|
|
121
|
+
"message": kwargs["exception"],
|
|
122
|
+
"usage": kwargs.get("usage"),
|
|
123
|
+
"cost": kwargs.get("response_cost"),
|
|
124
|
+
},
|
|
125
|
+
span=self._trace.active_span,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
agenta_litellm_handler = AgentaLiteLLMHandler()
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Stdlib Imports
|
|
2
|
+
from threading import Lock
|
|
2
3
|
from datetime import datetime, timezone
|
|
3
4
|
from typing import Optional, Dict, Any, List, Union
|
|
4
5
|
|
|
@@ -13,10 +14,43 @@ from agenta.client.backend.types.create_span import CreateSpan, SpanKind, SpanSt
|
|
|
13
14
|
from bson.objectid import ObjectId
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
class
|
|
17
|
-
"""
|
|
17
|
+
class SingletonMeta(type):
|
|
18
|
+
"""
|
|
19
|
+
Thread-safe implementation of Singleton.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
_instances = {}
|
|
23
|
+
|
|
24
|
+
# We need the lock mechanism to synchronize threads \
|
|
25
|
+
# during the initial access to the Singleton object.
|
|
26
|
+
_lock: Lock = Lock()
|
|
18
27
|
|
|
19
|
-
|
|
28
|
+
def __call__(cls, *args, **kwargs):
|
|
29
|
+
"""
|
|
30
|
+
Possible changes to the value of the `__init__` argument do not affect
|
|
31
|
+
the returned instance.
|
|
32
|
+
"""
|
|
33
|
+
# Now, imagine that the program has just been launched. Since there's no
|
|
34
|
+
# Singleton instance yet, multiple threads can simultaneously pass the
|
|
35
|
+
# previous conditional and reach this point almost at the same time. The
|
|
36
|
+
# first of them will acquire lock and will proceed further, while the
|
|
37
|
+
# rest will wait here.
|
|
38
|
+
with cls._lock:
|
|
39
|
+
# The first thread to acquire the lock, reaches this conditional,
|
|
40
|
+
# goes inside and creates the Singleton instance. Once it leaves the
|
|
41
|
+
# lock block, a thread that might have been waiting for the lock
|
|
42
|
+
# release may then enter this section. But since the Singleton field
|
|
43
|
+
# is already initialized, the thread won't create a new object.
|
|
44
|
+
if cls not in cls._instances:
|
|
45
|
+
instance = super().__call__(*args, **kwargs)
|
|
46
|
+
cls._instances[cls] = instance
|
|
47
|
+
return cls._instances[cls]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class Tracing(metaclass=SingletonMeta):
|
|
51
|
+
"""The `Tracing` class is an agent for LLM tracing with specific initialization arguments.
|
|
52
|
+
|
|
53
|
+
__init__ args:
|
|
20
54
|
base_url (str): The URL of the backend host
|
|
21
55
|
api_key (str): The API Key of the backend host
|
|
22
56
|
tasks_manager (TaskQueue): The tasks manager dedicated to handling asynchronous tasks
|
|
@@ -24,13 +58,6 @@ class Tracing(object):
|
|
|
24
58
|
max_workers (int): The maximum number of workers to run tracing
|
|
25
59
|
"""
|
|
26
60
|
|
|
27
|
-
_instance = None
|
|
28
|
-
|
|
29
|
-
def __new__(cls, *args, **kwargs):
|
|
30
|
-
if not cls._instance:
|
|
31
|
-
cls._instance = super().__new__(cls)
|
|
32
|
-
return cls._instance
|
|
33
|
-
|
|
34
61
|
def __init__(
|
|
35
62
|
self,
|
|
36
63
|
base_url: str,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "agenta"
|
|
3
|
-
version = "0.14.
|
|
3
|
+
version = "0.14.7a1"
|
|
4
4
|
description = "The SDK for agenta is an open-source LLMOps platform."
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = ["Mahmoud Mabrouk <mahmoud@agenta.ai>"]
|
|
@@ -30,6 +30,7 @@ posthog = "^3.1.0"
|
|
|
30
30
|
pydantic = "1.10.13"
|
|
31
31
|
httpx = ">=0.24, <0.28"
|
|
32
32
|
pymongo = "^4.6.3"
|
|
33
|
+
litellm = "^1.35.33"
|
|
33
34
|
cachetools = "^5.3.3"
|
|
34
35
|
|
|
35
36
|
[tool.poetry.dev-dependencies]
|
|
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
|
{agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/errors/unprocessable_entity_error.py
RENAMED
|
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
|
{agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/containers/types/__init__.py
RENAMED
|
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
|
{agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/resources/variants/types/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/aggregated_result_evaluator_config.py
RENAMED
|
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
|
{agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/environment_output_extended.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/evaluation_scenario_score_update.py
RENAMED
|
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
|
{agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/human_evaluation_scenario_input.py
RENAMED
|
File without changes
|
{agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/human_evaluation_scenario_output.py
RENAMED
|
File without changes
|
{agenta-0.14.7 → agenta-0.14.7a1}/agenta/client/backend/types/human_evaluation_scenario_update.py
RENAMED
|
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
|
|
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
|
|
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
|