Skip to content

Same agent Smaller bill. The tools and infrastructure to get more work from your AI. Fewer tokens. Less compute. Lower cost.

[Fix]: Use `general_tokens` instead of `openai_tokens` in LangChain chains (#542)

Bassel-Elwakilebcdcb6cbbf9
diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml
index caca1ab0..c4c4bb53 100644
--- a/sdk/python/pyproject.toml
+++ b/sdk/python/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openlit"
-version = "1.32.8"
+version = "1.32.9"
description = "OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications and GPUs, facilitating the integration of observability into your GenAI-driven projects"
authors = ["OpenLIT"]
repository = "https://github.com/openlit/openlit/tree/main/openlit/python"
diff --git a/sdk/python/src/openlit/instrumentation/langchain/langchain.py b/sdk/python/src/openlit/instrumentation/langchain/langchain.py
index 32279e83..cb063994 100644
--- a/sdk/python/src/openlit/instrumentation/langchain/langchain.py
+++ b/sdk/python/src/openlit/instrumentation/langchain/langchain.py
@@ -523,9 +523,9 @@ def chat(gen_ai_endpoint, version, environment, application_name,
doc.page_content for doc in response.get("input_documents", [])
if isinstance(doc.page_content, str)
]
- input_tokens = sum(general_tokens(text, model) for text in input_texts)
+ input_tokens = sum(general_tokens(text) for text in input_texts)
output_text = response.get("output_text", "")
- output_tokens = general_tokens(output_text, model)
+ output_tokens = general_tokens(output_text)
# Calculate cost of the operation
cost = get_chat_model_cost(