Skip to content

Commit 9efd5bc

Browse files
committed
Merge branch 'development' into release-3.8.2
2 parents 25ddc11 + 5da182f commit 9efd5bc

File tree

12 files changed

+589
-68
lines changed

12 files changed

+589
-68
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import os
2+
3+
from cleanlab_tlm import TLM
4+
from dotenv import find_dotenv, load_dotenv
5+
6+
from langtrace_python_sdk import langtrace
7+
8+
_ = load_dotenv(find_dotenv())
9+
10+
langtrace.init()
11+
12+
api_key = os.getenv("CLEANLAB_API_KEY")
13+
tlm = TLM(api_key=api_key, options={"log": ["explanation"], "model": "gpt-4o-mini"}) # GPT, Claude, etc
14+
out = tlm.prompt("What's the third month of the year alphabetically?")
15+
trustworthiness_score = tlm.get_trustworthiness_score("What's the first month of the year?", response="January")
16+
17+
print(out)
18+
print(trustworthiness_score)

src/langtrace_python_sdk/constants/instrumentation/common.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"ARCH": "Arch",
1414
"AZURE": "Azure",
1515
"CHROMA": "Chroma",
16+
"CLEANLAB": "CleanLab",
17+
"COHERE": "Cohere",
1618
"CREWAI": "CrewAI",
1719
"DEEPSEEK": "DeepSeek",
1820
"DSPY": "DSPy",
@@ -25,7 +27,6 @@
2527
"LLAMAINDEX": "LlamaIndex",
2628
"OPENAI": "OpenAI",
2729
"PINECONE": "Pinecone",
28-
"COHERE": "Cohere",
2930
"PPLX": "Perplexity",
3031
"QDRANT": "Qdrant",
3132
"WEAVIATE": "Weaviate",
@@ -42,6 +43,7 @@
4243
"MILVUS": "Milvus",
4344
"GRAPHLIT": "Graphlit",
4445
"PHIDATA": "Phidata",
46+
"AGNO": "Agno",
4547
}
4648

4749
LANGTRACE_ADDITIONAL_SPAN_ATTRIBUTES_KEY = "langtrace_additional_attributes"

src/langtrace_python_sdk/instrumentation/__init__.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
from .agno import AgnoInstrumentation
12
from .anthropic import AnthropicInstrumentation
23
from .autogen import AutogenInstrumentation
34
from .aws_bedrock import AWSBedrockInstrumentation
45
from .cerebras import CerebrasInstrumentation
56
from .chroma import ChromaInstrumentation
7+
from .cleanlab import CleanLabInstrumentation
68
from .cohere import CohereInstrumentation
79
from .crewai import CrewAIInstrumentation
810
from .crewai_tools import CrewaiToolsInstrumentation
911
from .dspy import DspyInstrumentation
1012
from .embedchain import EmbedchainInstrumentation
1113
from .gemini import GeminiInstrumentation
1214
from .google_genai import GoogleGenaiInstrumentation
15+
from .graphlit import GraphlitInstrumentation
1316
from .groq import GroqInstrumentation
1417
from .langchain import LangchainInstrumentation
1518
from .langchain_community import LangchainCommunityInstrumentation
@@ -21,16 +24,12 @@
2124
from .mistral import MistralInstrumentation
2225
from .ollama import OllamaInstrumentor
2326
from .openai import OpenAIInstrumentation
27+
from .phidata import PhiDataInstrumentation
2428
from .pinecone import PineconeInstrumentation
2529
from .pymongo import PyMongoInstrumentation
2630
from .qdrant import QdrantInstrumentation
2731
from .vertexai import VertexAIInstrumentation
2832
from .weaviate import WeaviateInstrumentation
29-
from .cerebras import CerebrasInstrumentation
30-
from .milvus import MilvusInstrumentation
31-
from .google_genai import GoogleGenaiInstrumentation
32-
from .graphlit import GraphlitInstrumentation
33-
from .phidata import PhiDataInstrumentation
3433

3534
__all__ = [
3635
"AnthropicInstrumentation",
@@ -63,4 +62,6 @@
6362
"CrewaiToolsInstrumentation",
6463
"GraphlitInstrumentation",
6564
"PhiDataInstrumentation",
65+
"AgnoInstrumentation",
66+
"CleanLabInstrumentation",
6667
]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .instrumentation import AgnoInstrumentation
2+
3+
__all__ = [
4+
"AgnoInstrumentation",
5+
]
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
"""
2+
Copyright (c) 2024 Scale3 Labs
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
"""
16+
17+
from opentelemetry.instrumentation.instrumentor import BaseInstrumentor
18+
from opentelemetry.trace import get_tracer
19+
from wrapt import wrap_function_wrapper as _W
20+
from typing import Collection
21+
from importlib_metadata import version as v
22+
from .patch import patch_agent, patch_memory
23+
24+
class AgnoInstrumentation(BaseInstrumentor):
25+
def instrumentation_dependencies(self) -> Collection[str]:
26+
return ["agno >= 1.1.4"]
27+
28+
def _instrument(self, **kwargs):
29+
tracer_provider = kwargs.get("tracer_provider")
30+
tracer = get_tracer(__name__, "", tracer_provider)
31+
version = v("agno")
32+
33+
try:
34+
_W(
35+
"agno.agent.agent",
36+
"Agent.run",
37+
patch_agent("Agent.run", version, tracer),
38+
)
39+
_W(
40+
"agno.agent.agent",
41+
"Agent.arun",
42+
patch_agent("Agent.arun", version, tracer),
43+
)
44+
_W(
45+
"agno.agent.agent",
46+
"Agent._run",
47+
patch_agent("Agent._run", version, tracer),
48+
)
49+
_W(
50+
"agno.agent.agent",
51+
"Agent._arun",
52+
patch_agent("Agent._arun", version, tracer),
53+
)
54+
55+
_W(
56+
"agno.memory.agent",
57+
"AgentMemory.update_memory",
58+
patch_memory("AgentMemory.update_memory", version, tracer),
59+
)
60+
_W(
61+
"agno.memory.agent",
62+
"AgentMemory.aupdate_memory",
63+
patch_memory("AgentMemory.aupdate_memory", version, tracer),
64+
)
65+
_W(
66+
"agno.memory.agent",
67+
"AgentMemory.update_summary",
68+
patch_memory("AgentMemory.update_summary", version, tracer),
69+
)
70+
_W(
71+
"agno.memory.agent",
72+
"AgentMemory.aupdate_summary",
73+
patch_memory("AgentMemory.aupdate_summary", version, tracer),
74+
)
75+
76+
except Exception:
77+
pass
78+
79+
def _uninstrument(self, **kwargs):
80+
pass

0 commit comments

Comments
 (0)