Skip to content

Commit

Permalink
[FEATURE] Send provider in the usage callback (#75)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Deepak-Kesavan authored Jul 19, 2024
1 parent 04aa44d commit c8d93f8
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies = [
"python-magic~=0.4.27",
"python-dotenv==1.0.0",
# LLM Triad
"unstract-adapters~=0.21.0",
"unstract-adapters~=0.22.0",
"llama-index==0.10.38",
"tiktoken~=0.4.0",
"transformers==4.37.0",
Expand Down
2 changes: 1 addition & 1 deletion src/unstract/sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.37.0"
__version__ = "0.38.0"


def get_sdk_version():
Expand Down
2 changes: 2 additions & 0 deletions src/unstract/sdk/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def push_usage_data(
execution_id = kwargs.get("execution_id", "")
adapter_instance_id = kwargs.get("adapter_instance_id", "")
run_id = kwargs.get("run_id", "")
provider = kwargs.get("provider", "")
llm_usage_reason = ""
if event_type == "llm":
llm_usage_reason = kwargs.get("llm_usage_reason", "")
Expand All @@ -80,6 +81,7 @@ def push_usage_data(
"usage_type": event_type,
"llm_usage_reason": llm_usage_reason,
"model_name": model_name,
"provider": provider,
"embedding_tokens": token_counter.total_embedding_token_count,
"prompt_tokens": token_counter.prompt_llm_token_count,
"completion_tokens": token_counter.completion_llm_token_count,
Expand Down
1 change: 1 addition & 0 deletions src/unstract/sdk/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _get_embedding(self) -> BaseEmbedding:
][Common.ADAPTER]
embedding_metadata = embedding_config_data.get(Common.ADAPTER_METADATA)
embedding_adapter_class = embedding_adapter(embedding_metadata)
self._usage_kwargs["provider"] = embedding_adapter_class.get_provider()
return embedding_adapter_class.get_embedding_instance()
except Exception as e:
self._tool.stream_log(
Expand Down
1 change: 1 addition & 0 deletions src/unstract/sdk/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def _get_llm(self, adapter_instance_id: str) -> LlamaIndexLLM:
]
llm_metadata = llm_config_data.get(Common.ADAPTER_METADATA)
llm_adapter_class: LLMAdapter = llm_adapter(llm_metadata)
self._usage_kwargs["provider"] = llm_adapter_class.get_provider()
llm_instance: LLM = llm_adapter_class.get_llm_instance()
return llm_instance
except Exception as e:
Expand Down

0 comments on commit c8d93f8

Please sign in to comment.