Skip to content

Commit 52c254c

Browse files
authored
fix how to get the right provider (#280)
Signed-off-by: kerthcet <kerthcet@gmail.com>
1 parent 27c7f56 commit 52c254c

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

alphatrion/tracing/cost_enrichment_processor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ def on_end(self, span: ReadableSpan):
5555

5656
# Extract token usage
5757
attributes = span.attributes
58-
# OpenAI SDK populates the `gen_ai.openai.api_base` with base URL
59-
# whereas Bedrock SDK either only populates the `gen_ai.system` with "AWS"
60-
# or the `gen_ai.provider.name` with "aws.bedrock"
58+
# Keep getting the provider from api_base first because some providers (like DeepInfra)
59+
# don't set the provider name in the attributes, it's still OPENAI, which is not correct.
6160
provider = determine_provider(
6261
str(
6362
attributes.get("gen_ai.openai.api_base")
64-
or attributes.get("gen_ai.system")
6563
or attributes.get("gen_ai.provider.name")
64+
# Being deprecated in favor of `gen_ai.provider.name`
65+
or attributes.get("gen_ai.system")
6666
)
6767
)
6868
model = str(

0 commit comments

Comments
 (0)