Skip to content

Commit c8d93f8

Browse files
[FEATURE] Send provider in the usage callback (#75)
* Send provider in the usage callback Signed-off-by: Deepak <[email protected]> * Updated lock file Signed-off-by: Deepak <[email protected]> --------- Signed-off-by: Deepak <[email protected]>
1 parent 04aa44d commit c8d93f8

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

pdm.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ dependencies = [
1212
"python-magic~=0.4.27",
1313
"python-dotenv==1.0.0",
1414
# LLM Triad
15-
"unstract-adapters~=0.21.0",
15+
"unstract-adapters~=0.22.0",
1616
"llama-index==0.10.38",
1717
"tiktoken~=0.4.0",
1818
"transformers==4.37.0",

src/unstract/sdk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "0.37.0"
1+
__version__ = "0.38.0"
22

33

44
def get_sdk_version():

src/unstract/sdk/audit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def push_usage_data(
6969
execution_id = kwargs.get("execution_id", "")
7070
adapter_instance_id = kwargs.get("adapter_instance_id", "")
7171
run_id = kwargs.get("run_id", "")
72+
provider = kwargs.get("provider", "")
7273
llm_usage_reason = ""
7374
if event_type == "llm":
7475
llm_usage_reason = kwargs.get("llm_usage_reason", "")
@@ -80,6 +81,7 @@ def push_usage_data(
8081
"usage_type": event_type,
8182
"llm_usage_reason": llm_usage_reason,
8283
"model_name": model_name,
84+
"provider": provider,
8385
"embedding_tokens": token_counter.total_embedding_token_count,
8486
"prompt_tokens": token_counter.prompt_llm_token_count,
8587
"completion_tokens": token_counter.completion_llm_token_count,

src/unstract/sdk/embedding.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def _get_embedding(self) -> BaseEmbedding:
7171
][Common.ADAPTER]
7272
embedding_metadata = embedding_config_data.get(Common.ADAPTER_METADATA)
7373
embedding_adapter_class = embedding_adapter(embedding_metadata)
74+
self._usage_kwargs["provider"] = embedding_adapter_class.get_provider()
7475
return embedding_adapter_class.get_embedding_instance()
7576
except Exception as e:
7677
self._tool.stream_log(

src/unstract/sdk/llm.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ def _get_llm(self, adapter_instance_id: str) -> LlamaIndexLLM:
106106
]
107107
llm_metadata = llm_config_data.get(Common.ADAPTER_METADATA)
108108
llm_adapter_class: LLMAdapter = llm_adapter(llm_metadata)
109+
self._usage_kwargs["provider"] = llm_adapter_class.get_provider()
109110
llm_instance: LLM = llm_adapter_class.get_llm_instance()
110111
return llm_instance
111112
except Exception as e:

0 commit comments

Comments
 (0)