langtrace-python-sdk 1.2.23__tar.gz → 1.2.25__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.
Files changed (78) hide show
  1. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/PKG-INFO +63 -1
  2. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/README.md +62 -0
  3. langtrace_python_sdk-1.2.25/src/examples/perplexity_example/basic.py +21 -0
  4. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/constants/instrumentation/common.py +1 -0
  5. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/openai/patch.py +6 -0
  6. langtrace_python_sdk-1.2.25/src/langtrace_python_sdk/version.py +1 -0
  7. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/run_example.py +1 -0
  8. langtrace_python_sdk-1.2.23/src/langtrace_python_sdk/version.py +0 -1
  9. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/.gitignore +0 -0
  10. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/LICENSE +0 -0
  11. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/pyproject.toml +0 -0
  12. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/__init__.py +0 -0
  13. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/__init__.py +0 -0
  14. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/anthropic_example/__init__.py +0 -0
  15. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/anthropic_example/completion.py +0 -0
  16. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/chroma_example/__init__.py +0 -0
  17. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/chroma_example/basic.py +0 -0
  18. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/langchain_example/__init__.py +0 -0
  19. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/langchain_example/basic.py +0 -0
  20. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/langchain_example/tool.py +0 -0
  21. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/llamaindex_example/__init__.py +0 -0
  22. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/llamaindex_example/basic.py +0 -0
  23. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/llamaindex_example/data/abramov.txt +0 -0
  24. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/openai/__init__.py +0 -0
  25. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/openai/chat_completion.py +0 -0
  26. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/openai/embeddings_create.py +0 -0
  27. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/openai/function_calling.py +0 -0
  28. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/openai/images_generate.py +0 -0
  29. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/pinecone_example/__init__.py +0 -0
  30. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/examples/pinecone_example/basic.py +0 -0
  31. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/__init__.py +0 -0
  32. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/constants/__init__.py +0 -0
  33. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/constants/exporter/langtrace_exporter.py +0 -0
  34. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/constants/instrumentation/__init__.py +0 -0
  35. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/constants/instrumentation/anthropic.py +0 -0
  36. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/constants/instrumentation/chroma.py +0 -0
  37. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/constants/instrumentation/openai.py +0 -0
  38. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/constants/instrumentation/pinecone.py +0 -0
  39. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/extensions/__init__.py +0 -0
  40. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/extensions/langtrace_exporter.py +0 -0
  41. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/__init__.py +0 -0
  42. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/anthropic/__init__.py +0 -0
  43. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/anthropic/instrumentation.py +0 -0
  44. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/anthropic/patch.py +0 -0
  45. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/chroma/__init__.py +0 -0
  46. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/chroma/instrumentation.py +0 -0
  47. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/chroma/patch.py +0 -0
  48. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/langchain/__init__.py +0 -0
  49. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/langchain/instrumentation.py +0 -0
  50. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/langchain/patch.py +0 -0
  51. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/langchain_community/__init__.py +0 -0
  52. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/langchain_community/instrumentation.py +0 -0
  53. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/langchain_community/patch.py +0 -0
  54. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/langchain_core/__init__.py +0 -0
  55. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/langchain_core/instrumentation.py +0 -0
  56. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/langchain_core/patch.py +0 -0
  57. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/llamaindex/__init__.py +0 -0
  58. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/llamaindex/instrumentation.py +0 -0
  59. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/llamaindex/patch.py +0 -0
  60. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/openai/__init__.py +0 -0
  61. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/openai/instrumentation.py +0 -0
  62. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/pinecone/__init__.py +0 -0
  63. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/pinecone/instrumentation.py +0 -0
  64. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/instrumentation/pinecone/patch.py +0 -0
  65. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/langtrace.py +0 -0
  66. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/utils/__init__.py +0 -0
  67. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/utils/llm.py +0 -0
  68. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/langtrace_python_sdk/utils/with_root_span.py +0 -0
  69. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/__init__.py +0 -0
  70. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/anthropic/test_anthropic.py +0 -0
  71. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/chroma/test_chroma.py +0 -0
  72. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/langchain/test_langchain.py +0 -0
  73. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/langchain/test_langchain_community.py +0 -0
  74. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/langchain/test_langchain_core.py +0 -0
  75. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/openai/test_chat_completion.py +0 -0
  76. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/openai/test_image_generation.py +0 -0
  77. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/pinecone/test_pinecone.py +0 -0
  78. {langtrace_python_sdk-1.2.23 → langtrace_python_sdk-1.2.25}/src/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: langtrace-python-sdk
3
- Version: 1.2.23
3
+ Version: 1.2.25
4
4
  Summary: Python SDK for LangTrace
5
5
  Project-URL: Homepage, https://github.com/Scale3-Labs/langtrace-python-sdk
6
6
  Author-email: Scale3 Labs <engineering@scale3labs.com>
@@ -72,6 +72,68 @@ from langtrace_python_sdk import langtrace # Must precede any llm module imports
72
72
  langtrace.init() # LANGTRACE_API_KEY as an ENVIRONMENT variable
73
73
  ```
74
74
 
75
+ ## FastAPI Quick Start
76
+ Initialize FastAPI project and add this inside the ```main.py``` file
77
+
78
+ ```python
79
+ from fastapi import FastAPI
80
+ from langtrace_python_sdk import langtrace
81
+ from openai import OpenAI
82
+
83
+ langtrace.init()
84
+ app = FastAPI()
85
+ client = OpenAI()
86
+
87
+ @app.get("/")
88
+ def root():
89
+ client.chat.completions.create(
90
+ model="gpt-4",
91
+ messages=[{"role": "user", "content": "Say this is a test three times"}],
92
+ stream=False,
93
+ )
94
+ return {"Hello": "World"}
95
+ ```
96
+
97
+ ## Django Quick Start
98
+ Initialize django project and add this inside the ```__init.py__``` file
99
+ ```python
100
+ from langtrace_python_sdk import langtrace
101
+ from openai import OpenAI
102
+
103
+
104
+ langtrace.init()
105
+ client = OpenAI()
106
+
107
+ client.chat.completions.create(
108
+ model="gpt-4",
109
+ messages=[{"role": "user", "content": "Say this is a test three times"}],
110
+ stream=False,
111
+ )
112
+
113
+ ```
114
+
115
+ ## Flask Quick Start
116
+ Initialize flask project and this inside ```app.py``` file
117
+ ```python
118
+ from flask import Flask
119
+ from langtrace_python_sdk import langtrace
120
+ from openai import OpenAI
121
+
122
+ langtrace.init()
123
+ client = OpenAI()
124
+ app = Flask(__name__)
125
+
126
+
127
+ @app.route("/")
128
+ def main():
129
+ 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 "Hello, World!"
135
+ ```
136
+
75
137
  ## Langtrace Self Hosted
76
138
 
77
139
  Get started by adding simply two lines to your code and see traces being logged to the console!
@@ -44,6 +44,68 @@ from langtrace_python_sdk import langtrace # Must precede any llm module imports
44
44
  langtrace.init() # LANGTRACE_API_KEY as an ENVIRONMENT variable
45
45
  ```
46
46
 
47
+ ## FastAPI Quick Start
48
+ Initialize FastAPI project and add this inside the ```main.py``` file
49
+
50
+ ```python
51
+ from fastapi import FastAPI
52
+ from langtrace_python_sdk import langtrace
53
+ from openai import OpenAI
54
+
55
+ langtrace.init()
56
+ app = FastAPI()
57
+ client = OpenAI()
58
+
59
+ @app.get("/")
60
+ def root():
61
+ client.chat.completions.create(
62
+ model="gpt-4",
63
+ messages=[{"role": "user", "content": "Say this is a test three times"}],
64
+ stream=False,
65
+ )
66
+ return {"Hello": "World"}
67
+ ```
68
+
69
+ ## Django Quick Start
70
+ Initialize django project and add this inside the ```__init.py__``` file
71
+ ```python
72
+ from langtrace_python_sdk import langtrace
73
+ from openai import OpenAI
74
+
75
+
76
+ langtrace.init()
77
+ client = OpenAI()
78
+
79
+ client.chat.completions.create(
80
+ model="gpt-4",
81
+ messages=[{"role": "user", "content": "Say this is a test three times"}],
82
+ stream=False,
83
+ )
84
+
85
+ ```
86
+
87
+ ## Flask Quick Start
88
+ Initialize flask project and this inside ```app.py``` file
89
+ ```python
90
+ from flask import Flask
91
+ from langtrace_python_sdk import langtrace
92
+ from openai import OpenAI
93
+
94
+ langtrace.init()
95
+ client = OpenAI()
96
+ app = Flask(__name__)
97
+
98
+
99
+ @app.route("/")
100
+ def main():
101
+ client.chat.completions.create(
102
+ model="gpt-4",
103
+ messages=[{"role": "user", "content": "Say this is a test three times"}],
104
+ stream=False,
105
+ )
106
+ return "Hello, World!"
107
+ ```
108
+
47
109
  ## Langtrace Self Hosted
48
110
 
49
111
  Get started by adding simply two lines to your code and see traces being logged to the console!
@@ -0,0 +1,21 @@
1
+ from openai import OpenAI
2
+
3
+ from langtrace_python_sdk import langtrace
4
+ from langtrace_python_sdk.utils.with_root_span import (
5
+ with_additional_attributes, with_langtrace_root_span)
6
+
7
+ # _ = load_dotenv(find_dotenv())
8
+
9
+ langtrace.init(batch=False, write_to_langtrace_cloud=False, debug_log_to_console=True)
10
+ client = OpenAI(base_url="https://api.perplexity.ai", api_key="PPLX_API_KEY")
11
+
12
+
13
+ @with_additional_attributes({"user.id": "1234", "user.feedback.rating": 1})
14
+ def basic():
15
+ response = client.chat.completions.create(
16
+ model="pplx-70b-online",
17
+ messages=[{"role": "user", "content": "What is the capital of France?"}],
18
+ stream=False,
19
+ )
20
+ print(response)
21
+ return response
@@ -16,6 +16,7 @@ SERVICE_PROVIDERS = {
16
16
  "LLAMAINDEX": "LlamaIndex",
17
17
  "OPENAI": "OpenAI",
18
18
  "PINECONE": "Pinecone",
19
+ "PPLX": "Perplexity",
19
20
  }
20
21
 
21
22
  LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY = "langtrace_additional_attributes"
@@ -97,6 +97,12 @@ def chat_completions_create(original_method, version, tracer):
97
97
  else ""
98
98
  )
99
99
  service_provider = SERVICE_PROVIDERS["OPENAI"]
100
+ # If base url contains perplexity or azure, set the service provider accordingly
101
+ if "perplexity" in base_url:
102
+ service_provider = SERVICE_PROVIDERS["PPLX"]
103
+ elif "azure" in base_url:
104
+ service_provider = SERVICE_PROVIDERS["AZURE"]
105
+
100
106
  extra_attributes = baggage.get_baggage(LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY)
101
107
 
102
108
  span_attributes = {
@@ -0,0 +1 @@
1
+ __version__ = "1.2.25"
@@ -11,6 +11,7 @@ from examples.openai.chat_completion import chat_completion
11
11
  # from examples.chroma_example.basic import basic
12
12
  # from examples.llamaindex_example.basic import basic
13
13
  # from examples.langchain_example.basic import basic
14
+ # from examples.perplexity_example.basic import basic
14
15
 
15
16
  # load_and_split()
16
17
  # rag()
@@ -1 +0,0 @@
1
- __version__ = "1.2.23"