langtrace-python-sdk 1.0.10__tar.gz → 1.0.11__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.
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/PKG-INFO +1 -1
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/setup.py +2 -2
- langtrace-python-sdk-1.0.11/src/examples/openai/function_calling.py +75 -0
- langtrace-python-sdk-1.0.11/src/examples/setup.py +50 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/langtrace_python_sdk.egg-info/PKG-INFO +1 -1
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/langtrace_python_sdk.egg-info/SOURCES.txt +2 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/langtrace_python_sdk.egg-info/top_level.txt +1 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/LICENSE +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/README.md +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/setup.cfg +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/chroma_example/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/chroma_example/basic.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/langchain_example/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/langchain_example/basic.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/langchain_example/tool.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/llamaindex_example/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/llamaindex_example/basic.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/openai/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/openai/chat_completion.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/openai/embeddings_create.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/openai/images_generate.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/pinecone_example/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/pinecone_example/basic.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/chroma/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/chroma/apis.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/chroma/instrumentation.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/chroma/lib/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/chroma/patch.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/constants.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain/instrumentation.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain/patch.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain_community/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain_community/instrumentation.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain_community/patch.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain_core/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain_core/instrumentation.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain_core/patch.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/llamaindex/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/llamaindex/instrumentation.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/llamaindex/patch.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/apis.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/constants.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/instrumentation.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/lib/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/patch.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/token_estimation.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/pinecone/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/pinecone/apis.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/pinecone/instrumentation.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/pinecone/lib/__init__.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/pinecone/patch.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/with_root_span.py +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/langtrace_python_sdk.egg-info/dependency_links.txt +0 -0
- {langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/langtrace_python_sdk.egg-info/requires.txt +0 -0
|
@@ -4,7 +4,7 @@ with open('requirements.txt') as f:
|
|
|
4
4
|
|
|
5
5
|
setup(
|
|
6
6
|
name='langtrace-python-sdk', # Choose a unique name for PyPI
|
|
7
|
-
version='1.0.
|
|
7
|
+
version='1.0.11',
|
|
8
8
|
author='Ali Waleed',
|
|
9
9
|
author_email='ali@scale3labs.com',
|
|
10
10
|
description='LangTrace - Python SDK',
|
|
@@ -12,7 +12,7 @@ setup(
|
|
|
12
12
|
long_description_content_type='text/markdown',
|
|
13
13
|
url='https://github.com/Scale3-Labs/langtrace-python-sdk', # Project home page
|
|
14
14
|
package_dir={'': 'src'},
|
|
15
|
-
packages=find_packages(where='src'
|
|
15
|
+
packages=find_packages(where='src'),
|
|
16
16
|
install_requires=required,
|
|
17
17
|
python_requires='>=3.6',
|
|
18
18
|
classifiers=[
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from dotenv import find_dotenv, load_dotenv
|
|
4
|
+
from openai import OpenAI
|
|
5
|
+
|
|
6
|
+
from examples.setup import setup_instrumentation
|
|
7
|
+
from instrumentation.with_root_span import with_langtrace_root_span
|
|
8
|
+
|
|
9
|
+
_ = load_dotenv(find_dotenv())
|
|
10
|
+
|
|
11
|
+
setup_instrumentation()
|
|
12
|
+
|
|
13
|
+
client = OpenAI()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
student_custom_functions = [
|
|
17
|
+
{
|
|
18
|
+
'name': 'extract_student_info',
|
|
19
|
+
'description': 'Get the student information from the body of the input text',
|
|
20
|
+
'parameters': {
|
|
21
|
+
'type': 'object',
|
|
22
|
+
'properties': {
|
|
23
|
+
'name': {
|
|
24
|
+
'type': 'string',
|
|
25
|
+
'description': 'Name of the person'
|
|
26
|
+
},
|
|
27
|
+
'major': {
|
|
28
|
+
'type': 'string',
|
|
29
|
+
'description': 'Major subject.'
|
|
30
|
+
},
|
|
31
|
+
'school': {
|
|
32
|
+
'type': 'string',
|
|
33
|
+
'description': 'The university name.'
|
|
34
|
+
},
|
|
35
|
+
'grades': {
|
|
36
|
+
'type': 'integer',
|
|
37
|
+
'description': 'GPA of the student.'
|
|
38
|
+
},
|
|
39
|
+
'club': {
|
|
40
|
+
'type': 'string',
|
|
41
|
+
'description': 'School club for extracurricular activities. '
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@with_langtrace_root_span()
|
|
51
|
+
def function_calling():
|
|
52
|
+
response = client.chat.completions.create(
|
|
53
|
+
model='gpt-3.5-turbo',
|
|
54
|
+
messages=[{'role': 'user', 'content': "David Nguyen is a sophomore majoring in computer science at Stanford University. He is Asian American and has a 3.8 GPA. David is known for his programming skills and is an active member of the university's Robotics Club. He hopes to pursue a career in artificial intelligence after graduating."}],
|
|
55
|
+
functions=student_custom_functions,
|
|
56
|
+
function_call='auto',
|
|
57
|
+
stream=False
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# result = []
|
|
61
|
+
# for chunk in response:
|
|
62
|
+
# if chunk.choices[0].delta.function_call is not None:
|
|
63
|
+
# content = [
|
|
64
|
+
# choice.delta.function_call.arguments if choice.delta.function_call and
|
|
65
|
+
# choice.delta.function_call.arguments else ""
|
|
66
|
+
# for choice in chunk.choices]
|
|
67
|
+
# result.append(
|
|
68
|
+
# content[0] if len(content) > 0 else "")
|
|
69
|
+
|
|
70
|
+
# print("".join(result))
|
|
71
|
+
|
|
72
|
+
# Loading the response as a JSON object
|
|
73
|
+
json_response = json.loads(
|
|
74
|
+
response.choices[0].message.function_call.arguments)
|
|
75
|
+
print(json_response)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
from opentelemetry import trace
|
|
3
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
4
|
+
from opentelemetry.sdk.trace.export import (ConsoleSpanExporter,
|
|
5
|
+
SimpleSpanProcessor)
|
|
6
|
+
|
|
7
|
+
from instrumentation.chroma.instrumentation import ChromaInstrumentation
|
|
8
|
+
from instrumentation.langchain.instrumentation import LangchainInstrumentation
|
|
9
|
+
from instrumentation.langchain_community.instrumentation import \
|
|
10
|
+
LangchainCommunityInstrumentation
|
|
11
|
+
from instrumentation.langchain_core.instrumentation import \
|
|
12
|
+
LangchainCoreInstrumentation
|
|
13
|
+
from instrumentation.llamaindex.instrumentation import \
|
|
14
|
+
LlamaindexInstrumentation
|
|
15
|
+
from instrumentation.openai.instrumentation import OpenAIInstrumentation
|
|
16
|
+
from instrumentation.pinecone.instrumentation import PineconeInstrumentation
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def setup_instrumentation():
|
|
20
|
+
|
|
21
|
+
# Set up OpenTelemetry tracing
|
|
22
|
+
tracer_provider = TracerProvider()
|
|
23
|
+
|
|
24
|
+
# Use the ConsoleSpanExporter to print traces to the console
|
|
25
|
+
console_exporter = ConsoleSpanExporter()
|
|
26
|
+
tracer_provider.add_span_processor(SimpleSpanProcessor(console_exporter))
|
|
27
|
+
|
|
28
|
+
# Initialize tracer
|
|
29
|
+
trace.set_tracer_provider(tracer_provider)
|
|
30
|
+
|
|
31
|
+
# Initialize and enable your custom OpenAI instrumentation
|
|
32
|
+
# Create an instance of OpenAIInstrumentation
|
|
33
|
+
openai_instrumentation = OpenAIInstrumentation()
|
|
34
|
+
pinecone_instrumentation = PineconeInstrumentation()
|
|
35
|
+
llamaindex_instrumentation = LlamaindexInstrumentation()
|
|
36
|
+
chroma_instrumentation = ChromaInstrumentation()
|
|
37
|
+
langchain_instrumentation = LangchainInstrumentation()
|
|
38
|
+
langchain_core_instrumentation = LangchainCoreInstrumentation()
|
|
39
|
+
langchain_community_instrumentation = LangchainCommunityInstrumentation()
|
|
40
|
+
|
|
41
|
+
# Call the instrument method with some arguments
|
|
42
|
+
openai_instrumentation.instrument()
|
|
43
|
+
pinecone_instrumentation.instrument()
|
|
44
|
+
llamaindex_instrumentation.instrument()
|
|
45
|
+
chroma_instrumentation.instrument()
|
|
46
|
+
langchain_instrumentation.instrument()
|
|
47
|
+
langchain_core_instrumentation.instrument()
|
|
48
|
+
langchain_community_instrumentation.instrument()
|
|
49
|
+
|
|
50
|
+
print("setup complete")
|
|
@@ -2,6 +2,7 @@ LICENSE
|
|
|
2
2
|
README.md
|
|
3
3
|
setup.py
|
|
4
4
|
src/examples/__init__.py
|
|
5
|
+
src/examples/setup.py
|
|
5
6
|
src/examples/chroma_example/__init__.py
|
|
6
7
|
src/examples/chroma_example/basic.py
|
|
7
8
|
src/examples/langchain_example/__init__.py
|
|
@@ -12,6 +13,7 @@ src/examples/llamaindex_example/basic.py
|
|
|
12
13
|
src/examples/openai/__init__.py
|
|
13
14
|
src/examples/openai/chat_completion.py
|
|
14
15
|
src/examples/openai/embeddings_create.py
|
|
16
|
+
src/examples/openai/function_calling.py
|
|
15
17
|
src/examples/openai/images_generate.py
|
|
16
18
|
src/examples/pinecone_example/__init__.py
|
|
17
19
|
src/examples/pinecone_example/basic.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/chroma_example/__init__.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/chroma_example/basic.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/langchain_example/basic.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/langchain_example/tool.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/llamaindex_example/basic.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/openai/chat_completion.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/openai/embeddings_create.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/openai/images_generate.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/examples/pinecone_example/basic.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/chroma/__init__.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/chroma/apis.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/chroma/patch.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/constants.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/langchain/patch.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
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/llamaindex/patch.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/__init__.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/apis.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/constants.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/openai/patch.py
RENAMED
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/pinecone/__init__.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/pinecone/apis.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/pinecone/patch.py
RENAMED
|
File without changes
|
{langtrace-python-sdk-1.0.10 → langtrace-python-sdk-1.0.11}/src/instrumentation/with_root_span.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|