ref(ai): Rename generate_text to text_completion (#5885) · gitcommit90/sentry-python@3debca0 · GitHub
Skip to content

Commit 3debca0

Browse files
authored
ref(ai): Rename generate_text to text_completion (getsentry#5885)
1 parent 7ee6918 commit 3debca0

5 files changed

Lines changed: 26 additions & 18 deletions

File tree

sentry_sdk/consts.py

Lines changed: 1 addition & 1 deletion

sentry_sdk/integrations/huggingface_hub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def setup_once() -> None:
4141
huggingface_hub.inference._client.InferenceClient.text_generation = (
4242
_wrap_huggingface_task(
4343
huggingface_hub.inference._client.InferenceClient.text_generation,
44-
OP.GEN_AI_GENERATE_TEXT,
44+
OP.GEN_AI_TEXT_COMPLETION,
4545
)
4646
)
4747
huggingface_hub.inference._client.InferenceClient.chat_completion = (

sentry_sdk/integrations/langchain.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -377,13 +377,13 @@ def on_llm_start(
377377
watched_span = self._create_span(
378378
run_id,
379379
parent_run_id,
380-
op=OP.GEN_AI_GENERATE_TEXT,
381-
name=f"generate_text {model}".strip(),
380+
op=OP.GEN_AI_TEXT_COMPLETION,
381+
name=f"text_completion {model}".strip(),
382382
origin=LangchainIntegration.origin,
383383
)
384384
span = watched_span.span
385385

386-
span.set_data(SPANDATA.GEN_AI_OPERATION_NAME, "generate_text")
386+
span.set_data(SPANDATA.GEN_AI_OPERATION_NAME, "text_completion")
387387

388388
pipeline_name = kwargs.get("name")
389389
if pipeline_name:

tests/integrations/huggingface_hub/test_huggingface_hub.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,12 @@ def test_text_generation(
507507

508508
assert span is not None
509509

510-
assert span["op"] == "gen_ai.generate_text"
511-
assert span["description"] == "generate_text test-model"
510+
assert span["op"] == "gen_ai.text_completion"
511+
assert span["description"] == "text_completion test-model"
512512
assert span["origin"] == "auto.ai.huggingface_hub"
513513

514514
expected_data = {
515-
"gen_ai.operation.name": "generate_text",
515+
"gen_ai.operation.name": "text_completion",
516516
"gen_ai.request.model": "test-model",
517517
"gen_ai.response.finish_reasons": "length",
518518
"gen_ai.response.streaming": False,
@@ -576,12 +576,12 @@ def test_text_generation_streaming(
576576

577577
assert span is not None
578578

579-
assert span["op"] == "gen_ai.generate_text"
580-
assert span["description"] == "generate_text test-model"
579+
assert span["op"] == "gen_ai.text_completion"
580+
assert span["description"] == "text_completion test-model"
581581
assert span["origin"] == "auto.ai.huggingface_hub"
582582

583583
expected_data = {
584-
"gen_ai.operation.name": "generate_text",
584+
"gen_ai.operation.name": "text_completion",
585585
"gen_ai.request.model": "test-model",
586586
"gen_ai.response.finish_reasons": "length",
587587
"gen_ai.response.streaming": True,

tests/integrations/langchain/test_langchain.py

Lines changed: 15 additions & 7 deletions

0 commit comments

Comments
 (0)