Skip to content

Commit

Permalink
Merge branch 'main' into ollama-tool-calling
Browse files Browse the repository at this point in the history
  • Loading branch information
sathvikrav authored Oct 5, 2024
2 parents 3f7b758 + d9523bc commit 87c4eb2
Show file tree
Hide file tree
Showing 56 changed files with 318 additions and 291 deletions.
4 changes: 3 additions & 1 deletion .cz.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ tag_format = "v$version"
version_scheme = "pep440"
major_version_zero = true
update_changelog_on_bump = true
version = "0.32.0"
version = "0.32.2"
version_files = [
"packages/opentelemetry-instrumentation-groq/pyproject.toml:^version",
"packages/opentelemetry-instrumentation-groq/opentelemetry/instrumentation/groq/version.py",
Expand Down Expand Up @@ -42,6 +42,8 @@ version_files = [
"packages/opentelemetry-instrumentation-qdrant/opentelemetry/instrumentation/qdrant/version.py",
"packages/opentelemetry-instrumentation-replicate/pyproject.toml:^version",
"packages/opentelemetry-instrumentation-replicate/opentelemetry/instrumentation/replicate/version.py",
"packages/opentelemetry-instrumentation-sagemaker/pyproject.toml:^version",
"packages/opentelemetry-instrumentation-sagemaker/opentelemetry/instrumentation/sagemaker/version.py",
"packages/opentelemetry-instrumentation-together/pyproject.toml:^version",
"packages/opentelemetry-instrumentation-together/opentelemetry/instrumentation/together/version.py",
"packages/opentelemetry-instrumentation-transformers/pyproject.toml:^version",
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## v0.32.2 (2024-10-04)

### Fix

- **traceloop-sdk**: add aiohttp as dependency (#2094)

## v0.32.1 (2024-10-03)

### Fix

- **anthropic**: Replace count_tokens with usage for newer models (#2086)

## v0.32.0 (2024-10-03)

### Feat
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-alephalpha"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Aleph Alpha instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,26 @@ async def _aset_token_usage(
if not isinstance(response, dict):
response = response.__dict__

prompt_tokens = 0
if hasattr(anthropic, "count_tokens"):
if request.get("prompt"):
prompt_tokens = await anthropic.count_tokens(request.get("prompt"))
elif request.get("messages"):
prompt_tokens = 0
for m in request.get("messages"):
content = m.get("content")
if isinstance(content, str):
prompt_tokens += await anthropic.count_tokens(content)
elif isinstance(content, list):
for item in content:
# TODO: handle image tokens
if isinstance(item, dict) and item.get("type") == "text":
prompt_tokens += await anthropic.count_tokens(
item.get("text", "")
)
if usage := response.get("usage"):
prompt_tokens = usage.input_tokens
else:
prompt_tokens = 0
if hasattr(anthropic, "count_tokens"):
if request.get("prompt"):
prompt_tokens = await anthropic.count_tokens(request.get("prompt"))
elif request.get("messages"):
prompt_tokens = 0
for m in request.get("messages"):
content = m.get("content")
if isinstance(content, str):
prompt_tokens += await anthropic.count_tokens(content)
elif isinstance(content, list):
for item in content:
# TODO: handle image tokens
if isinstance(item, dict) and item.get("type") == "text":
prompt_tokens += await anthropic.count_tokens(
item.get("text", "")
)

if token_histogram and type(prompt_tokens) is int and prompt_tokens >= 0:
token_histogram.record(
Expand All @@ -209,14 +212,17 @@ async def _aset_token_usage(
},
)

completion_tokens = 0
if hasattr(anthropic, "count_tokens"):
if response.get("completion"):
completion_tokens = await anthropic.count_tokens(response.get("completion"))
elif response.get("content"):
completion_tokens = await anthropic.count_tokens(
response.get("content")[0].text
)
if usage := response.get("usage"):
completion_tokens = usage.output_tokens
else:
completion_tokens = 0
if hasattr(anthropic, "count_tokens"):
if response.get("completion"):
completion_tokens = await anthropic.count_tokens(response.get("completion"))
elif response.get("content"):
completion_tokens = await anthropic.count_tokens(
response.get("content")[0].text
)

if token_histogram and type(completion_tokens) is int and completion_tokens >= 0:
token_histogram.record(
Expand Down Expand Up @@ -264,23 +270,26 @@ def _set_token_usage(
if not isinstance(response, dict):
response = response.__dict__

prompt_tokens = 0
if hasattr(anthropic, "count_tokens"):
if request.get("prompt"):
prompt_tokens = anthropic.count_tokens(request.get("prompt"))
elif request.get("messages"):
prompt_tokens = 0
for m in request.get("messages"):
content = m.get("content")
if isinstance(content, str):
prompt_tokens += anthropic.count_tokens(content)
elif isinstance(content, list):
for item in content:
# TODO: handle image tokens
if isinstance(item, dict) and item.get("type") == "text":
prompt_tokens += anthropic.count_tokens(
item.get("text", "")
)
if usage := response.get("usage"):
prompt_tokens = usage.input_tokens
else:
prompt_tokens = 0
if hasattr(anthropic, "count_tokens"):
if request.get("prompt"):
prompt_tokens = anthropic.count_tokens(request.get("prompt"))
elif request.get("messages"):
prompt_tokens = 0
for m in request.get("messages"):
content = m.get("content")
if isinstance(content, str):
prompt_tokens += anthropic.count_tokens(content)
elif isinstance(content, list):
for item in content:
# TODO: handle image tokens
if isinstance(item, dict) and item.get("type") == "text":
prompt_tokens += anthropic.count_tokens(
item.get("text", "")
)

if token_histogram and type(prompt_tokens) is int and prompt_tokens >= 0:
token_histogram.record(
Expand All @@ -291,12 +300,15 @@ def _set_token_usage(
},
)

completion_tokens = 0
if hasattr(anthropic, "count_tokens"):
if response.get("completion"):
completion_tokens = anthropic.count_tokens(response.get("completion"))
elif response.get("content"):
completion_tokens = anthropic.count_tokens(response.get("content")[0].text)
if usage := response.get("usage"):
completion_tokens = usage.output_tokens
else:
completion_tokens = 0
if hasattr(anthropic, "count_tokens"):
if response.get("completion"):
completion_tokens = anthropic.count_tokens(response.get("completion"))
elif response.get("content"):
completion_tokens = anthropic.count_tokens(response.get("content")[0].text)

if token_histogram and type(completion_tokens) is int and completion_tokens >= 0:
token_histogram.record(
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-anthropic"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Anthropic instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def test_anthropic_message_create(exporter, reader):
anthropic_span.attributes.get(f"{SpanAttributes.LLM_COMPLETIONS}.0.content")
== response.content[0].text
)
assert anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS] == 8
assert anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS] == 17
assert (
anthropic_span.attributes[SpanAttributes.LLM_USAGE_COMPLETION_TOKENS]
+ anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS]
Expand Down Expand Up @@ -255,7 +255,7 @@ def test_anthropic_multi_modal(exporter):
anthropic_span.attributes.get(f"{SpanAttributes.LLM_COMPLETIONS}.0.content")
== response.content[0].text
)
assert anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS] == 5
assert anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS] == 1381
assert (
anthropic_span.attributes[SpanAttributes.LLM_USAGE_COMPLETION_TOKENS]
+ anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS]
Expand Down Expand Up @@ -314,7 +314,7 @@ async def test_anthropic_async_multi_modal(exporter):
anthropic_span.attributes.get(f"{SpanAttributes.LLM_COMPLETIONS}.0.content")
== response.content[0].text
)
assert anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS] == 5
assert anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS] == 1311
assert (
anthropic_span.attributes[SpanAttributes.LLM_USAGE_COMPLETION_TOKENS]
+ anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS]
Expand Down Expand Up @@ -457,7 +457,7 @@ async def test_async_anthropic_message_create(exporter, reader):
anthropic_span.attributes.get(f"{SpanAttributes.LLM_COMPLETIONS}.0.content")
== response.content[0].text
)
assert anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS] == 8
assert anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS] == 17
assert (
anthropic_span.attributes[SpanAttributes.LLM_USAGE_COMPLETION_TOKENS]
+ anthropic_span.attributes[SpanAttributes.LLM_USAGE_PROMPT_TOKENS]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-bedrock"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Bedrock instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-chromadb"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Chroma DB instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-cohere"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Cohere instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-google-generativeai"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Google Generative AI instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
2 changes: 1 addition & 1 deletion packages/opentelemetry-instrumentation-groq/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-groq"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Groq instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-haystack"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Haystack instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-lancedb"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Lancedb instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-langchain"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Langchain instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-llamaindex"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry LlamaIndex instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-marqo"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Marqo instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-milvus"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Milvus instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-mistralai"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Mistral AI instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-ollama"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry Ollama instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ show_missing = true

[tool.poetry]
name = "opentelemetry-instrumentation-openai"
version = "0.32.0"
version = "0.32.2"
description = "OpenTelemetry OpenAI instrumentation"
authors = [
"Gal Kleinman <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.32.0"
__version__ = "0.32.2"
Loading

0 comments on commit 87c4eb2

Please sign in to comment.