File tree Expand file tree Collapse file tree
util/opentelemetry-util-genai
src/opentelemetry/util/genai Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535 ToolDefinition ,
3636)
3737
38+ # TODO: Migrate to GenAI constants once available in semconv package
3839_GEN_AI_AGENT_VERSION = "gen_ai.agent.version"
3940_GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS = (
4041 "gen_ai.usage.cache_creation.input_tokens"
Original file line number Diff line number Diff line change 4040 should_emit_event ,
4141)
4242
43- _GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS : str = getattr (
44- GenAI ,
45- "GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS" ,
46- "gen_ai.usage.cache_creation.input_tokens" ,
47- )
48- _GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS : str = getattr (
49- GenAI ,
50- "GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS" ,
51- "gen_ai.usage.cache_read.input_tokens" ,
43+ # TODO: Migrate to GenAI constants once available in semconv package
44+ _GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS = (
45+ "gen_ai.usage.cache_creation.input_tokens"
5246)
47+ _GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS = "gen_ai.usage.cache_read.input_tokens"
5348
5449
5550class InferenceInvocation (GenAIInvocation ):
Original file line number Diff line number Diff line change 5252 gen_ai_attributes .GEN_AI_SYSTEM_INSTRUCTIONS + "_ref"
5353)
5454
55- GEN_AI_TOOL_DEFINITIONS = getattr (
56- gen_ai_attributes , "GEN_AI_TOOL_DEFINITIONS" , "gen_ai.tool.definitions"
57- )
55+ # TODO: Migrate to gen_ai_attributes constant once available in semconv package
56+ GEN_AI_TOOL_DEFINITIONS = "gen_ai.tool.definitions"
5857GEN_AI_TOOL_DEFINITIONS_REF : Final = GEN_AI_TOOL_DEFINITIONS + "_ref"
5958
6059_MESSAGE_INDEX_KEY = "index"
Original file line number Diff line number Diff line change @@ -126,12 +126,6 @@ def test_finish_reasons_empty_list_omitted(self):
126126 invocation .finish_reasons = []
127127 invocation .stop ()
128128 attrs = self .span_exporter .get_finished_spans ()[0 ].attributes
129- assert GenAI .GEN_AI_RESPONSE_FINISH_REASONS not in attrs
130-
131- def test_no_response_model_or_finish_reasons (self ):
132- invocation = self .handler .start_invoke_local_agent ("openai" )
133- invocation .stop ()
134- attrs = self .span_exporter .get_finished_spans ()[0 ].attributes
135129 assert GenAI .GEN_AI_RESPONSE_MODEL not in attrs
136130 assert GenAI .GEN_AI_RESPONSE_FINISH_REASONS not in attrs
137131
@@ -260,12 +254,6 @@ def test_agent_name_set_after_construction(self):
260254 assert span .name == "invoke_agent Named Agent"
261255 assert span .attributes [GenAI .GEN_AI_AGENT_NAME ] == "Named Agent"
262256
263- def test_provider_always_set (self ):
264- invocation = self .handler .start_invoke_local_agent ("gcp_vertex_ai" )
265- invocation .stop ()
266- attrs = self .span_exporter .get_finished_spans ()[0 ].attributes
267- assert attrs [GenAI .GEN_AI_PROVIDER_NAME ] == "gcp_vertex_ai"
268-
269257
270258class TestAgentInvocationContent (unittest .TestCase ):
271259 def setUp (self ):
You can’t perform that action at this time.
0 commit comments