Skip to content

v0.5.2 add error chunk, remove pipeline and sem-search SDK resource, add agent configurations #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ for chunk in client.agent.run(
prompt="What is the weather in London today?",
stream=True
):
if chunk.chunkType == 'step':
if chunk.chunk_type == 'step':
print(chunk.summary)
elif chunk.chunkType == 'finalOutput':
elif chunk.chunk_type == 'finalOutput':
print(chunk.content.result.content)
```

Expand Down Expand Up @@ -262,8 +262,8 @@ async for chunk in client.agent.run(
prompt="What is the weather in London today?",
stream=True
):
if chunk.chunkType == 'step':
if chunk.chunk_type == 'step':
print(chunk.summary)
elif chunk.chunkType == 'finalOutput':
elif chunk.chunk_type == 'finalOutput':
print(chunk.content.result.content)
```
114 changes: 59 additions & 55 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[project]
name = "lmnr"
version = "0.5.1"
version = "0.5.2"
description = "Python SDK for Laminar"
authors = [
{ name = "lmnr.ai", email = "[email protected]" }
Expand Down Expand Up @@ -38,7 +38,7 @@ dependencies = [
# https://discuss.ai.google.dev/t/warning-all-log-messages-before-absl-initializelog-is-called-are-written-to-stderr-e0000-001731955515-629532-17124-init-cc-229-grpc-wait-for-shutdown-with-timeout-timed-out/50020
# https://github.com/grpc/grpc/issues/38490
"grpcio<1.68.0",
"httpx>=0.28.1",
"httpx>=0.25.0",
]

[project.scripts]
Expand All @@ -52,71 +52,75 @@ lmnr = "lmnr.cli:cli"
# `uv add lmnr --extra anthropic --extra openai`
# `poetry add 'lmnr[anthropic,openai]'`

alephalpha=["opentelemetry-instrumentation-alephalpha>=0.38.12"]
anthropic=["opentelemetry-instrumentation-anthropic>=0.38.12"]
bedrock=["opentelemetry-instrumentation-bedrock>=0.38.12"]
chromadb=["opentelemetry-instrumentation-chromadb>=0.38.12"]
cohere=["opentelemetry-instrumentation-cohere>=0.38.12"]
google-generativeai=["opentelemetry-instrumentation-google-generativeai>=0.38.12"]
groq=["opentelemetry-instrumentation-groq>=0.38.12"]
haystack=["opentelemetry-instrumentation-haystack>=0.38.12"]
lancedb=["opentelemetry-instrumentation-lancedb>=0.38.12"]
langchain=["opentelemetry-instrumentation-langchain>=0.38.12"]
llamaindex=["opentelemetry-instrumentation-llamaindex>=0.38.12"]
marqo=["opentelemetry-instrumentation-marqo>=0.38.12"]
milvus=["opentelemetry-instrumentation-milvus>=0.38.12"]
mistralai=["opentelemetry-instrumentation-mistralai>=0.38.12"]
ollama=["opentelemetry-instrumentation-ollama>=0.38.12"]
openai=["opentelemetry-instrumentation-openai>=0.38.12"]
pinecone=["opentelemetry-instrumentation-pinecone>=0.38.12"]
qdrant=["opentelemetry-instrumentation-qdrant>=0.38.12"]
replicate=["opentelemetry-instrumentation-replicate>=0.38.12"]
sagemaker=["opentelemetry-instrumentation-sagemaker>=0.38.12"]
together=["opentelemetry-instrumentation-together>=0.38.12"]
transformers=["opentelemetry-instrumentation-transformers>=0.38.12"]
vertexai=["opentelemetry-instrumentation-vertexai>=0.38.12"]
watsonx=["opentelemetry-instrumentation-watsonx>=0.38.12"]
weaviate=["opentelemetry-instrumentation-weaviate>=0.38.12"]
alephalpha=["opentelemetry-instrumentation-alephalpha>=0.39.2"]
anthropic=["opentelemetry-instrumentation-anthropic>=0.39.2"]
bedrock=["opentelemetry-instrumentation-bedrock>=0.39.2"]
chromadb=["opentelemetry-instrumentation-chromadb>=0.39.2"]
cohere=["opentelemetry-instrumentation-cohere>=0.39.2"]
google-generativeai=["opentelemetry-instrumentation-google-generativeai>=0.39.2"]
groq=["opentelemetry-instrumentation-groq>=0.39.2"]
haystack=["opentelemetry-instrumentation-haystack>=0.39.2"]
lancedb=["opentelemetry-instrumentation-lancedb>=0.39.2"]
langchain=["opentelemetry-instrumentation-langchain>=0.39.2"]
llamaindex=["opentelemetry-instrumentation-llamaindex>=0.39.2"]
marqo=["opentelemetry-instrumentation-marqo>=0.39.2"]
milvus=["opentelemetry-instrumentation-milvus>=0.39.2"]
mistralai=["opentelemetry-instrumentation-mistralai>=0.39.2"]
ollama=["opentelemetry-instrumentation-ollama>=0.39.2"]
openai=["opentelemetry-instrumentation-openai>=0.39.2"]
pinecone=["opentelemetry-instrumentation-pinecone>=0.39.2"]
qdrant=["opentelemetry-instrumentation-qdrant>=0.39.2"]
replicate=["opentelemetry-instrumentation-replicate>=0.39.2"]
sagemaker=["opentelemetry-instrumentation-sagemaker>=0.39.2"]
together=["opentelemetry-instrumentation-together>=0.39.2"]
transformers=["opentelemetry-instrumentation-transformers>=0.39.2"]
vertexai=["opentelemetry-instrumentation-vertexai>=0.39.2"]
watsonx=["opentelemetry-instrumentation-watsonx>=0.39.2"]
weaviate=["opentelemetry-instrumentation-weaviate>=0.39.2"]
# `all` is the group added for convenience, if you want to install all
# the instrumentations.
all = [
"opentelemetry-instrumentation-alephalpha>=0.38.12",
"opentelemetry-instrumentation-anthropic>=0.38.12",
"opentelemetry-instrumentation-bedrock>=0.38.12",
"opentelemetry-instrumentation-chromadb>=0.38.12",
"opentelemetry-instrumentation-cohere>=0.38.12",
"opentelemetry-instrumentation-google-generativeai>=0.38.12",
"opentelemetry-instrumentation-groq>=0.38.12",
"opentelemetry-instrumentation-haystack>=0.38.12",
"opentelemetry-instrumentation-lancedb>=0.38.12",
"opentelemetry-instrumentation-langchain>=0.38.12",
"opentelemetry-instrumentation-llamaindex>=0.38.12",
"opentelemetry-instrumentation-marqo>=0.38.12",
"opentelemetry-instrumentation-milvus>=0.38.12",
"opentelemetry-instrumentation-mistralai>=0.38.12",
"opentelemetry-instrumentation-ollama>=0.38.12",
"opentelemetry-instrumentation-openai>=0.38.12",
"opentelemetry-instrumentation-pinecone>=0.38.12",
"opentelemetry-instrumentation-qdrant>=0.38.12",
"opentelemetry-instrumentation-replicate>=0.38.12",
"opentelemetry-instrumentation-sagemaker>=0.38.12",
"opentelemetry-instrumentation-together>=0.38.12",
"opentelemetry-instrumentation-transformers>=0.38.12",
"opentelemetry-instrumentation-vertexai>=0.38.12",
"opentelemetry-instrumentation-watsonx>=0.38.12",
"opentelemetry-instrumentation-weaviate>=0.38.12"
"opentelemetry-instrumentation-alephalpha>=0.39.2",
"opentelemetry-instrumentation-anthropic>=0.39.2",
"opentelemetry-instrumentation-bedrock>=0.39.2",
"opentelemetry-instrumentation-chromadb>=0.39.2",
"opentelemetry-instrumentation-cohere>=0.39.2",
"opentelemetry-instrumentation-google-generativeai>=0.39.2",
"opentelemetry-instrumentation-groq>=0.39.2",
"opentelemetry-instrumentation-haystack>=0.39.2",
"opentelemetry-instrumentation-lancedb>=0.39.2",
"opentelemetry-instrumentation-langchain>=0.39.2",
"opentelemetry-instrumentation-llamaindex>=0.39.2",
"opentelemetry-instrumentation-marqo>=0.39.2",
"opentelemetry-instrumentation-milvus>=0.39.2",
"opentelemetry-instrumentation-mistralai>=0.39.2",
"opentelemetry-instrumentation-ollama>=0.39.2",
"opentelemetry-instrumentation-openai>=0.39.2",
"opentelemetry-instrumentation-pinecone>=0.39.2",
"opentelemetry-instrumentation-qdrant>=0.39.2",
"opentelemetry-instrumentation-replicate>=0.39.2",
"opentelemetry-instrumentation-sagemaker>=0.39.2",
"opentelemetry-instrumentation-together>=0.39.2",
"opentelemetry-instrumentation-transformers>=0.39.2",
"opentelemetry-instrumentation-vertexai>=0.39.2",
"opentelemetry-instrumentation-watsonx>=0.39.2",
"opentelemetry-instrumentation-weaviate>=0.39.2"
]

[dependency-groups]
dev = [
"autopep8",
"flake8",
"pytest>=8.3.4",
"pytest-sugar",
"pytest-asyncio>=0.25.2",
"pytest>=8.3.5",
"pytest-sugar>=1.0.0",
"pytest-asyncio>=0.26.0",
"playwright>=1.51.0"
]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
# we can move to uv_build, once it's more stable
# https://github.com/astral-sh/uv/issues/3957
# requires = ["uv_build>=0.6.16,<0.7"]
# build-backend = "uv_build"
8 changes: 0 additions & 8 deletions src/lmnr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
from .sdk.types import (
AgentOutput,
FinalOutputChunkContent,
ChatMessage,
HumanEvaluator,
NodeInput,
PipelineRunError,
PipelineRunResponse,
RunAgentResponseChunk,
StepChunkContent,
TracingLevel,
Expand All @@ -25,7 +21,6 @@
"AgentOutput",
"AsyncLaminarClient",
"Attributes",
"ChatMessage",
"EvaluationDataset",
"FinalOutputChunkContent",
"HumanEvaluator",
Expand All @@ -34,9 +29,6 @@
"LaminarClient",
"LaminarDataset",
"LaminarSpanContext",
"NodeInput",
"PipelineRunError",
"PipelineRunResponse",
"RunAgentResponseChunk",
"StepChunkContent",
"TracingLevel",
Expand Down
4 changes: 4 additions & 0 deletions src/lmnr/openllmetry_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,7 @@ def init(
@staticmethod
def flush() -> bool:
return TracerManager.__tracer_wrapper.flush()

@staticmethod
def shutdown():
TracerManager.__tracer_wrapper.shutdown()
33 changes: 20 additions & 13 deletions src/lmnr/openllmetry_sdk/decorators/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
from functools import wraps
import logging
import os
import pydantic
import types
from typing import Any, Literal, Optional, Union
Expand Down Expand Up @@ -40,6 +39,7 @@ def json_dumps(data: dict) -> str:
def entity_method(
name: Optional[str] = None,
ignore_input: bool = False,
ignore_inputs: Optional[list[str]] = None,
ignore_output: bool = False,
span_type: Union[Literal["DEFAULT"], Literal["LLM"], Literal["TOOL"]] = "DEFAULT",
):
Expand All @@ -58,9 +58,15 @@ def wrap(*args, **kwargs):
ctx_token = context_api.attach(ctx)

try:
if _should_send_prompts() and not ignore_input:
if not ignore_input:
inp = json_dumps(
get_input_from_func_args(fn, is_method(fn), args, kwargs)
get_input_from_func_args(
fn,
is_method=is_method(fn),
func_args=args,
func_kwargs=kwargs,
ignore_inputs=ignore_inputs,
)
)
if len(inp) > MAX_MANUAL_SPAN_PAYLOAD_SIZE:
span.set_attribute(
Expand All @@ -83,7 +89,7 @@ def wrap(*args, **kwargs):
return _handle_generator(span, res)

try:
if _should_send_prompts() and not ignore_output:
if not ignore_output:
output = json_dumps(res)
if len(output) > MAX_MANUAL_SPAN_PAYLOAD_SIZE:
span.set_attribute(
Expand All @@ -108,6 +114,7 @@ def wrap(*args, **kwargs):
def aentity_method(
name: Optional[str] = None,
ignore_input: bool = False,
ignore_inputs: Optional[list[str]] = None,
ignore_output: bool = False,
span_type: Union[Literal["DEFAULT"], Literal["LLM"], Literal["TOOL"]] = "DEFAULT",
):
Expand All @@ -126,9 +133,15 @@ async def wrap(*args, **kwargs):
ctx_token = context_api.attach(ctx)

try:
if _should_send_prompts() and not ignore_input:
if not ignore_input:
inp = json_dumps(
get_input_from_func_args(fn, is_method(fn), args, kwargs)
get_input_from_func_args(
fn,
is_method=is_method(fn),
func_args=args,
func_kwargs=kwargs,
ignore_inputs=ignore_inputs,
)
)
if len(inp) > MAX_MANUAL_SPAN_PAYLOAD_SIZE:
span.set_attribute(
Expand All @@ -151,7 +164,7 @@ async def wrap(*args, **kwargs):
return await _ahandle_generator(span, ctx_token, res)

try:
if _should_send_prompts() and not ignore_output:
if not ignore_output:
output = json_dumps(res)
if len(output) > MAX_MANUAL_SPAN_PAYLOAD_SIZE:
span.set_attribute(
Expand Down Expand Up @@ -192,12 +205,6 @@ async def _ahandle_generator(span, ctx_token, res):
context_api.detach(ctx_token)


def _should_send_prompts():
return (
os.getenv("TRACELOOP_TRACE_CONTENT") or "true"
).lower() == "true" or context_api.get_value("override_enable_content_tracing")


def _process_exception(span: Span, e: Exception):
# Note that this `escaped` is sent as a StringValue("True"), not a boolean.
span.record_exception(e, escaped=True)
1 change: 1 addition & 0 deletions src/lmnr/openllmetry_sdk/instruments.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Instruments(Enum):
CHROMA = "chroma"
COHERE = "cohere"
GOOGLE_GENERATIVEAI = "google_generativeai"
GOOGLE_GENAI = "google_genai"
GROQ = "groq"
HAYSTACK = "haystack"
LANCEDB = "lancedb"
Expand Down
Loading
Loading