langtrace-python-sdk 1.2.9__py3-none-any.whl → 1.2.11__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.
- langtrace_python_sdk/constants/exporter/langtrace_exporter.py +1 -1
- langtrace_python_sdk/version.py +1 -1
- langtrace_python_sdk-1.2.11.dist-info/METADATA +191 -0
- {langtrace_python_sdk-1.2.9.dist-info → langtrace_python_sdk-1.2.11.dist-info}/RECORD +6 -6
- langtrace_python_sdk-1.2.9.dist-info/METADATA +0 -130
- {langtrace_python_sdk-1.2.9.dist-info → langtrace_python_sdk-1.2.11.dist-info}/WHEEL +0 -0
- {langtrace_python_sdk-1.2.9.dist-info → langtrace_python_sdk-1.2.11.dist-info}/licenses/LICENSE +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
LANGTRACE_REMOTE_URL = "https://
|
|
1
|
+
LANGTRACE_REMOTE_URL = "https://langtrace.ai/api/trace"
|
langtrace_python_sdk/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.2.
|
|
1
|
+
__version__ = "1.2.11"
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: langtrace-python-sdk
|
|
3
|
+
Version: 1.2.11
|
|
4
|
+
Summary: Python SDK for LangTrace
|
|
5
|
+
Project-URL: Homepage, https://github.com/Scale3-Labs/langtrace-python-sdk
|
|
6
|
+
Author-email: Scale3 Labs <engineering@scale3labs.com>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.9
|
|
13
|
+
Requires-Dist: opentelemetry-api
|
|
14
|
+
Requires-Dist: opentelemetry-instrumentation
|
|
15
|
+
Requires-Dist: opentelemetry-sdk
|
|
16
|
+
Requires-Dist: pinecone-client
|
|
17
|
+
Requires-Dist: tiktoken
|
|
18
|
+
Requires-Dist: trace-attributes
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: anthropic; extra == 'dev'
|
|
21
|
+
Requires-Dist: chromadb; extra == 'dev'
|
|
22
|
+
Requires-Dist: langchain; extra == 'dev'
|
|
23
|
+
Requires-Dist: langchain-openai; extra == 'dev'
|
|
24
|
+
Requires-Dist: llama-index; extra == 'dev'
|
|
25
|
+
Requires-Dist: openai; extra == 'dev'
|
|
26
|
+
Requires-Dist: python-dotenv; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# [Langtrace](https://www.langtrace.ai)
|
|
30
|
+
|
|
31
|
+
## Open Source & Open Telemetry(OTEL) Observability for LLM applications
|
|
32
|
+
|
|
33
|
+
   
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
Langtrace is an open source observability software which lets you capture, debug and analyze traces and metrics from all your applications that leverages LLM APIs, Vector Databases and LLM based Frameworks.
|
|
38
|
+
|
|
39
|
+
## Open Telemetry Support
|
|
40
|
+
|
|
41
|
+
The traces generated by Langtrace adhere to [Open Telemetry Standards(OTEL)](https://opentelemetry.io/docs/concepts/signals/traces/). We are developing [semantic conventions](https://opentelemetry.io/docs/concepts/semantic-conventions/) for the traces generated by this project. You can checkout the current definitions in [this repository](https://github.com/Scale3-Labs/langtrace-trace-attributes/tree/main/schemas). Note: This is an ongoing development and we encourage you to get involved and welcome your feedback.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Langtrace Cloud ☁️
|
|
46
|
+
|
|
47
|
+
To use the managed SaaS version of Langtrace, follow the steps below:
|
|
48
|
+
|
|
49
|
+
1. Sign up by going to [this link](https://langtrace.ai).
|
|
50
|
+
2. Create a new Project after signing up. Projects are containers for storing traces and metrics generated by your application. If you have only one application, creating 1 project will do.
|
|
51
|
+
3. Generate an API key by going inside the project.
|
|
52
|
+
4. In your application, install the Langtrace SDK and initialize it with the API key you generated in the step 3.
|
|
53
|
+
5. The code for installing and setting up the SDK is shown below
|
|
54
|
+
|
|
55
|
+
## Getting Started
|
|
56
|
+
|
|
57
|
+
Get started by adding simply three lines to your code!
|
|
58
|
+
|
|
59
|
+
``` python
|
|
60
|
+
pip install langtrace-python-sdk
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
``` python
|
|
64
|
+
from langtrace_python_sdk import langtrace # Must precede any llm module imports
|
|
65
|
+
langtrace.init(api_key=<your_api_key>)
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
OR
|
|
69
|
+
|
|
70
|
+
``` python
|
|
71
|
+
from langtrace_python_sdk import langtrace # Must precede any llm module imports
|
|
72
|
+
langtrace.init() # LANGTRACE_API_KEY as an ENVIRONMENT variable
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Langtrace Self Hosted
|
|
76
|
+
|
|
77
|
+
Get started by adding simply two lines to your code and see traces being logged to the console!
|
|
78
|
+
|
|
79
|
+
``` python
|
|
80
|
+
pip install langtrace-python-sdk
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
``` python
|
|
84
|
+
from langtrace_python_sdk import langtrace # Must precede any llm module imports
|
|
85
|
+
langtrace.init(write_to_langtrace_cloud=False, batch=False)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Langtrace self hosted custom exporter
|
|
89
|
+
|
|
90
|
+
Get started by adding simply three lines to your code and see traces being exported to your remote location!
|
|
91
|
+
|
|
92
|
+
``` python
|
|
93
|
+
pip install langtrace-python-sdk
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
``` python
|
|
97
|
+
from langtrace_python_sdk import langtrace # Must precede any llm module imports
|
|
98
|
+
langtrace.init(custom_remote_exporter=<your_exporter>, batch=<True or False>)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Additional Customization
|
|
102
|
+
|
|
103
|
+
- `@with_langtrace_root_span` - this decorator is designed to organize and relate different spans, in a hierarchical manner. When you're performing multiple operations that you want to monitor together as a unit, this function helps by establishing a "parent" (`LangtraceRootSpan` or whatever is passed to `name`) span. Then, any calls to the LLM APIs made within the given function (fn) will be considered "children" of this parent span. This setup is especially useful for tracking the performance or behavior of a group of operations collectively, rather than individually.
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
|
|
107
|
+
|
|
108
|
+
@with_langtrace_root_span()
|
|
109
|
+
def example():
|
|
110
|
+
response = client.chat.completions.create(
|
|
111
|
+
model="gpt-4",
|
|
112
|
+
messages=[{"role": "user", "content": "Say this is a test three times"}],
|
|
113
|
+
stream=False,
|
|
114
|
+
)
|
|
115
|
+
return response
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
- `with_additional_attributes` - this function is designed to enhance the traces by adding custom attributes to the current context. These custom attributes provide extra details about the operations being performed, making it easier to analyze and understand their behavior.
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from langtrace_python_sdk.utils.with_root_span import (
|
|
123
|
+
with_langtrace_root_span,
|
|
124
|
+
with_additional_attributes,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
@with_additional_attributes({"user.id": "1234", "user.feedback.rating": 1})
|
|
128
|
+
def api_call1():
|
|
129
|
+
response = client.chat.completions.create(
|
|
130
|
+
model="gpt-4",
|
|
131
|
+
messages=[{"role": "user", "content": "Say this is a test three times"}],
|
|
132
|
+
stream=False,
|
|
133
|
+
)
|
|
134
|
+
return response
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@with_additional_attributes({"user.id": "5678", "user.feedback.rating": -1})
|
|
138
|
+
def api_call2():
|
|
139
|
+
response = client.chat.completions.create(
|
|
140
|
+
model="gpt-4",
|
|
141
|
+
messages=[{"role": "user", "content": "Say this is a test three times"}],
|
|
142
|
+
stream=False,
|
|
143
|
+
)
|
|
144
|
+
return response
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
@with_langtrace_root_span()
|
|
148
|
+
def chat_completion():
|
|
149
|
+
api_call1()
|
|
150
|
+
api_call2()
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Supported integrations
|
|
154
|
+
|
|
155
|
+
Langtrace automatically captures traces from the following vendors:
|
|
156
|
+
|
|
157
|
+
| Vendor | Type | Typescript SDK | Python SDK
|
|
158
|
+
| ------ | ------ | ------ | ------ |
|
|
159
|
+
| OpenAI | LLM | :white_check_mark: | :white_check_mark: |
|
|
160
|
+
| Anthropic | LLM | :white_check_mark: | :white_check_mark: |
|
|
161
|
+
| Azure OpenAI | LLM | :white_check_mark: | :white_check_mark: |
|
|
162
|
+
| Langchain | Framework | :x: | :white_check_mark: |
|
|
163
|
+
| LlamaIndex | Framework | :white_check_mark: | :white_check_mark: |
|
|
164
|
+
| Pinecone | Vector Database | :white_check_mark: | :white_check_mark: |
|
|
165
|
+
| ChromaDB | Vector Database | :white_check_mark: | :white_check_mark: |
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Feature Requests and Issues
|
|
170
|
+
|
|
171
|
+
- To request for features, head over [here to start a discussion](https://github.com/Scale3-Labs/langtrace/discussions/categories/feature-requests).
|
|
172
|
+
- To raise an issue, head over [here and create an issue](https://github.com/Scale3-Labs/langtrace/issues).
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## Contributions
|
|
177
|
+
|
|
178
|
+
We welcome contributions to this project. To get started, fork this repository and start developing. To get involved, join our Slack workspace.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Security
|
|
183
|
+
|
|
184
|
+
To report security vulnerabilites, email us at <security@scale3labs.com>. You can read more on security [here](https://github.com/Scale3-Labs/langtrace/blob/development/SECURITY.md).
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
- Langtrace application(this repository) is [licensed](https://github.com/Scale3-Labs/langtrace/blob/development/LICENSE) under the AGPL 3.0 License. You can read about this license [here](https://www.gnu.org/licenses/agpl-3.0.en.html).
|
|
191
|
+
- Langtrace SDKs are licensed under the Apache 2.0 License. You can read about this license [here](https://www.apache.org/licenses/LICENSE-2.0).
|
|
@@ -18,9 +18,9 @@ examples/pinecone_example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
|
18
18
|
examples/pinecone_example/basic.py,sha256=hdV6-5Fmol9zeyFzDtdabD62vkqUJ4lCHG2YcVNpIpI,933
|
|
19
19
|
langtrace_python_sdk/__init__.py,sha256=SlHg447-nQBbw8exRNJP_OyHUZ39Sldb7aaQ35hIRm8,262
|
|
20
20
|
langtrace_python_sdk/langtrace.py,sha256=sWC7WqbOdOUB1sZ_hzLZVp0_Q8fBTRJRMUvOPyO6f20,3170
|
|
21
|
-
langtrace_python_sdk/version.py,sha256=
|
|
21
|
+
langtrace_python_sdk/version.py,sha256=aBWZsCYiXXcSUsUJr3tOTQWsH7ZDqJzyMYdQbOd5Qtc,23
|
|
22
22
|
langtrace_python_sdk/constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
-
langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=
|
|
23
|
+
langtrace_python_sdk/constants/exporter/langtrace_exporter.py,sha256=OfgvphRBPENwsAizqzka9lFu9aDw-A7ErYJ0atl3bpI,56
|
|
24
24
|
langtrace_python_sdk/constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
25
25
|
langtrace_python_sdk/constants/instrumentation/anthropic.py,sha256=YX3llt3zwDY6XrYk3CB8WEVqgrzRXEw_ffyk56JoF3k,126
|
|
26
26
|
langtrace_python_sdk/constants/instrumentation/chroma.py,sha256=hiPGYdHS0Yj4Kh3eaYBbuCAl_swqIygu80yFqkOgdak,955
|
|
@@ -57,7 +57,7 @@ langtrace_python_sdk/instrumentation/pinecone/patch.py,sha256=lvWL_xM7mxTQ1D-eY5
|
|
|
57
57
|
langtrace_python_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
58
|
langtrace_python_sdk/utils/llm.py,sha256=4z2e-md_ELXCEuOIRVWracR6qH2pmsOxCqpkuF9_3Nw,1589
|
|
59
59
|
langtrace_python_sdk/utils/with_root_span.py,sha256=N7ONrcF0myZbHBy5gpQffDbX-Kf63Crsz9szG0i3m08,1889
|
|
60
|
-
langtrace_python_sdk-1.2.
|
|
61
|
-
langtrace_python_sdk-1.2.
|
|
62
|
-
langtrace_python_sdk-1.2.
|
|
63
|
-
langtrace_python_sdk-1.2.
|
|
60
|
+
langtrace_python_sdk-1.2.11.dist-info/METADATA,sha256=8uVY2vORbVzc3bYx29FnJTZmUW9GUYfdymEsvbbqX44,7661
|
|
61
|
+
langtrace_python_sdk-1.2.11.dist-info/WHEEL,sha256=uNdcs2TADwSd5pVaP0Z_kcjcvvTUklh2S7bxZMF8Uj0,87
|
|
62
|
+
langtrace_python_sdk-1.2.11.dist-info/licenses/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
63
|
+
langtrace_python_sdk-1.2.11.dist-info/RECORD,,
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: langtrace-python-sdk
|
|
3
|
-
Version: 1.2.9
|
|
4
|
-
Summary: Python SDK for LangTrace
|
|
5
|
-
Project-URL: Homepage, https://github.com/Scale3-Labs/langtrace-python-sdk
|
|
6
|
-
Author-email: Scale3 Labs <engineering@scale3labs.com>
|
|
7
|
-
License-Expression: Apache-2.0
|
|
8
|
-
License-File: LICENSE
|
|
9
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Requires-Python: >=3.9
|
|
13
|
-
Requires-Dist: opentelemetry-api
|
|
14
|
-
Requires-Dist: opentelemetry-instrumentation
|
|
15
|
-
Requires-Dist: opentelemetry-sdk
|
|
16
|
-
Requires-Dist: pinecone-client
|
|
17
|
-
Requires-Dist: tiktoken
|
|
18
|
-
Requires-Dist: trace-attributes
|
|
19
|
-
Provides-Extra: dev
|
|
20
|
-
Requires-Dist: anthropic; extra == 'dev'
|
|
21
|
-
Requires-Dist: chromadb; extra == 'dev'
|
|
22
|
-
Requires-Dist: langchain; extra == 'dev'
|
|
23
|
-
Requires-Dist: langchain-openai; extra == 'dev'
|
|
24
|
-
Requires-Dist: llama-index; extra == 'dev'
|
|
25
|
-
Requires-Dist: openai; extra == 'dev'
|
|
26
|
-
Requires-Dist: python-dotenv; extra == 'dev'
|
|
27
|
-
Description-Content-Type: text/markdown
|
|
28
|
-
|
|
29
|
-
# What is Langtrace?
|
|
30
|
-
|
|
31
|
-
Langtrace stands as a developer-centric, open-source solution, fully compatible with OpenTelemetry. It enables developers to effortlessly trace, monitor, and debug their LLM applications, offering robust support for automatic instrumentation.
|
|
32
|
-
|
|
33
|
-
## Supported LLM Modules
|
|
34
|
-
|
|
35
|
-
Langtrace supports a comprehensive range of LLMs, VectorDBs, and frameworks, ensuring wide coverage for your development needs:
|
|
36
|
-
|
|
37
|
-
### LLMs
|
|
38
|
-
|
|
39
|
-
1. OpenAI
|
|
40
|
-
2. Anthropic
|
|
41
|
-
3. Azure OpenAI
|
|
42
|
-
|
|
43
|
-
### VectorDBs
|
|
44
|
-
|
|
45
|
-
1. Pinecone
|
|
46
|
-
2. Chromadb
|
|
47
|
-
|
|
48
|
-
### Frameworks
|
|
49
|
-
|
|
50
|
-
1. LangChain
|
|
51
|
-
2. LlamaIndex
|
|
52
|
-
3. Haystack
|
|
53
|
-
|
|
54
|
-
We are actively working to extend our support to additional libraries!
|
|
55
|
-
|
|
56
|
-
## Getting Started
|
|
57
|
-
|
|
58
|
-
To begin utilizing Langtrace, follow these straightforward steps:
|
|
59
|
-
|
|
60
|
-
1. Install the package using `pip install langtrace-python-sdk`.
|
|
61
|
-
2. Incorporate Langtrace into your project with `from langtrace_python_sdk import langtrace`.
|
|
62
|
-
- This import should precede any other LLM module imports (such as OpenAI, LlamaIndex, etc.) to ensure proper functionality.
|
|
63
|
-
3. Initialize Langtrace by adding `langtrace.init(write_to_langtrace_cloud=false)` to your code.
|
|
64
|
-
4. Congratulations, you've completed the basic setup! You will now begin to see traces from your LLM modules logged directly to the console.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
## Exporting Traces to Langtrace
|
|
68
|
-
|
|
69
|
-
To configure trace exporting, you have two options:
|
|
70
|
-
|
|
71
|
-
You'll need a Langtrace `api_key`, which can be acquired by logging into your Langtrace account.
|
|
72
|
-
|
|
73
|
-
1. Direct Initialization: Utilize `langtrace.init(api_key=<YOUR_API_KEY>)`.
|
|
74
|
-
2. Environment Variables: Set `LANGTRACE_API_KEY`, then add `langtrace.init()` at the beginning of your file.
|
|
75
|
-
|
|
76
|
-
### Additional Customization
|
|
77
|
-
|
|
78
|
-
- `@with_langtrace_root_span` - this decorator is designed to organize and relate different spans, in a hierarchical manner. When you're performing multiple operations that you want to monitor together as a unit, this function helps by establishing a "parent" (`LangtraceRootSpan` or whatever is passed to `name`) span. Then, any calls to the LLM APIs made within the given function (fn) will be considered "children" of this parent span. This setup is especially useful for tracking the performance or behavior of a group of operations collectively, rather than individually.
|
|
79
|
-
|
|
80
|
-
```python
|
|
81
|
-
from langtrace_python_sdk.utils.with_root_span import with_langtrace_root_span
|
|
82
|
-
|
|
83
|
-
@with_langtrace_root_span()
|
|
84
|
-
def example():
|
|
85
|
-
response = client.chat.completions.create(
|
|
86
|
-
model="gpt-4",
|
|
87
|
-
messages=[{"role": "user", "content": "Say this is a test three times"}],
|
|
88
|
-
stream=False,
|
|
89
|
-
)
|
|
90
|
-
return response
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
- `with_additional_attributes` - this function is designed to enhance the traces by adding custom attributes to the current context. These custom attributes provide extra details about the operations being performed, making it easier to analyze and understand their behavior.
|
|
95
|
-
|
|
96
|
-
```python
|
|
97
|
-
from langtrace_python_sdk.utils.with_root_span import (
|
|
98
|
-
with_langtrace_root_span,
|
|
99
|
-
with_additional_attributes,
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
@with_additional_attributes({"user.id": "1234", "user.feedback.rating": 1})
|
|
103
|
-
def api_call1():
|
|
104
|
-
response = client.chat.completions.create(
|
|
105
|
-
model="gpt-4",
|
|
106
|
-
messages=[{"role": "user", "content": "Say this is a test three times"}],
|
|
107
|
-
stream=False,
|
|
108
|
-
)
|
|
109
|
-
return response
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
@with_additional_attributes({"user.id": "5678", "user.feedback.rating": -1})
|
|
113
|
-
def api_call2():
|
|
114
|
-
response = client.chat.completions.create(
|
|
115
|
-
model="gpt-4",
|
|
116
|
-
messages=[{"role": "user", "content": "Say this is a test three times"}],
|
|
117
|
-
stream=False,
|
|
118
|
-
)
|
|
119
|
-
return response
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
@with_langtrace_root_span()
|
|
123
|
-
def chat_completion():
|
|
124
|
-
api_call1()
|
|
125
|
-
api_call2()
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Langtrace Cloud
|
|
129
|
-
|
|
130
|
-
Currently under development 🚧
|
|
File without changes
|
{langtrace_python_sdk-1.2.9.dist-info → langtrace_python_sdk-1.2.11.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|