arize-phoenix 2.11.1__py3-none-any.whl → 3.0.1__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 arize-phoenix might be problematic. Click here for more details.
- {arize_phoenix-2.11.1.dist-info → arize_phoenix-3.0.1.dist-info}/METADATA +25 -22
- {arize_phoenix-2.11.1.dist-info → arize_phoenix-3.0.1.dist-info}/RECORD +15 -16
- phoenix/config.py +5 -3
- phoenix/trace/exporter.py +24 -9
- phoenix/trace/langchain/__init__.py +25 -3
- phoenix/trace/langchain/instrumentor.py +23 -29
- phoenix/trace/langchain/tracer.py +32 -418
- phoenix/trace/llama_index/callback.py +21 -658
- phoenix/trace/openai/instrumentor.py +19 -676
- phoenix/trace/otel.py +8 -1
- phoenix/trace/tracer.py +84 -107
- phoenix/version.py +1 -1
- phoenix/trace/llama_index/streaming.py +0 -92
- {arize_phoenix-2.11.1.dist-info → arize_phoenix-3.0.1.dist-info}/WHEEL +0 -0
- {arize_phoenix-2.11.1.dist-info → arize_phoenix-3.0.1.dist-info}/licenses/IP_NOTICE +0 -0
- {arize_phoenix-2.11.1.dist-info → arize_phoenix-3.0.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: arize-phoenix
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.1
|
|
4
4
|
Summary: ML Observability in your notebook
|
|
5
5
|
Project-URL: Documentation, https://docs.arize.com/phoenix/
|
|
6
6
|
Project-URL: Issues, https://github.com/Arize-ai/phoenix/issues
|
|
@@ -20,6 +20,10 @@ Requires-Dist: ddsketch
|
|
|
20
20
|
Requires-Dist: hdbscan<1.0.0,>=0.8.33
|
|
21
21
|
Requires-Dist: jinja2
|
|
22
22
|
Requires-Dist: numpy
|
|
23
|
+
Requires-Dist: openinference-instrumentation-langchain
|
|
24
|
+
Requires-Dist: openinference-instrumentation-llama-index
|
|
25
|
+
Requires-Dist: openinference-instrumentation-openai
|
|
26
|
+
Requires-Dist: opentelemetry-exporter-otlp
|
|
23
27
|
Requires-Dist: opentelemetry-proto
|
|
24
28
|
Requires-Dist: opentelemetry-sdk
|
|
25
29
|
Requires-Dist: pandas
|
|
@@ -50,10 +54,10 @@ Requires-Dist: llama-index>=0.9.14; extra == 'dev'
|
|
|
50
54
|
Requires-Dist: nbqa; extra == 'dev'
|
|
51
55
|
Requires-Dist: pandas-stubs<=2.0.2.230605; extra == 'dev'
|
|
52
56
|
Requires-Dist: pre-commit; extra == 'dev'
|
|
53
|
-
Requires-Dist: pytest; extra == 'dev'
|
|
54
57
|
Requires-Dist: pytest-asyncio; extra == 'dev'
|
|
55
58
|
Requires-Dist: pytest-cov; extra == 'dev'
|
|
56
59
|
Requires-Dist: pytest-lazy-fixture; extra == 'dev'
|
|
60
|
+
Requires-Dist: pytest==7.4.4; extra == 'dev'
|
|
57
61
|
Requires-Dist: ruff==0.1.5; extra == 'dev'
|
|
58
62
|
Requires-Dist: strawberry-graphql[debug-server]==0.208.2; extra == 'dev'
|
|
59
63
|
Provides-Extra: experimental
|
|
@@ -103,22 +107,22 @@ Phoenix provides MLOps and LLMOps insights at lightning speed with zero-config o
|
|
|
103
107
|
|
|
104
108
|
**Table of Contents**
|
|
105
109
|
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
-
|
|
111
|
-
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
-
|
|
116
|
-
-
|
|
117
|
-
-
|
|
118
|
-
-
|
|
119
|
-
-
|
|
120
|
-
-
|
|
121
|
-
-
|
|
110
|
+
- [Installation](#installation)
|
|
111
|
+
- [LLM Traces](#llm-traces)
|
|
112
|
+
- [Tracing with LlamaIndex](#tracing-with-llamaindex)
|
|
113
|
+
- [Tracing with LangChain](#tracing-with-langchain)
|
|
114
|
+
- [LLM Evals](#llm-evals)
|
|
115
|
+
- [Embedding Analysis](#embedding-analysis)
|
|
116
|
+
- [UMAP-based Exploratory Data Analysis](#umap-based-exploratory-data-analysis)
|
|
117
|
+
- [Cluster-driven Drift and Performance Analysis](#cluster-driven-drift-and-performance-analysis)
|
|
118
|
+
- [Exportable Clusters](#exportable-clusters)
|
|
119
|
+
- [Retrieval-Augmented Generation Analysis](#retrieval-augmented-generation-analysis)
|
|
120
|
+
- [Structured Data Analysis](#structured-data-analysis)
|
|
121
|
+
- [Deploying Phoenix](#deploying-phoenix)
|
|
122
|
+
- [Breaking Changes](#breaking-changes)
|
|
123
|
+
- [Community](#community)
|
|
124
|
+
- [Thanks](#thanks)
|
|
125
|
+
- [Copyright, Patent, and License](#copyright-patent-and-license)
|
|
122
126
|
|
|
123
127
|
## Installation
|
|
124
128
|
|
|
@@ -219,9 +223,8 @@ session = px.launch_app()
|
|
|
219
223
|
|
|
220
224
|
from phoenix.trace.langchain import OpenInferenceTracer, LangChainInstrumentor
|
|
221
225
|
|
|
222
|
-
#
|
|
223
|
-
|
|
224
|
-
LangChainInstrumentor(tracer).instrument()
|
|
226
|
+
# By default, the traces will be exported to the locally running Phoenix server.
|
|
227
|
+
LangChainInstrumentor().instrument()
|
|
225
228
|
|
|
226
229
|
# Initialize your LangChain application
|
|
227
230
|
from langchain.chains import RetrievalQA
|
|
@@ -456,7 +459,7 @@ For more information on deploying Phoenix, see the [Phoenix Deployment Guide](ht
|
|
|
456
459
|
|
|
457
460
|
## Breaking Changes
|
|
458
461
|
|
|
459
|
-
|
|
462
|
+
see the [migration guide](./MIGRATION.md) for a list of breaking changes.
|
|
460
463
|
|
|
461
464
|
## Community
|
|
462
465
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
phoenix/__init__.py,sha256=MSamw7OMCIcCtrJdvJYMvQmC6O0uyehfPAXXELsllZM,1451
|
|
2
|
-
phoenix/config.py,sha256=
|
|
2
|
+
phoenix/config.py,sha256=RT4UR5VH8JUAKQhfmlkpxq2kmBSA8G8MODrC3GXWyaI,3507
|
|
3
3
|
phoenix/datetime_utils.py,sha256=D955QLrkgrrSdUM6NyqbCeAu2SMsjhR5rHVQEsVUdng,2773
|
|
4
4
|
phoenix/exceptions.py,sha256=X5k9ipUDfwSCwZB-H5zFJLas86Gf9tAx0W4l5TZxp5k,108
|
|
5
5
|
phoenix/py.typed,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
6
6
|
phoenix/services.py,sha256=f6AeyKTuOpy9RCcTCjVH3gx5nYZhbTMFOuv1WSUOB5o,4992
|
|
7
|
-
phoenix/version.py,sha256=
|
|
7
|
+
phoenix/version.py,sha256=E3P6AbnCwaWk6ndR1zNqlOTVebX9z5rv9voltc71dos,22
|
|
8
8
|
phoenix/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
phoenix/core/embedding_dimension.py,sha256=zKGbcvwOXgLf-yrJBpQyKtd-LEOPRKHnUToyAU8Owis,87
|
|
10
10
|
phoenix/core/evals.py,sha256=gJyqQzpud5YjtoY8h4pgXvHDsdubGfqmEewLuZHPPmQ,10224
|
|
@@ -139,39 +139,38 @@ phoenix/session/session.py,sha256=mrTAQkUFMGjN65ApYqRjhGXExbfxu2ODJcJ14MSDOLE,21
|
|
|
139
139
|
phoenix/trace/__init__.py,sha256=4d_MqzUIFmlY9WWcFeTONJ4xL5mPGoWZaPM2TJ0ZDBQ,266
|
|
140
140
|
phoenix/trace/errors.py,sha256=DbXSJnNErV7305tKv7pUWLD6jcVHJ6EBdSu4mZJ6IM4,112
|
|
141
141
|
phoenix/trace/evaluation_conventions.py,sha256=t8jydM3U0-T5YpiQKRJ3tWdWGlHtzKyttYdw-ddvPOk,1048
|
|
142
|
-
phoenix/trace/exporter.py,sha256=
|
|
142
|
+
phoenix/trace/exporter.py,sha256=O-9Arn-S_B9Me-jy4Qa84y6lvxKNoa8pczrsamPl3_Q,4871
|
|
143
143
|
phoenix/trace/fixtures.py,sha256=LokNedhbGYxpzXznteO4m5QehvNYjzvoh231-CMJQeY,7113
|
|
144
|
-
phoenix/trace/otel.py,sha256=
|
|
144
|
+
phoenix/trace/otel.py,sha256=lJoTvkCSFiPT4dFRLMZZgZfsOoTSATctW9lQk9J30ZI,14821
|
|
145
145
|
phoenix/trace/schemas.py,sha256=QDBlM94faceTnloY_ZVo2BHWWnE5UGymefC0jmfj4ew,6011
|
|
146
146
|
phoenix/trace/semantic_conventions.py,sha256=u6NG85ZhbreriZr8cqJaddldM_jUcew7JilszY7JUk8,4652
|
|
147
147
|
phoenix/trace/span_evaluations.py,sha256=FvY9YRnKuYIzCa-H9P5SuDaI2DeqGnVCjNgclC2v3HA,12909
|
|
148
148
|
phoenix/trace/span_json_decoder.py,sha256=nrIPkcgbCcNML-0OSjWC6fxIfBEMiP0n67yM_m-vegg,3068
|
|
149
149
|
phoenix/trace/span_json_encoder.py,sha256=C5y7rkyOcV08oJC5t8TZqVxsKCZMJKad7bBQzAgLoDs,1763
|
|
150
150
|
phoenix/trace/trace_dataset.py,sha256=KW0TzmhlKuX8PUPLV172iTK08myYE0QXUC75KiIqJ7k,13204
|
|
151
|
-
phoenix/trace/tracer.py,sha256=
|
|
151
|
+
phoenix/trace/tracer.py,sha256=JDKlyvjy6AsQmaA60ycJ1hKXoUQU61jqPx3nvYr8xUc,3647
|
|
152
152
|
phoenix/trace/utils.py,sha256=7LurVGXn245cjj4MJsc7v6jq4DSJkpK6YGBfIaSywuw,1307
|
|
153
153
|
phoenix/trace/dsl/__init__.py,sha256=WIQIjJg362XD3s50OsPJJ0xbDsGp41bSv7vDllLrPuA,144
|
|
154
154
|
phoenix/trace/dsl/filter.py,sha256=VwlzL4KsIoyYjjCSKXlOSyVm49WyYRlkK5zedXqZlcc,13136
|
|
155
155
|
phoenix/trace/dsl/helpers.py,sha256=qxRS65NFUFVpLDd8IZVrZUH891MamLeXyfIIN1BJJ_c,1552
|
|
156
156
|
phoenix/trace/dsl/missing.py,sha256=BWPOHr2_tBkPDgVeq8GVXXVbNbJiBelu4NtwHBg6mTE,1435
|
|
157
157
|
phoenix/trace/dsl/query.py,sha256=W6_e1o_JbucGWWv6pSUQFyIHcTuj7QuCBSuKXodRfCE,14773
|
|
158
|
-
phoenix/trace/langchain/__init__.py,sha256=
|
|
159
|
-
phoenix/trace/langchain/instrumentor.py,sha256=
|
|
160
|
-
phoenix/trace/langchain/tracer.py,sha256=
|
|
158
|
+
phoenix/trace/langchain/__init__.py,sha256=aTKMFmEOgjx_6dnyplalgYi7PQnetablwrwpcUZqcGE,764
|
|
159
|
+
phoenix/trace/langchain/instrumentor.py,sha256=rmqdaEh2rwyZnaddns4RC2WQnj7TbCnJjETgoiwWvzs,1163
|
|
160
|
+
phoenix/trace/langchain/tracer.py,sha256=fSjtPc5VxaZK63x3ob3DAW7eM2kfOZWgbSQ9dmhhtsw,1424
|
|
161
161
|
phoenix/trace/llama_index/__init__.py,sha256=wCcQgD9CG5TA8i-1XsSed4ZzwHTUmqZwegQAV_FqEng,178
|
|
162
|
-
phoenix/trace/llama_index/callback.py,sha256=
|
|
162
|
+
phoenix/trace/llama_index/callback.py,sha256=MHgUNJSG6ecxZ8SZ_9LdcKnAAWmNI-U5pySFyXqubjM,1694
|
|
163
163
|
phoenix/trace/llama_index/debug_callback.py,sha256=SKToD9q_QADSGTJ5lhilqRVKaUnUSRXUvURCzN4by2U,1367
|
|
164
|
-
phoenix/trace/llama_index/streaming.py,sha256=yt_kB0LJK6lGdARtivmEmkZgbnzFUqIHfSN0hjYbTpM,3248
|
|
165
164
|
phoenix/trace/openai/__init__.py,sha256=J3G0uqCxGdksUpaQVHds_Egv2drvh8UEqoLjiQAOveg,79
|
|
166
|
-
phoenix/trace/openai/instrumentor.py,sha256=
|
|
165
|
+
phoenix/trace/openai/instrumentor.py,sha256=Lre96YfPxs5iM3frZfwdAh94LUpyYw_RZpSF0XmPtKw,1061
|
|
167
166
|
phoenix/trace/v1/__init__.py,sha256=-IbAD0ruESMjvQLvGAg9CTfjBUATFDx1OXseDPis6-0,88
|
|
168
167
|
phoenix/trace/v1/evaluation_pb2.py,sha256=8sXvv2BW_vqD30MOMbmkeE2zpmm7ncik21kl3e-HzeQ,2254
|
|
169
168
|
phoenix/trace/v1/evaluation_pb2.pyi,sha256=cCbbx06gwQmaH14s3J1X25TtaARh-k1abbxQdQCXGm8,4500
|
|
170
169
|
phoenix/utilities/__init__.py,sha256=3TVirVnjIGyaCFuJCqeZO4tjlzQ_chZgYM0itIwsEpE,656
|
|
171
170
|
phoenix/utilities/error_handling.py,sha256=7b5rpGFj9EWZ8yrZK1IHvxB89suWk3lggDayUQcvZds,1946
|
|
172
171
|
phoenix/utilities/logging.py,sha256=lDXd6EGaamBNcQxL4vP1au9-i_SXe0OraUDiJOcszSw,222
|
|
173
|
-
arize_phoenix-
|
|
174
|
-
arize_phoenix-
|
|
175
|
-
arize_phoenix-
|
|
176
|
-
arize_phoenix-
|
|
177
|
-
arize_phoenix-
|
|
172
|
+
arize_phoenix-3.0.1.dist-info/METADATA,sha256=MIwob2psMophui1KBYcjRPTmKinVvD9YIY0aDqRE5V0,28556
|
|
173
|
+
arize_phoenix-3.0.1.dist-info/WHEEL,sha256=TJPnKdtrSue7xZ_AVGkp9YXcvDrobsjBds1du3Nx6dc,87
|
|
174
|
+
arize_phoenix-3.0.1.dist-info/licenses/IP_NOTICE,sha256=JBqyyCYYxGDfzQ0TtsQgjts41IJoa-hiwDrBjCb9gHM,469
|
|
175
|
+
arize_phoenix-3.0.1.dist-info/licenses/LICENSE,sha256=HFkW9REuMOkvKRACuwLPT0hRydHb3zNg-fdFt94td18,3794
|
|
176
|
+
arize_phoenix-3.0.1.dist-info/RECORD,,
|
phoenix/config.py
CHANGED
|
@@ -12,7 +12,7 @@ ENV_PHOENIX_COLLECTOR_ENDPOINT = "PHOENIX_COLLECTOR_ENDPOINT"
|
|
|
12
12
|
The endpoint traces and evals are sent to. This must be set if the Phoenix
|
|
13
13
|
server is running on a remote instance.
|
|
14
14
|
"""
|
|
15
|
-
|
|
15
|
+
ENV_PHOENIX_WORKING_DIR = "PHOENIX_WORKING_DIR"
|
|
16
16
|
"""
|
|
17
17
|
The directory in which to save, load, and export datasets. This directory must
|
|
18
18
|
be accessible by both the Phoenix server and the notebook environment.
|
|
@@ -45,7 +45,7 @@ def get_working_dir() -> Path:
|
|
|
45
45
|
"""
|
|
46
46
|
Get the working directory for saving, loading, and exporting datasets.
|
|
47
47
|
"""
|
|
48
|
-
working_dir_str = os.getenv(
|
|
48
|
+
working_dir_str = os.getenv(ENV_PHOENIX_WORKING_DIR)
|
|
49
49
|
if working_dir_str is not None:
|
|
50
50
|
return Path(working_dir_str)
|
|
51
51
|
# Fall back to ~/.phoenix if PHOENIX_WORKING_DIR is not set
|
|
@@ -77,7 +77,9 @@ except Exception as e:
|
|
|
77
77
|
f"⚠️ Failed to initialize the working directory at {WORKING_DIR} due to an error: {str(e)}"
|
|
78
78
|
)
|
|
79
79
|
print("⚠️ While phoenix will still run, you will not be able to save, load, or export data")
|
|
80
|
-
print(
|
|
80
|
+
print(
|
|
81
|
+
f"ℹ️ To change, set the `{ENV_PHOENIX_WORKING_DIR}` environment variable before importing phoenix." # noqa: E501
|
|
82
|
+
)
|
|
81
83
|
|
|
82
84
|
|
|
83
85
|
def get_exported_files(directory: Path) -> List[Path]:
|
phoenix/trace/exporter.py
CHANGED
|
@@ -9,6 +9,7 @@ from urllib.parse import urljoin
|
|
|
9
9
|
|
|
10
10
|
import opentelemetry.proto.trace.v1.trace_pb2 as otlp
|
|
11
11
|
import requests
|
|
12
|
+
from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
|
|
12
13
|
from requests import Session
|
|
13
14
|
from typing_extensions import TypeAlias, assert_never
|
|
14
15
|
|
|
@@ -30,6 +31,19 @@ class NoOpExporter:
|
|
|
30
31
|
pass
|
|
31
32
|
|
|
32
33
|
|
|
34
|
+
class _OpenInferenceExporter(OTLPSpanExporter):
|
|
35
|
+
def __init__(self) -> None:
|
|
36
|
+
host = get_env_host()
|
|
37
|
+
if host == "0.0.0.0":
|
|
38
|
+
host = "127.0.0.1"
|
|
39
|
+
endpoint = urljoin(
|
|
40
|
+
get_env_collector_endpoint() or f"http://{host}:{get_env_port()}",
|
|
41
|
+
"/v1/traces",
|
|
42
|
+
)
|
|
43
|
+
_warn_if_phoenix_is_not_running(endpoint)
|
|
44
|
+
super().__init__(endpoint)
|
|
45
|
+
|
|
46
|
+
|
|
33
47
|
class HttpExporter:
|
|
34
48
|
def __init__(
|
|
35
49
|
self,
|
|
@@ -62,7 +76,7 @@ class HttpExporter:
|
|
|
62
76
|
or get_env_collector_endpoint()
|
|
63
77
|
or f"http://{'127.0.0.1' if self._host == '0.0.0.0' else self._host}:{self._port}"
|
|
64
78
|
)
|
|
65
|
-
self.
|
|
79
|
+
_warn_if_phoenix_is_not_running(self._base_url)
|
|
66
80
|
self._session = Session()
|
|
67
81
|
weakref.finalize(self, self._session.close)
|
|
68
82
|
self._session.headers.update(
|
|
@@ -114,11 +128,12 @@ class HttpExporter:
|
|
|
114
128
|
logger.exception(f"unrecognized message type: {type(message)}")
|
|
115
129
|
assert_never(message)
|
|
116
130
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
)
|
|
131
|
+
|
|
132
|
+
def _warn_if_phoenix_is_not_running(endpoint: str) -> None:
|
|
133
|
+
try:
|
|
134
|
+
requests.get(urljoin(endpoint, "/arize_phoenix_version")).raise_for_status()
|
|
135
|
+
except Exception:
|
|
136
|
+
logger.warning(
|
|
137
|
+
f"Arize Phoenix is not running on {endpoint}. Launch Phoenix "
|
|
138
|
+
f"with `import phoenix as px; px.launch_app()`"
|
|
139
|
+
)
|
|
@@ -1,4 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
from
|
|
1
|
+
import sys
|
|
2
|
+
from typing import Any
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import phoenix.trace.langchain.instrumentor as _instrumentor
|
|
5
|
+
import phoenix.trace.langchain.tracer as _tracer
|
|
6
|
+
|
|
7
|
+
_DUMMY = "OpenInferenceTracer"
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class _Deprecation:
|
|
11
|
+
__all__ = ("LangChainInstrumentor", _DUMMY)
|
|
12
|
+
|
|
13
|
+
def __getattr__(self, name: str) -> Any:
|
|
14
|
+
if name == "tracer":
|
|
15
|
+
return _tracer
|
|
16
|
+
if name == "instrumentor":
|
|
17
|
+
return _instrumentor
|
|
18
|
+
if name == _DUMMY:
|
|
19
|
+
return getattr(_tracer, name)
|
|
20
|
+
if name == "LangChainInstrumentor":
|
|
21
|
+
return _instrumentor.LangChainInstrumentor
|
|
22
|
+
raise AttributeError(f"module {__name__} has no attribute {name}")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# See e.g. https://stackoverflow.com/a/7668273
|
|
26
|
+
sys.modules[__name__] = _Deprecation() # type: ignore
|
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
import logging
|
|
2
|
+
from importlib.metadata import PackageNotFoundError
|
|
3
|
+
from importlib.util import find_spec
|
|
4
|
+
from typing import Any
|
|
2
5
|
|
|
3
|
-
from .
|
|
6
|
+
from openinference.instrumentation.langchain import LangChainInstrumentor as Instrumentor
|
|
7
|
+
from opentelemetry.sdk import trace as trace_sdk
|
|
8
|
+
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
|
|
4
9
|
|
|
10
|
+
from phoenix.trace.exporter import _OpenInferenceExporter
|
|
11
|
+
from phoenix.trace.tracer import _show_deprecation_warnings
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
"""
|
|
8
|
-
Instruments the OpenInferenceTracer for LangChain automatically by patching the
|
|
9
|
-
BaseCallbackManager in LangChain.
|
|
10
|
-
"""
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
11
14
|
|
|
12
|
-
def __init__(self, tracer: Optional[OpenInferenceTracer] = None) -> None:
|
|
13
|
-
self._tracer = tracer if tracer is not None else OpenInferenceTracer()
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
try:
|
|
17
|
-
from langchain.callbacks.base import BaseCallbackManager
|
|
18
|
-
except ImportError:
|
|
19
|
-
# Raise a cleaner error if LangChain is not installed
|
|
20
|
-
raise ImportError(
|
|
21
|
-
"LangChain is not installed. Please install LangChain first to use the instrumentor"
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
source_init = BaseCallbackManager.__init__
|
|
16
|
+
__all__ = ("LangChainInstrumentor",)
|
|
25
17
|
|
|
26
|
-
# Keep track of the source init so we can tell if the patching occurred
|
|
27
|
-
self._source_callback_manager_init = source_init
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
class LangChainInstrumentor(Instrumentor):
|
|
20
|
+
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
|
21
|
+
_show_deprecation_warnings(self, *args, **kwargs)
|
|
22
|
+
if find_spec("langchain_core") is None:
|
|
23
|
+
raise PackageNotFoundError(
|
|
24
|
+
"Missing `langchain-core`. Install with `pip install langchain-core`."
|
|
25
|
+
)
|
|
26
|
+
super().__init__()
|
|
36
27
|
|
|
37
|
-
|
|
28
|
+
def instrument(self) -> None:
|
|
29
|
+
tracer_provider = trace_sdk.TracerProvider()
|
|
30
|
+
tracer_provider.add_span_processor(SimpleSpanProcessor(_OpenInferenceExporter()))
|
|
31
|
+
super().instrument(skip_dep_check=True, tracer_provider=tracer_provider)
|