langtrace-python-sdk 1.0.10__py3-none-any.whl → 1.0.12__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.
- constants/instrumentation/chroma.py +40 -0
- instrumentation/constants.py → constants/instrumentation/common.py +9 -4
- instrumentation/openai/constants.py → constants/instrumentation/openai.py +16 -10
- instrumentation/pinecone/apis.py → constants/instrumentation/pinecone.py +1 -1
- examples/chroma_example/__init__.py +1 -0
- examples/chroma_example/basic.py +26 -0
- examples/langchain_example/__init__.py +0 -0
- examples/langchain_example/basic.py +64 -0
- examples/langchain_example/tool.py +85 -0
- examples/llamaindex_example/__init__.py +0 -0
- examples/llamaindex_example/basic.py +20 -0
- examples/openai/__init__.py +0 -0
- examples/openai/chat_completion.py +40 -0
- examples/openai/embeddings_create.py +19 -0
- examples/openai/function_calling.py +76 -0
- examples/openai/images_generate.py +20 -0
- examples/pinecone_example/__init__.py +0 -0
- examples/pinecone_example/basic.py +32 -0
- extensions/__init__.py +0 -0
- extensions/langtrace_exporter.py +75 -0
- init/__init__.py +1 -0
- init/init.py +72 -0
- instrumentation/chroma/instrumentation.py +1 -1
- instrumentation/chroma/patch.py +2 -2
- instrumentation/langchain/patch.py +1 -1
- instrumentation/langchain_community/patch.py +2 -1
- instrumentation/langchain_core/patch.py +2 -1
- instrumentation/llamaindex/patch.py +2 -1
- instrumentation/openai/patch.py +5 -5
- instrumentation/openai/token_estimation.py +2 -3
- instrumentation/pinecone/instrumentation.py +1 -1
- instrumentation/pinecone/patch.py +2 -2
- {langtrace_python_sdk-1.0.10.dist-info → langtrace_python_sdk-1.0.12.dist-info}/METADATA +5 -3
- langtrace_python_sdk-1.0.12.dist-info/RECORD +56 -0
- langtrace_python_sdk-1.0.12.dist-info/top_level.txt +6 -0
- utils/__init__.py +0 -0
- instrumentation/openai/apis.py +0 -19
- langtrace_python_sdk-1.0.10.dist-info/RECORD +0 -37
- langtrace_python_sdk-1.0.10.dist-info/top_level.txt +0 -1
- {instrumentation/chroma/lib → constants}/__init__.py +0 -0
- {instrumentation/openai/lib → constants/instrumentation}/__init__.py +0 -0
- {instrumentation/pinecone/lib → examples}/__init__.py +0 -0
- {langtrace_python_sdk-1.0.10.dist-info → langtrace_python_sdk-1.0.12.dist-info}/LICENSE +0 -0
- {langtrace_python_sdk-1.0.10.dist-info → langtrace_python_sdk-1.0.12.dist-info}/WHEEL +0 -0
- {instrumentation → utils}/with_root_span.py +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from langtrace.trace_attributes import ChromaDBMethods
|
|
2
|
+
|
|
3
|
+
APIS = {
|
|
4
|
+
"ADD": {
|
|
5
|
+
"METHOD": ChromaDBMethods.ADD.value,
|
|
6
|
+
"OPERATION": "add",
|
|
7
|
+
},
|
|
8
|
+
"GET": {
|
|
9
|
+
"METHOD": ChromaDBMethods.GET.value,
|
|
10
|
+
"OPERATION": "get",
|
|
11
|
+
},
|
|
12
|
+
"QUERY": {
|
|
13
|
+
"METHOD": ChromaDBMethods.QUERY.value,
|
|
14
|
+
"OPERATION": "query",
|
|
15
|
+
},
|
|
16
|
+
"DELETE": {
|
|
17
|
+
"METHOD": ChromaDBMethods.DELETE.value,
|
|
18
|
+
"OPERATION": "delete",
|
|
19
|
+
},
|
|
20
|
+
"PEEK": {
|
|
21
|
+
"METHOD": ChromaDBMethods.PEEK.value,
|
|
22
|
+
"OPERATION": "peek",
|
|
23
|
+
},
|
|
24
|
+
"UPDATE": {
|
|
25
|
+
"METHOD": ChromaDBMethods.UPDATE.value,
|
|
26
|
+
"OPERATION": "update",
|
|
27
|
+
},
|
|
28
|
+
"UPSERT": {
|
|
29
|
+
"METHOD": ChromaDBMethods.UPSERT.value,
|
|
30
|
+
"OPERATION": "upsert",
|
|
31
|
+
},
|
|
32
|
+
"MODIFY": {
|
|
33
|
+
"METHOD": ChromaDBMethods.MODIFY.value,
|
|
34
|
+
"OPERATION": "modify",
|
|
35
|
+
},
|
|
36
|
+
"COUNT": {
|
|
37
|
+
"METHOD": ChromaDBMethods.COUNT.value,
|
|
38
|
+
"OPERATION": "count",
|
|
39
|
+
},
|
|
40
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
"""
|
|
1
|
+
TIKTOKEN_MODEL_MAPPING = {
|
|
2
|
+
"gpt-4": "cl100k_base",
|
|
3
|
+
"gpt-4-32k": "cl100k_base",
|
|
4
|
+
"gpt-4-0125-preview": "cl100k_base",
|
|
5
|
+
"gpt-4-1106-preview": "cl100k_base",
|
|
6
|
+
"gpt-4-1106-vision-preview": "cl100k_base",
|
|
7
|
+
}
|
|
8
|
+
|
|
4
9
|
SERVICE_PROVIDERS = {
|
|
5
10
|
"OPENAI": "OpenAI",
|
|
6
11
|
"AZURE": "Azure",
|
|
@@ -10,4 +15,4 @@ SERVICE_PROVIDERS = {
|
|
|
10
15
|
"PINECONE": "Pinecone",
|
|
11
16
|
"LLAMAINDEX": "LlamaIndex",
|
|
12
17
|
"CHROMA": "Chroma",
|
|
13
|
-
}
|
|
18
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Constants for OpenAI API"""
|
|
1
|
+
from langtrace.trace_attributes import OpenAIMethods
|
|
3
2
|
|
|
4
3
|
OPENAI_COST_TABLE = {
|
|
5
4
|
"gpt-4-0125-preview": {
|
|
@@ -32,12 +31,19 @@ OPENAI_COST_TABLE = {
|
|
|
32
31
|
},
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
APIS = {
|
|
35
|
+
"CHAT_COMPLETION": {
|
|
36
|
+
"METHOD": OpenAIMethods.CHAT_COMPLETION.value,
|
|
37
|
+
"ENDPOINT": "/chat/completions",
|
|
38
|
+
},
|
|
39
|
+
"IMAGES_GENERATION": {
|
|
40
|
+
"METHOD": OpenAIMethods.IMAGES_GENERATION.value,
|
|
41
|
+
"ENDPOINT": "/images/generations",
|
|
42
|
+
},
|
|
43
|
+
"EMBEDDINGS_CREATE": {
|
|
44
|
+
"METHOD": OpenAIMethods.EMBEDDINGS_CREATE.value,
|
|
45
|
+
"ENDPOINT": "/embeddings",
|
|
46
|
+
},
|
|
43
47
|
}
|
|
48
|
+
|
|
49
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .basic import basic
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import chromadb
|
|
2
|
+
from chromadb.utils import embedding_functions
|
|
3
|
+
from dotenv import find_dotenv, load_dotenv
|
|
4
|
+
|
|
5
|
+
from utils.with_root_span import with_langtrace_root_span
|
|
6
|
+
from init import init
|
|
7
|
+
_ = load_dotenv(find_dotenv())
|
|
8
|
+
|
|
9
|
+
init()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@with_langtrace_root_span()
|
|
13
|
+
def basic():
|
|
14
|
+
chroma_client = chromadb.Client()
|
|
15
|
+
embedder = embedding_functions.DefaultEmbeddingFunction()
|
|
16
|
+
collection = chroma_client.create_collection(
|
|
17
|
+
name="my6_collection", embedding_function=embedder)
|
|
18
|
+
collection.add(
|
|
19
|
+
documents=["This is a document", "This is another document"],
|
|
20
|
+
metadatas=[{"source": "my_source"}, {"source": "my_source"}],
|
|
21
|
+
ids=["id1", "id2"]
|
|
22
|
+
)
|
|
23
|
+
results = collection.query(
|
|
24
|
+
query_texts=["This is a query document"],
|
|
25
|
+
n_results=2
|
|
26
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from dotenv import find_dotenv, load_dotenv
|
|
2
|
+
from init.init import init
|
|
3
|
+
from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|
4
|
+
from langchain_community.document_loaders import PyPDFLoader
|
|
5
|
+
from langchain_community.vectorstores.faiss import FAISS
|
|
6
|
+
from langchain_core.output_parsers import StrOutputParser
|
|
7
|
+
from langchain_core.prompts.chat import ChatPromptTemplate
|
|
8
|
+
from langchain_core.runnables import RunnablePassthrough
|
|
9
|
+
from langchain_openai import ChatOpenAI, OpenAIEmbeddings
|
|
10
|
+
from utils.with_root_span import with_langtrace_root_span
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
_ = load_dotenv(find_dotenv())
|
|
14
|
+
|
|
15
|
+
init()
|
|
16
|
+
|
|
17
|
+
@with_langtrace_root_span()
|
|
18
|
+
def basic():
|
|
19
|
+
llm = ChatOpenAI()
|
|
20
|
+
prompt = ChatPromptTemplate.from_messages([
|
|
21
|
+
("system", "You are world class technical documentation writer."),
|
|
22
|
+
("user", "{input}")
|
|
23
|
+
])
|
|
24
|
+
output_parser = StrOutputParser()
|
|
25
|
+
chain = prompt | llm | output_parser
|
|
26
|
+
res = chain.invoke({"input": "how can langsmith help with testing?"})
|
|
27
|
+
print(res)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@with_langtrace_root_span()
|
|
31
|
+
def rag():
|
|
32
|
+
vectorstore = FAISS.from_texts(
|
|
33
|
+
["harrison worked at kensho"], embedding=OpenAIEmbeddings()
|
|
34
|
+
)
|
|
35
|
+
retriever = vectorstore.as_retriever()
|
|
36
|
+
|
|
37
|
+
template = """Answer the question based only on the following context:{context}
|
|
38
|
+
|
|
39
|
+
Question: {question}
|
|
40
|
+
"""
|
|
41
|
+
prompt = ChatPromptTemplate.from_template(template)
|
|
42
|
+
|
|
43
|
+
model = ChatOpenAI()
|
|
44
|
+
|
|
45
|
+
chain = (
|
|
46
|
+
{"context": retriever, "question": RunnablePassthrough()}
|
|
47
|
+
| prompt
|
|
48
|
+
| model
|
|
49
|
+
| StrOutputParser()
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
res = chain.invoke("where did harrison work?")
|
|
53
|
+
# print(res)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@with_langtrace_root_span()
|
|
57
|
+
def load_and_split():
|
|
58
|
+
url = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'
|
|
59
|
+
loader = PyPDFLoader(url)
|
|
60
|
+
data = loader.load()
|
|
61
|
+
text_splitter = RecursiveCharacterTextSplitter(
|
|
62
|
+
chunk_size=500, chunk_overlap=0)
|
|
63
|
+
docs = text_splitter.split_documents(data)
|
|
64
|
+
# print(docs)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
from dotenv import find_dotenv, load_dotenv
|
|
2
|
+
from init import init
|
|
3
|
+
from langchain import hub
|
|
4
|
+
from langchain.agents import AgentExecutor, create_openai_functions_agent
|
|
5
|
+
from langchain.chains import LLMMathChain
|
|
6
|
+
from langchain_core.pydantic_v1 import BaseModel, Field
|
|
7
|
+
from langchain_core.tools import Tool
|
|
8
|
+
from langchain_openai import ChatOpenAI
|
|
9
|
+
from utils.with_root_span import with_langtrace_root_span
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
_ = load_dotenv(find_dotenv())
|
|
13
|
+
|
|
14
|
+
init()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
llm = ChatOpenAI(temperature=0, model="gpt-4")
|
|
18
|
+
llm_math_chain = LLMMathChain.from_llm(llm=llm, verbose=True)
|
|
19
|
+
|
|
20
|
+
primes = {998: 7901, 999: 7907, 1000: 7919}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CalculatorInput(BaseModel):
|
|
24
|
+
question: str = Field()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class PrimeInput(BaseModel):
|
|
28
|
+
n: int = Field()
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def is_prime(n: int) -> bool:
|
|
32
|
+
if n <= 1 or (n % 2 == 0 and n > 2):
|
|
33
|
+
return False
|
|
34
|
+
for i in range(3, int(n**0.5) + 1, 2):
|
|
35
|
+
if n % i == 0:
|
|
36
|
+
return False
|
|
37
|
+
return True
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_prime(n: int, primes: dict = primes) -> str:
|
|
41
|
+
return str(primes.get(int(n)))
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
async def aget_prime(n: int, primes: dict = primes) -> str:
|
|
45
|
+
return str(primes.get(int(n)))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@with_langtrace_root_span()
|
|
49
|
+
def tool_example():
|
|
50
|
+
|
|
51
|
+
tools = [
|
|
52
|
+
Tool(
|
|
53
|
+
name="GetPrime",
|
|
54
|
+
func=get_prime,
|
|
55
|
+
description="A tool that returns the `n`th prime number",
|
|
56
|
+
args_schema=PrimeInput,
|
|
57
|
+
coroutine=aget_prime,
|
|
58
|
+
),
|
|
59
|
+
Tool.from_function(
|
|
60
|
+
func=llm_math_chain.run,
|
|
61
|
+
name="Calculator",
|
|
62
|
+
description="Useful for when you need to compute mathematical expressions",
|
|
63
|
+
args_schema=CalculatorInput,
|
|
64
|
+
coroutine=llm_math_chain.arun,
|
|
65
|
+
),
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
prompt = hub.pull("hwchase17/openai-functions-agent")
|
|
69
|
+
|
|
70
|
+
agent = create_openai_functions_agent(llm, tools, prompt)
|
|
71
|
+
|
|
72
|
+
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)
|
|
73
|
+
|
|
74
|
+
question = "What is the product of the 998th, 999th and 1000th prime numbers?"
|
|
75
|
+
|
|
76
|
+
for step in agent_executor.iter({"input": question}):
|
|
77
|
+
if output := step.get("intermediate_step"):
|
|
78
|
+
action, value = output[0]
|
|
79
|
+
if action.tool == "GetPrime":
|
|
80
|
+
print(f"Checking whether {value} is prime...")
|
|
81
|
+
assert is_prime(int(value))
|
|
82
|
+
# Ask user if they want to continue
|
|
83
|
+
_continue = input("Should the agent continue (Y/n)?:\n") or "Y"
|
|
84
|
+
if _continue.lower() != "y":
|
|
85
|
+
break
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from dotenv import find_dotenv, load_dotenv
|
|
2
|
+
from init import init
|
|
3
|
+
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
|
|
4
|
+
from utils.with_root_span import with_langtrace_root_span
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
_ = load_dotenv(find_dotenv())
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
init()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@with_langtrace_root_span()
|
|
14
|
+
def basic():
|
|
15
|
+
documents = SimpleDirectoryReader(
|
|
16
|
+
"src/examples/llamaindex_example/data").load_data()
|
|
17
|
+
index = VectorStoreIndex.from_documents(documents)
|
|
18
|
+
query_engine = index.as_query_engine()
|
|
19
|
+
response = query_engine.query("What did the author do in college?")
|
|
20
|
+
print(response)
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from dotenv import find_dotenv, load_dotenv
|
|
2
|
+
from openai import OpenAI
|
|
3
|
+
|
|
4
|
+
from init.init import init
|
|
5
|
+
from utils.with_root_span import with_langtrace_root_span
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
_ = load_dotenv(find_dotenv())
|
|
9
|
+
|
|
10
|
+
init()
|
|
11
|
+
|
|
12
|
+
client = OpenAI()
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@with_langtrace_root_span()
|
|
16
|
+
def chat_completion():
|
|
17
|
+
response = client.chat.completions.create(
|
|
18
|
+
model="gpt-4",
|
|
19
|
+
messages=[{"role": "user", "content": "Say this is a test three times"}],
|
|
20
|
+
stream=True,
|
|
21
|
+
)
|
|
22
|
+
# print(stream)
|
|
23
|
+
# stream = client.chat.completions.create(
|
|
24
|
+
# model="gpt-4",
|
|
25
|
+
# messages=[{"role": "user", "content": "Say this is a test three times"}, {"role": "assistant", "content": "This is a test. This is a test. This is a test"},
|
|
26
|
+
# {"role": "user", "content": "Say this is a mock 4 times"}],
|
|
27
|
+
# stream=False,
|
|
28
|
+
# )
|
|
29
|
+
|
|
30
|
+
result = []
|
|
31
|
+
for chunk in response:
|
|
32
|
+
if chunk.choices[0].delta.function_call is not None:
|
|
33
|
+
content = [
|
|
34
|
+
choice.delta.function_call.arguments if choice.delta.function_call and
|
|
35
|
+
choice.delta.function_call.arguments else ""
|
|
36
|
+
for choice in chunk.choices]
|
|
37
|
+
result.append(
|
|
38
|
+
content[0] if len(content) > 0 else "")
|
|
39
|
+
|
|
40
|
+
print("".join(result))
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from dotenv import find_dotenv, load_dotenv
|
|
2
|
+
from init import init
|
|
3
|
+
from openai import OpenAI
|
|
4
|
+
|
|
5
|
+
from utils.with_root_span import with_langtrace_root_span
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
_ = load_dotenv(find_dotenv())
|
|
9
|
+
|
|
10
|
+
init()
|
|
11
|
+
client = OpenAI()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@with_langtrace_root_span()
|
|
15
|
+
def embeddings_create():
|
|
16
|
+
result = client.embeddings.create(
|
|
17
|
+
model="text-embedding-ada-002",
|
|
18
|
+
input="Once upon a time, there was a frog.",
|
|
19
|
+
)
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from dotenv import find_dotenv, load_dotenv
|
|
4
|
+
from init import init
|
|
5
|
+
from openai import OpenAI
|
|
6
|
+
|
|
7
|
+
from utils.with_root_span import with_langtrace_root_span
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
_ = load_dotenv(find_dotenv())
|
|
11
|
+
|
|
12
|
+
init()
|
|
13
|
+
|
|
14
|
+
client = OpenAI()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
student_custom_functions = [
|
|
18
|
+
{
|
|
19
|
+
'name': 'extract_student_info',
|
|
20
|
+
'description': 'Get the student information from the body of the input text',
|
|
21
|
+
'parameters': {
|
|
22
|
+
'type': 'object',
|
|
23
|
+
'properties': {
|
|
24
|
+
'name': {
|
|
25
|
+
'type': 'string',
|
|
26
|
+
'description': 'Name of the person'
|
|
27
|
+
},
|
|
28
|
+
'major': {
|
|
29
|
+
'type': 'string',
|
|
30
|
+
'description': 'Major subject.'
|
|
31
|
+
},
|
|
32
|
+
'school': {
|
|
33
|
+
'type': 'string',
|
|
34
|
+
'description': 'The university name.'
|
|
35
|
+
},
|
|
36
|
+
'grades': {
|
|
37
|
+
'type': 'integer',
|
|
38
|
+
'description': 'GPA of the student.'
|
|
39
|
+
},
|
|
40
|
+
'club': {
|
|
41
|
+
'type': 'string',
|
|
42
|
+
'description': 'School club for extracurricular activities. '
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@with_langtrace_root_span()
|
|
52
|
+
def function_calling():
|
|
53
|
+
response = client.chat.completions.create(
|
|
54
|
+
model='gpt-3.5-turbo',
|
|
55
|
+
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."}],
|
|
56
|
+
functions=student_custom_functions,
|
|
57
|
+
function_call='auto',
|
|
58
|
+
stream=False
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
# result = []
|
|
62
|
+
# for chunk in response:
|
|
63
|
+
# if chunk.choices[0].delta.function_call is not None:
|
|
64
|
+
# content = [
|
|
65
|
+
# choice.delta.function_call.arguments if choice.delta.function_call and
|
|
66
|
+
# choice.delta.function_call.arguments else ""
|
|
67
|
+
# for choice in chunk.choices]
|
|
68
|
+
# result.append(
|
|
69
|
+
# content[0] if len(content) > 0 else "")
|
|
70
|
+
|
|
71
|
+
# print("".join(result))
|
|
72
|
+
|
|
73
|
+
# Loading the response as a JSON object
|
|
74
|
+
json_response = json.loads(
|
|
75
|
+
response.choices[0].message.function_call.arguments)
|
|
76
|
+
print(json_response)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from dotenv import find_dotenv, load_dotenv
|
|
2
|
+
from init import init
|
|
3
|
+
from openai import OpenAI
|
|
4
|
+
from utils.with_root_span import with_langtrace_root_span
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
_ = load_dotenv(find_dotenv())
|
|
8
|
+
|
|
9
|
+
init()
|
|
10
|
+
|
|
11
|
+
client = OpenAI()
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@with_langtrace_root_span()
|
|
15
|
+
def images_generate():
|
|
16
|
+
result = client.images.generate(
|
|
17
|
+
model="dall-e-3",
|
|
18
|
+
prompt="A cute baby sea otter",
|
|
19
|
+
)
|
|
20
|
+
print(result)
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from dotenv import find_dotenv, load_dotenv
|
|
2
|
+
from init import init
|
|
3
|
+
from openai import OpenAI
|
|
4
|
+
from pinecone import Pinecone
|
|
5
|
+
from utils.with_root_span import with_langtrace_root_span
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
_ = load_dotenv(find_dotenv())
|
|
9
|
+
|
|
10
|
+
init()
|
|
11
|
+
|
|
12
|
+
client = OpenAI()
|
|
13
|
+
pinecone = Pinecone()
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@with_langtrace_root_span()
|
|
17
|
+
def basic():
|
|
18
|
+
result = client.embeddings.create(
|
|
19
|
+
model="text-embedding-ada-002",
|
|
20
|
+
input="Some random text string goes here",
|
|
21
|
+
encoding_format="float"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
embedding = result.data[0].embedding
|
|
25
|
+
|
|
26
|
+
unique_id = "randomid"
|
|
27
|
+
data_to_upsert = {"id": unique_id, "values": embedding}
|
|
28
|
+
|
|
29
|
+
index = pinecone.Index("test-index")
|
|
30
|
+
index.upsert(vectors=[data_to_upsert])
|
|
31
|
+
|
|
32
|
+
resp = index.query(vector=embedding, top_k=1)
|
extensions/__init__.py
ADDED
|
File without changes
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from opentelemetry.sdk.trace.export import (SpanExporter, ReadableSpan, SpanExportResult)
|
|
3
|
+
import os
|
|
4
|
+
import typing
|
|
5
|
+
import requests
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class LangTraceExporter(SpanExporter):
|
|
11
|
+
api_key: str
|
|
12
|
+
url: str
|
|
13
|
+
write_to_remote_url: bool
|
|
14
|
+
|
|
15
|
+
def __init__(self, api_key: str = None, url: str = None, write_to_remote_url: bool = False) -> None:
|
|
16
|
+
self.api_key = api_key if api_key else os.environ.get('LANGTRACE_API_KEY')
|
|
17
|
+
self.url = url if url else os.environ.get('LANGTRACE_URL')
|
|
18
|
+
self.write_to_remote_url = write_to_remote_url
|
|
19
|
+
|
|
20
|
+
if not self.api_key:
|
|
21
|
+
raise ValueError('No API key provided')
|
|
22
|
+
|
|
23
|
+
if not self.url and self.write_to_remote_url:
|
|
24
|
+
raise ValueError('No URL provided')
|
|
25
|
+
|
|
26
|
+
def export(self, spans: typing.Sequence[ReadableSpan]) -> SpanExportResult:
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
Exports a batch of telemetry data.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
spans: The list of `opentelemetry.trace.Span` objects to be exported
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
The result of the export SUCCESS or FAILURE
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
data = [
|
|
40
|
+
{
|
|
41
|
+
'traceId': span.get_span_context().trace_id,
|
|
42
|
+
'instrumentationLibrary': span.instrumentation_info.__repr__(),
|
|
43
|
+
'droppedEventsCount': span.dropped_events,
|
|
44
|
+
'droppedAttributesCount': span.dropped_attributes,
|
|
45
|
+
'droppedLinksCount': span.dropped_links,
|
|
46
|
+
'ended': span.status.is_ok,
|
|
47
|
+
'duration': span.end_time - span.start_time,
|
|
48
|
+
**json.loads(span.to_json()),
|
|
49
|
+
} for span in spans]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if not self.write_to_remote_url:
|
|
53
|
+
return
|
|
54
|
+
|
|
55
|
+
# Send data to remote URL
|
|
56
|
+
try:
|
|
57
|
+
requests.post(
|
|
58
|
+
url=self.url,
|
|
59
|
+
data=json.dumps(data),
|
|
60
|
+
headers={
|
|
61
|
+
'Content-Type': 'application/json',
|
|
62
|
+
'x-api-key': self.api_key
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
print(f"Sent To {self.url} with Body {data} ")
|
|
66
|
+
return SpanExportResult.SUCCESS
|
|
67
|
+
except Exception as e:
|
|
68
|
+
print("Error sending data to remote URL", e)
|
|
69
|
+
return SpanExportResult.FAILURE
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def shutdown(self) -> None:
|
|
75
|
+
pass
|
init/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from init.init import init
|
init/init.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
from opentelemetry.sdk.trace import TracerProvider
|
|
2
|
+
from opentelemetry.sdk.trace.export import ConsoleSpanExporter, SimpleSpanProcessor, BatchSpanProcessor
|
|
3
|
+
from extensions.langtrace_exporter import LangTraceExporter
|
|
4
|
+
|
|
5
|
+
from instrumentation.chroma.instrumentation import ChromaInstrumentation
|
|
6
|
+
from instrumentation.langchain.instrumentation import LangchainInstrumentation
|
|
7
|
+
from instrumentation.langchain_community.instrumentation import \
|
|
8
|
+
LangchainCommunityInstrumentation
|
|
9
|
+
from instrumentation.langchain_core.instrumentation import \
|
|
10
|
+
LangchainCoreInstrumentation
|
|
11
|
+
from instrumentation.llamaindex.instrumentation import \
|
|
12
|
+
LlamaindexInstrumentation
|
|
13
|
+
from instrumentation.openai.instrumentation import OpenAIInstrumentation
|
|
14
|
+
from instrumentation.pinecone.instrumentation import PineconeInstrumentation
|
|
15
|
+
from opentelemetry import trace
|
|
16
|
+
|
|
17
|
+
def init(
|
|
18
|
+
api_key: str = None,
|
|
19
|
+
remote_url: str = None,
|
|
20
|
+
batch: bool = False,
|
|
21
|
+
log_spans_to_console: bool = False,
|
|
22
|
+
write_to_remote_url: bool = True
|
|
23
|
+
):
|
|
24
|
+
|
|
25
|
+
provider = TracerProvider()
|
|
26
|
+
remote_write_exporter = LangTraceExporter(api_key, remote_url, write_to_remote_url)
|
|
27
|
+
console_exporter = ConsoleSpanExporter()
|
|
28
|
+
batch_processor_remote = BatchSpanProcessor(remote_write_exporter)
|
|
29
|
+
simple_processor_remote = SimpleSpanProcessor(remote_write_exporter)
|
|
30
|
+
batch_processor_console = BatchSpanProcessor(console_exporter)
|
|
31
|
+
simple_processor_console = SimpleSpanProcessor(console_exporter)
|
|
32
|
+
|
|
33
|
+
if log_spans_to_console:
|
|
34
|
+
if batch:
|
|
35
|
+
provider.add_span_processor(batch_processor_console)
|
|
36
|
+
else:
|
|
37
|
+
provider.add_span_processor(simple_processor_console)
|
|
38
|
+
|
|
39
|
+
if write_to_remote_url:
|
|
40
|
+
if batch:
|
|
41
|
+
provider.add_span_processor(batch_processor_remote)
|
|
42
|
+
else:
|
|
43
|
+
provider.add_span_processor(simple_processor_remote)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
# Initialize tracer
|
|
47
|
+
trace.set_tracer_provider(provider)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
openai_instrumentation = OpenAIInstrumentation()
|
|
51
|
+
pinecone_instrumentation = PineconeInstrumentation()
|
|
52
|
+
llamaindex_instrumentation = LlamaindexInstrumentation()
|
|
53
|
+
chroma_instrumentation = ChromaInstrumentation()
|
|
54
|
+
langchain_instrumentation = LangchainInstrumentation()
|
|
55
|
+
langchain_core_instrumentation = LangchainCoreInstrumentation()
|
|
56
|
+
langchain_community_instrumentation = LangchainCommunityInstrumentation()
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
# Call the instrument method with some arguments
|
|
60
|
+
openai_instrumentation.instrument()
|
|
61
|
+
pinecone_instrumentation.instrument()
|
|
62
|
+
llamaindex_instrumentation.instrument()
|
|
63
|
+
chroma_instrumentation.instrument()
|
|
64
|
+
langchain_instrumentation.instrument()
|
|
65
|
+
langchain_core_instrumentation.instrument()
|
|
66
|
+
langchain_community_instrumentation.instrument()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
@@ -8,7 +8,7 @@ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
|
8
8
|
from opentelemetry.trace import get_tracer
|
|
9
9
|
from wrapt import wrap_function_wrapper
|
|
10
10
|
|
|
11
|
-
from instrumentation.chroma
|
|
11
|
+
from constants.instrumentation.chroma import APIS
|
|
12
12
|
from instrumentation.chroma.patch import collection_patch
|
|
13
13
|
|
|
14
14
|
|
instrumentation/chroma/patch.py
CHANGED
|
@@ -5,8 +5,8 @@ from langtrace.trace_attributes import DatabaseSpanAttributes
|
|
|
5
5
|
from opentelemetry.trace import SpanKind
|
|
6
6
|
from opentelemetry.trace.status import Status, StatusCode
|
|
7
7
|
|
|
8
|
-
from instrumentation.chroma
|
|
9
|
-
from instrumentation.
|
|
8
|
+
from constants.instrumentation.chroma import APIS
|
|
9
|
+
from constants.instrumentation.common import SERVICE_PROVIDERS
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
def collection_patch(method, version, tracer):
|
|
@@ -7,7 +7,7 @@ from langtrace.trace_attributes import FrameworkSpanAttributes
|
|
|
7
7
|
from opentelemetry.trace import SpanKind, StatusCode
|
|
8
8
|
from opentelemetry.trace.status import Status
|
|
9
9
|
|
|
10
|
-
from instrumentation.
|
|
10
|
+
from constants.instrumentation.common import SERVICE_PROVIDERS
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
def generic_patch(method_name, task, tracer, version, trace_output=True, trace_input=True):
|
|
@@ -4,7 +4,8 @@ from langtrace.trace_attributes import FrameworkSpanAttributes
|
|
|
4
4
|
from opentelemetry.trace import SpanKind, StatusCode
|
|
5
5
|
from opentelemetry.trace.status import Status, StatusCode
|
|
6
6
|
|
|
7
|
-
from instrumentation.
|
|
7
|
+
from constants.instrumentation.common import SERVICE_PROVIDERS
|
|
8
|
+
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
def generic_patch(method_name, task, tracer, version, trace_output=True, trace_input=True):
|
|
@@ -7,7 +7,8 @@ from langtrace.trace_attributes import FrameworkSpanAttributes
|
|
|
7
7
|
from opentelemetry.trace import SpanKind, StatusCode
|
|
8
8
|
from opentelemetry.trace.status import Status
|
|
9
9
|
|
|
10
|
-
from instrumentation.
|
|
10
|
+
from constants.instrumentation.common import SERVICE_PROVIDERS
|
|
11
|
+
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
def generic_patch(method_name, task, tracer, version, trace_output=True, trace_input=True):
|
|
@@ -5,7 +5,8 @@ from langtrace.trace_attributes import FrameworkSpanAttributes
|
|
|
5
5
|
from opentelemetry.trace import SpanKind
|
|
6
6
|
from opentelemetry.trace.status import Status, StatusCode
|
|
7
7
|
|
|
8
|
-
from instrumentation.
|
|
8
|
+
from constants.instrumentation.common import SERVICE_PROVIDERS
|
|
9
|
+
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
def generic_patch(method, task, tracer, version):
|
instrumentation/openai/patch.py
CHANGED
|
@@ -6,8 +6,8 @@ from langtrace.trace_attributes import Event, LLMSpanAttributes
|
|
|
6
6
|
from opentelemetry.trace import SpanKind
|
|
7
7
|
from opentelemetry.trace.status import Status, StatusCode
|
|
8
8
|
|
|
9
|
-
from instrumentation.
|
|
10
|
-
from instrumentation.openai
|
|
9
|
+
from constants.instrumentation.common import SERVICE_PROVIDERS
|
|
10
|
+
from constants.instrumentation.openai import APIS
|
|
11
11
|
from instrumentation.openai.token_estimation import (calculate_prompt_tokens,
|
|
12
12
|
estimate_tokens)
|
|
13
13
|
|
|
@@ -94,9 +94,9 @@ def chat_completions_create(original_method, version, tracer):
|
|
|
94
94
|
attributes.llm_top_p = kwargs.get('top_p')
|
|
95
95
|
if kwargs.get('user') is not None:
|
|
96
96
|
attributes.llm_user = kwargs.get('user')
|
|
97
|
-
if kwargs.get('functions') is not None:
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
# if kwargs.get('functions') is not None:
|
|
98
|
+
# attributes.llm_function_prompts = json.dumps(
|
|
99
|
+
# kwargs.get('functions'))
|
|
100
100
|
|
|
101
101
|
# TODO(Karthik): Gotta figure out how to handle streaming with context
|
|
102
102
|
# with tracer.start_as_current_span(APIS["CHAT_COMPLETION"]["METHOD"],
|
|
@@ -4,9 +4,8 @@ to calculate the price of a model based on its usage.
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from tiktoken import get_encoding
|
|
7
|
-
|
|
8
|
-
from instrumentation.
|
|
9
|
-
TIKTOKEN_MODEL_MAPPING)
|
|
7
|
+
from constants.instrumentation.openai import OPENAI_COST_TABLE
|
|
8
|
+
from constants.instrumentation.common import TIKTOKEN_MODEL_MAPPING
|
|
10
9
|
|
|
11
10
|
|
|
12
11
|
def estimate_tokens(prompt):
|
|
@@ -11,7 +11,7 @@ from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
|
|
|
11
11
|
from opentelemetry.trace import get_tracer
|
|
12
12
|
from wrapt import wrap_function_wrapper
|
|
13
13
|
|
|
14
|
-
from instrumentation.pinecone
|
|
14
|
+
from constants.instrumentation.pinecone import APIS
|
|
15
15
|
from instrumentation.pinecone.patch import generic_patch
|
|
16
16
|
|
|
17
17
|
|
|
@@ -4,8 +4,8 @@ from langtrace.trace_attributes import DatabaseSpanAttributes
|
|
|
4
4
|
from opentelemetry.trace import SpanKind
|
|
5
5
|
from opentelemetry.trace.status import Status, StatusCode
|
|
6
6
|
|
|
7
|
-
from instrumentation.
|
|
8
|
-
from instrumentation.pinecone
|
|
7
|
+
from constants.instrumentation.common import SERVICE_PROVIDERS
|
|
8
|
+
from constants.instrumentation.pinecone import APIS
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
def generic_patch(original_method, method, version, tracer):
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: langtrace-python-sdk
|
|
3
|
-
Version: 1.0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.0.12
|
|
4
|
+
Summary: Python SDK for LangTrace
|
|
5
5
|
Home-page: https://github.com/Scale3-Labs/langtrace-python-sdk
|
|
6
|
-
Author:
|
|
6
|
+
Author: Scale3 Labs
|
|
7
7
|
Author-email: ali@scale3labs.com
|
|
8
|
+
Maintainer: ['Karthik Kalyanaraman', 'Ali Waleed', 'Rohit Kadhe']
|
|
9
|
+
License: AGPL-3.0-or-later
|
|
8
10
|
Classifier: Programming Language :: Python :: 3
|
|
9
11
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
12
|
Classifier: Operating System :: OS Independent
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
constants/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
constants/instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
constants/instrumentation/chroma.py,sha256=hiPGYdHS0Yj4Kh3eaYBbuCAl_swqIygu80yFqkOgdak,955
|
|
4
|
+
constants/instrumentation/common.py,sha256=boc8W2xUXXwRqf7d8FNl2EmUXvSjbDju_QFY03nzbGw,493
|
|
5
|
+
constants/instrumentation/openai.py,sha256=wQ3vb7C3Okt7XJyxDfo9LWwtEggx8s9DzQ1JKPJ7pw8,1050
|
|
6
|
+
constants/instrumentation/pinecone.py,sha256=8RZpXA1Qs2aQd8L_1qpevloPGMdY-IIr_hjz3jVK3PY,471
|
|
7
|
+
examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
examples/chroma_example/__init__.py,sha256=ktveH9U1bkZwKUIqwGSJy_fPmIQ0dYwUuDRPUSY_s-k,24
|
|
9
|
+
examples/chroma_example/basic.py,sha256=6mT0l4KMDMJCrn8mwBCyetFaeGrpKy52uYCrOPGKhB4,781
|
|
10
|
+
examples/langchain_example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
|
+
examples/langchain_example/basic.py,sha256=m2OtfaWwGbhTgClbDdoCpvYExOOUOZboBSFrKmPWzyM,1943
|
|
12
|
+
examples/langchain_example/tool.py,sha256=3g85yyGRoOmhNcbE16qsakODvhlQJxOB2gaggoFw1qc,2440
|
|
13
|
+
examples/llamaindex_example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
+
examples/llamaindex_example/basic.py,sha256=OeOwv8lhY87dfmL8o4K69UCrgDTip41LwDe-BoxDf0I,567
|
|
15
|
+
examples/openai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
examples/openai/chat_completion.py,sha256=kxMoMR2DizU-QcgLbUv1xedCOM5q-wnftUfsfCAssec,1252
|
|
17
|
+
examples/openai/embeddings_create.py,sha256=XUY-CsXXLNJe6Hsdh2P5w03PomfZSWuy4QlL_yHHgKg,403
|
|
18
|
+
examples/openai/function_calling.py,sha256=BAuw0BAglWodZg9UrhdHsSkpwOEKdiV3zv13J1Bhsmk,2422
|
|
19
|
+
examples/openai/images_generate.py,sha256=5A-jEQcOOW2Z8SJNRv0MiRP5tJOOmMrfMg_78L8mxqQ,390
|
|
20
|
+
examples/pinecone_example/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
+
examples/pinecone_example/basic.py,sha256=g8hd_P662SAQKuJv8M7_XHtl9b7qd8Vlc55xFupX2U4,739
|
|
22
|
+
extensions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
+
extensions/langtrace_exporter.py,sha256=Sd58QwQqGIV4ip3-0D2nzhtB-zbPCCqlE7SR65s3qvE,2115
|
|
24
|
+
init/__init__.py,sha256=tsnStHYS-UYMniJRWmVslRuhbT01MAldx_nU4AZ2Ko0,26
|
|
25
|
+
init/init.py,sha256=Kkfn5e4H8m6yc6Bso8mRNv_IDmfhU5CKb1CvNp0_50k,2614
|
|
26
|
+
instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
+
instrumentation/chroma/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
+
instrumentation/chroma/apis.py,sha256=hiPGYdHS0Yj4Kh3eaYBbuCAl_swqIygu80yFqkOgdak,955
|
|
29
|
+
instrumentation/chroma/instrumentation.py,sha256=YlsyhlRoCYTgCRUvRCmZlxTtEcUQMj35r8-y6u6UX3M,1179
|
|
30
|
+
instrumentation/chroma/patch.py,sha256=TCxTS7sWDmS6Vi2IDS5ZVV4YW-zZh54nqQh6akq-KPo,1955
|
|
31
|
+
instrumentation/langchain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
+
instrumentation/langchain/instrumentation.py,sha256=LXtx5edfHPLRZ9yP0yKbDHlvE7LOJumJMGTqQX5RhhM,2850
|
|
33
|
+
instrumentation/langchain/patch.py,sha256=CtDS-snAKL61XImh9MEN3QQ5XNruic2yN5YaCHtgEUQ,2986
|
|
34
|
+
instrumentation/langchain_community/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
|
+
instrumentation/langchain_community/instrumentation.py,sha256=XWzaHl4FPPlZEhnUlxRB0iO5kPkNVI9siRXZgxF_Yb4,4316
|
|
36
|
+
instrumentation/langchain_community/patch.py,sha256=0nqP0uTtpogYsu4-0fMRAdToKyCpVfl3n21GGuJ6L-o,2880
|
|
37
|
+
instrumentation/langchain_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
+
instrumentation/langchain_core/instrumentation.py,sha256=AYHqyuOwunuMqrTCxzXCbkIDmJbHA6Q40moHntdL4tw,4739
|
|
39
|
+
instrumentation/langchain_core/patch.py,sha256=YQbxlNUJA7XvQDHpVo3Snfpiq1Gen8x92Vs1NmkkuPg,7544
|
|
40
|
+
instrumentation/llamaindex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
41
|
+
instrumentation/llamaindex/instrumentation.py,sha256=WwETor8jLwaDQwnwgbtKZHQ3MwtNIfZSp1aaUn-uLIk,2759
|
|
42
|
+
instrumentation/llamaindex/patch.py,sha256=bcCfjBrBS9sSpge1m3se6NPqsHlw7K0jW-84gGdT6QE,1717
|
|
43
|
+
instrumentation/openai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
44
|
+
instrumentation/openai/instrumentation.py,sha256=Mkk6fwvQ8kS9ykFFc8OffIGbNMYVi6rrBVjVVhjuTjo,1408
|
|
45
|
+
instrumentation/openai/patch.py,sha256=9ch4tcl2fp_EF2bNAOZ8DV4r8VNeSxyV-5YPRDecMsE,12252
|
|
46
|
+
instrumentation/openai/token_estimation.py,sha256=j_JdAZNbAbpLdhSMdVIG5GvGwoIj2ZCC3LRrVTr7Tsg,1544
|
|
47
|
+
instrumentation/pinecone/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
48
|
+
instrumentation/pinecone/instrumentation.py,sha256=I0721lQFARpU9EfQ9eI-Yum80c8wQ48dp8tqLQ4ybGI,1713
|
|
49
|
+
instrumentation/pinecone/patch.py,sha256=TbTQ_eKkoeowyVtEwNYQRervqvVFCjvOeARmNDYXmxE,1852
|
|
50
|
+
utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
51
|
+
utils/with_root_span.py,sha256=CRie2ljHhnHN8bUGDwBM-F18-c6xyoI_238KP8BEO-U,969
|
|
52
|
+
langtrace_python_sdk-1.0.12.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
53
|
+
langtrace_python_sdk-1.0.12.dist-info/METADATA,sha256=SIzpMfuoAPWmyAiMKKm1kS1cq6wKFx73B_xGVFEeZgI,6245
|
|
54
|
+
langtrace_python_sdk-1.0.12.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
55
|
+
langtrace_python_sdk-1.0.12.dist-info/top_level.txt,sha256=oHxTmC4OfJqafm6-frLkJHxcBTTgetWc8lvVt-T_IMs,57
|
|
56
|
+
langtrace_python_sdk-1.0.12.dist-info/RECORD,,
|
utils/__init__.py
ADDED
|
File without changes
|
instrumentation/openai/apis.py
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
APIs to instrument OpenAI.
|
|
3
|
-
"""
|
|
4
|
-
from langtrace.trace_attributes import OpenAIMethods
|
|
5
|
-
|
|
6
|
-
APIS = {
|
|
7
|
-
"CHAT_COMPLETION": {
|
|
8
|
-
"METHOD": OpenAIMethods.CHAT_COMPLETION.value,
|
|
9
|
-
"ENDPOINT": "/chat/completions",
|
|
10
|
-
},
|
|
11
|
-
"IMAGES_GENERATION": {
|
|
12
|
-
"METHOD": OpenAIMethods.IMAGES_GENERATION.value,
|
|
13
|
-
"ENDPOINT": "/images/generations",
|
|
14
|
-
},
|
|
15
|
-
"EMBEDDINGS_CREATE": {
|
|
16
|
-
"METHOD": OpenAIMethods.EMBEDDINGS_CREATE.value,
|
|
17
|
-
"ENDPOINT": "/embeddings",
|
|
18
|
-
},
|
|
19
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
instrumentation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
instrumentation/constants.py,sha256=YdC62dsYpbbBdMHhfUbaK-cbDM4w4eau0ClUdWVmjmU,336
|
|
3
|
-
instrumentation/with_root_span.py,sha256=CRie2ljHhnHN8bUGDwBM-F18-c6xyoI_238KP8BEO-U,969
|
|
4
|
-
instrumentation/chroma/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
-
instrumentation/chroma/apis.py,sha256=hiPGYdHS0Yj4Kh3eaYBbuCAl_swqIygu80yFqkOgdak,955
|
|
6
|
-
instrumentation/chroma/instrumentation.py,sha256=ySEyLnXcjL7D3sgMHTkxwdpxDpsRVbRJvFOgTxYRHvs,1174
|
|
7
|
-
instrumentation/chroma/patch.py,sha256=2ERORLV4_F1UU2Is8Y4H7aEXNnAPI5XKvW9DnLeEndM,1943
|
|
8
|
-
instrumentation/chroma/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
instrumentation/langchain/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
instrumentation/langchain/instrumentation.py,sha256=LXtx5edfHPLRZ9yP0yKbDHlvE7LOJumJMGTqQX5RhhM,2850
|
|
11
|
-
instrumentation/langchain/patch.py,sha256=f-lq0wdk7doop-Dak2VcGueDsESA_5RKyuGtJQIm4DQ,2979
|
|
12
|
-
instrumentation/langchain_community/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
instrumentation/langchain_community/instrumentation.py,sha256=XWzaHl4FPPlZEhnUlxRB0iO5kPkNVI9siRXZgxF_Yb4,4316
|
|
14
|
-
instrumentation/langchain_community/patch.py,sha256=w6R_lHTDg2GzWRH8BZNocQowedeaNUE-pLfCoRETnTk,2872
|
|
15
|
-
instrumentation/langchain_core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
instrumentation/langchain_core/instrumentation.py,sha256=AYHqyuOwunuMqrTCxzXCbkIDmJbHA6Q40moHntdL4tw,4739
|
|
17
|
-
instrumentation/langchain_core/patch.py,sha256=a314C0IaF0gSa2eh-yO8jHqtZwnWIczQsF3FgCgoiiU,7536
|
|
18
|
-
instrumentation/llamaindex/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
|
-
instrumentation/llamaindex/instrumentation.py,sha256=WwETor8jLwaDQwnwgbtKZHQ3MwtNIfZSp1aaUn-uLIk,2759
|
|
20
|
-
instrumentation/llamaindex/patch.py,sha256=hSSoOij70kIhAleHLOfTW-zNc-N9boQz1iyhoBdVRsQ,1709
|
|
21
|
-
instrumentation/openai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
instrumentation/openai/apis.py,sha256=lMUa6rCkT-fKltngOUxcXd0aNpTb5L8xlqjrdseLIZM,488
|
|
23
|
-
instrumentation/openai/constants.py,sha256=3_xaFfAhh2dpH0072Cijzb5iZazUpmj4SF0iWiMFm1A,973
|
|
24
|
-
instrumentation/openai/instrumentation.py,sha256=Mkk6fwvQ8kS9ykFFc8OffIGbNMYVi6rrBVjVVhjuTjo,1408
|
|
25
|
-
instrumentation/openai/patch.py,sha256=Syktbjz9R-XjGj9QEGojZ4fsxZdQ7Gq4nPOW49J4fLA,12234
|
|
26
|
-
instrumentation/openai/token_estimation.py,sha256=nwTR0yyZs2OB0S3bBviBgd_xMb6oh7nCPMt-HlIlCRU,1549
|
|
27
|
-
instrumentation/openai/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
-
instrumentation/pinecone/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
29
|
-
instrumentation/pinecone/apis.py,sha256=XpKNUfyzEE3HkBN10Qv1w_t1PT-J39pHlotrdU-wvec,477
|
|
30
|
-
instrumentation/pinecone/instrumentation.py,sha256=yfOxKkMtW6GEUQ0E9AWSBdaa07MHzV3o6Q09cAvoWIU,1708
|
|
31
|
-
instrumentation/pinecone/patch.py,sha256=fr07o97CqGc8sUEyMtSiT6watZiTPStRPOrxOzhJGLo,1840
|
|
32
|
-
instrumentation/pinecone/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
-
langtrace_python_sdk-1.0.10.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
34
|
-
langtrace_python_sdk-1.0.10.dist-info/METADATA,sha256=PD7RbdnqjA8lCTuz7rc89PgW6VcrpMxV_DntIHak4bY,6149
|
|
35
|
-
langtrace_python_sdk-1.0.10.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
36
|
-
langtrace_python_sdk-1.0.10.dist-info/top_level.txt,sha256=mdFAULSZuqUiDveRElCIPMvwAkRAYXP4bm_dEI4A96Q,16
|
|
37
|
-
langtrace_python_sdk-1.0.10.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
instrumentation
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|