File tree Expand file tree Collapse file tree
instrumentation-genai/opentelemetry-instrumentation-openai-v2
src/opentelemetry/instrumentation/openai_v2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515 openai_attributes as OpenAIAttributes ,
1616)
1717
18- from .utils import get_server_address_and_port
18+ from .utils import (
19+ _openai_response_format_to_output_type ,
20+ get_server_address_and_port ,
21+ )
1922
2023if TYPE_CHECKING :
2124 from openai .types .responses .response import Response
@@ -122,12 +125,8 @@ def _extract_output_type_from_value(text_config: object) -> str | None:
122125 return None
123126
124127 format_type = _get_field (format_config , "type" )
125- if format_type == "json_schema" :
126- return GenAIAttributes .GenAiOutputTypeValues .JSON .value
127- if format_type == "text" :
128- return GenAIAttributes .GenAiOutputTypeValues .TEXT .value
129128 if isinstance (format_type , str ):
130- return format_type
129+ return _openai_response_format_to_output_type ( format_type )
131130 return None
132131
133132
Original file line number Diff line number Diff line change 1919
2020DEFAULT_MODEL = "gpt-4o-mini"
2121DEFAULT_EMBEDDING_MODEL = "text-embedding-3-small"
22- GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS = getattr (
23- GenAIAttributes ,
24- "GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS" ,
25- "gen_ai.usage.cache_creation.input_tokens" ,
26- )
27- GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS = getattr (
28- GenAIAttributes ,
29- "GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS" ,
30- "gen_ai.usage.cache_read.input_tokens" ,
22+ GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS = (
23+ "gen_ai.usage.cache_creation.input_tokens"
3124)
25+ GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS = "gen_ai.usage.cache_read.input_tokens"
3226USER_ONLY_PROMPT = [{"role" : "user" , "content" : "Say this is a test" }]
3327USER_ONLY_EXPECTED_INPUT_MESSAGES = [
3428 {
You can’t perform that action at this time.
0 commit comments