aiqtoolkit 1.2.0a20250528__py3-none-any.whl → 1.2.0a20250529__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 aiqtoolkit might be problematic. Click here for more details.

@@ -14,6 +14,7 @@
14
14
  # limitations under the License.
15
15
 
16
16
  import logging
17
+ import os
17
18
 
18
19
  from pydantic import Field
19
20
 
@@ -22,6 +23,7 @@ from aiq.cli.register_workflow import register_logging_method
22
23
  from aiq.cli.register_workflow import register_telemetry_exporter
23
24
  from aiq.data_models.logging import LoggingBaseConfig
24
25
  from aiq.data_models.telemetry_exporter import TelemetryExporterBaseConfig
26
+ from aiq.utils.optional_imports import telemetry_optional_import
25
27
  from aiq.utils.optional_imports import try_import_opentelemetry
26
28
  from aiq.utils.optional_imports import try_import_phoenix
27
29
 
@@ -42,11 +44,67 @@ async def phoenix_telemetry_exporter(config: PhoenixTelemetryExporter, builder:
42
44
  # If the dependencies are not installed, a TelemetryOptionalImportError will be raised
43
45
  phoenix = try_import_phoenix() # noqa: F841
44
46
  from phoenix.otel import HTTPSpanExporter
47
+
45
48
  yield HTTPSpanExporter(config.endpoint)
46
49
  except ConnectionError as ex:
47
- logger.warning("Unable to connect to Phoenix at port 6006. Are you sure Phoenix is running?\n %s",
48
- ex,
49
- exc_info=True)
50
+ logger.warning(
51
+ "Unable to connect to Phoenix at port 6006. Are you sure Phoenix is running?\n %s",
52
+ ex,
53
+ exc_info=True,
54
+ )
55
+
56
+
57
+ class LangfuseTelemetryExporter(TelemetryExporterBaseConfig, name="langfuse"):
58
+ """A telemetry exporter to transmit traces to externally hosted langfuse service."""
59
+
60
+ endpoint: str = Field(description="The langfuse OTEL endpoint (/api/public/otel/v1/traces)")
61
+ public_key: str = Field(description="The Langfuse public key", default="")
62
+ secret_key: str = Field(description="The Langfuse secret key", default="")
63
+
64
+
65
+ @register_telemetry_exporter(config_type=LangfuseTelemetryExporter)
66
+ async def langfuse_telemetry_exporter(config: LangfuseTelemetryExporter, builder: Builder):
67
+ """Create a Langfuse telemetry exporter."""
68
+
69
+ import base64
70
+
71
+ trace_exporter = telemetry_optional_import("opentelemetry.exporter.otlp.proto.http.trace_exporter")
72
+
73
+ secret_key = config.secret_key or os.environ.get("LANGFUSE_SECRET_KEY")
74
+ public_key = config.public_key or os.environ.get("LANGFUSE_PUBLIC_KEY")
75
+ if not secret_key or not public_key:
76
+ raise ValueError("secret and public keys are required for langfuse")
77
+
78
+ credentials = f"{public_key}:{secret_key}".encode("utf-8")
79
+ auth_header = base64.b64encode(credentials).decode("utf-8")
80
+ headers = {"Authorization": f"Basic {auth_header}"}
81
+
82
+ yield trace_exporter.OTLPSpanExporter(endpoint=config.endpoint, headers=headers)
83
+
84
+
85
+ class LangsmithTelemetryExporter(TelemetryExporterBaseConfig, name="langsmith"):
86
+ """A telemetry exporter to transmit traces to externally hosted langsmith service."""
87
+
88
+ endpoint: str = Field(
89
+ description="The langsmith OTEL endpoint",
90
+ default="https://api.smith.langchain.com/otel/v1/traces",
91
+ )
92
+ api_key: str = Field(description="The Langsmith API key", default="")
93
+ project: str = Field(description="The project name to group the telemetry traces.")
94
+
95
+
96
+ @register_telemetry_exporter(config_type=LangsmithTelemetryExporter)
97
+ async def langsmith_telemetry_exporter(config: LangsmithTelemetryExporter, builder: Builder):
98
+ """Create a Langsmith telemetry exporter."""
99
+
100
+ trace_exporter = telemetry_optional_import("opentelemetry.exporter.otlp.proto.http.trace_exporter")
101
+
102
+ api_key = config.api_key or os.environ.get("LANGSMITH_API_KEY")
103
+ if not api_key:
104
+ raise ValueError("API key is required for langsmith")
105
+
106
+ headers = {"x-api-key": api_key, "LANGSMITH_PROJECT": config.project}
107
+ yield trace_exporter.OTLPSpanExporter(endpoint=config.endpoint, headers=headers)
50
108
 
51
109
 
52
110
  class OtelCollectorTelemetryExporter(TelemetryExporterBaseConfig, name="otelcollector"):
@@ -73,8 +131,8 @@ class ConsoleLoggingMethod(LoggingBaseConfig, name="console"):
73
131
  @register_logging_method(config_type=ConsoleLoggingMethod)
74
132
  async def console_logging_method(config: ConsoleLoggingMethod, builder: Builder):
75
133
  """
76
- Build and return a StreamHandler for console-based logging.
77
- """
134
+ Build and return a StreamHandler for console-based logging.
135
+ """
78
136
  level = getattr(logging, config.level.upper(), logging.INFO)
79
137
  handler = logging.StreamHandler()
80
138
  handler.setLevel(level)
@@ -91,8 +149,8 @@ class FileLoggingMethod(LoggingBaseConfig, name="file"):
91
149
  @register_logging_method(config_type=FileLoggingMethod)
92
150
  async def file_logging_method(config: FileLoggingMethod, builder: Builder):
93
151
  """
94
- Build and return a FileHandler for file-based logging.
95
- """
152
+ Build and return a FileHandler for file-based logging.
153
+ """
96
154
  level = getattr(logging, config.level.upper(), logging.INFO)
97
155
  handler = logging.FileHandler(filename=config.path, mode="a", encoding="utf-8")
98
156
  handler.setLevel(level)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiqtoolkit
3
- Version: 1.2.0a20250528
3
+ Version: 1.2.0a20250529
4
4
  Summary: NVIDIA Agent Intelligence toolkit
5
5
  Author: NVIDIA Corporation
6
6
  Maintainer: NVIDIA Corporation
@@ -174,7 +174,7 @@ aiq/meta/module_to_distro.json,sha256=1XV7edobFrdDKvsSoynfodXg_hczUWpDrQzGkW9qqE
174
174
  aiq/meta/pypi.md,sha256=Ukj1J--Q6GF7Zh1tKonygttN3aiq_Lf2-445nz0sE-o,4362
175
175
  aiq/observability/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
176
176
  aiq/observability/async_otel_listener.py,sha256=gR8fEdpZ9L8vGZiXLI7FwbwtSiGgQHMDDj5d-vKjZGc,18407
177
- aiq/observability/register.py,sha256=ZDQOaSuy9igc7nAKG7XWP2u6JanC2T8yufMWItNpPJI,4245
177
+ aiq/observability/register.py,sha256=WLPGY1b_RmVv48od-hIytvJrCqNoJupriHCzyxvTbUw,6723
178
178
  aiq/plugins/.namespace,sha256=Gace0pOC3ETEJf-TBVuNw0TQV6J_KtOPpEiSzMH-odo,215
179
179
  aiq/profiler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
180
180
  aiq/profiler/data_frame_row.py,sha256=vudqk1ZzZtlZln2Ir43mPl3nwNc0pQlhwbtdY9oSKtI,1755
@@ -307,10 +307,10 @@ aiq/utils/reactive/base/observer_base.py,sha256=UAlyAY_ky4q2t0P81RVFo2Bs_R7z5Nde
307
307
  aiq/utils/reactive/base/subject_base.py,sha256=Ed-AC6P7cT3qkW1EXjzbd5M9WpVoeN_9KCe3OM3FLU4,2521
308
308
  aiq/utils/settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
309
309
  aiq/utils/settings/global_settings.py,sha256=U9TCLdoZsKq5qOVGjREipGVv9e-FlStzqy5zv82_VYk,7454
310
- aiqtoolkit-1.2.0a20250528.dist-info/licenses/LICENSE-3rd-party.txt,sha256=8o7aySJa9CBvFshPcsRdJbczzdNyDGJ8b0J67WRUQ2k,183936
311
- aiqtoolkit-1.2.0a20250528.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
312
- aiqtoolkit-1.2.0a20250528.dist-info/METADATA,sha256=Py9XOHitu4SU0eFhE8TK3IXPmDqwvJIr-O0CwiDYnIM,20174
313
- aiqtoolkit-1.2.0a20250528.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
314
- aiqtoolkit-1.2.0a20250528.dist-info/entry_points.txt,sha256=gRlPfR5g21t328WNEQ4CcEz80S1sJNS8A7rMDYnzl4A,452
315
- aiqtoolkit-1.2.0a20250528.dist-info/top_level.txt,sha256=fo7AzYcNhZ_tRWrhGumtxwnxMew4xrT1iwouDy_f0Kc,4
316
- aiqtoolkit-1.2.0a20250528.dist-info/RECORD,,
310
+ aiqtoolkit-1.2.0a20250529.dist-info/licenses/LICENSE-3rd-party.txt,sha256=8o7aySJa9CBvFshPcsRdJbczzdNyDGJ8b0J67WRUQ2k,183936
311
+ aiqtoolkit-1.2.0a20250529.dist-info/licenses/LICENSE.md,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
312
+ aiqtoolkit-1.2.0a20250529.dist-info/METADATA,sha256=BadJ83ZSQ3tyHqklgqjTRULCgVbBPDtbyqqqL24PPWM,20174
313
+ aiqtoolkit-1.2.0a20250529.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
314
+ aiqtoolkit-1.2.0a20250529.dist-info/entry_points.txt,sha256=gRlPfR5g21t328WNEQ4CcEz80S1sJNS8A7rMDYnzl4A,452
315
+ aiqtoolkit-1.2.0a20250529.dist-info/top_level.txt,sha256=fo7AzYcNhZ_tRWrhGumtxwnxMew4xrT1iwouDy_f0Kc,4
316
+ aiqtoolkit-1.2.0a20250529.dist-info/RECORD,,