diff --git a/python/instrumentation/openinference-instrumentation-openai/src/openinference/instrumentation/openai/_response_accumulator.py b/python/instrumentation/openinference-instrumentation-openai/src/openinference/instrumentation/openai/_response_accumulator.py index 01c3ecb5b..658e7d4bf 100644 --- a/python/instrumentation/openinference-instrumentation-openai/src/openinference/instrumentation/openai/_response_accumulator.py +++ b/python/instrumentation/openinference-instrumentation-openai/src/openinference/instrumentation/openai/_response_accumulator.py @@ -50,7 +50,7 @@ class _ChatCompletionAccumulator: def __init__(self) -> None: self._is_null = True - self._cached_result: Optional[Mapping[str, Any]] = None + self._cached_result: Optional[Dict[str, Any]] = None self._values = _ValuesAccumulator( choices=_IndexedAccumulator( lambda: _ValuesAccumulator( @@ -81,11 +81,11 @@ def process_chunk(self, chunk: ChatCompletionChunk) -> None: choice["message"] = delta self._values += values - def _result(self) -> Optional[Mapping[str, Any]]: + def _result(self) -> Optional[Dict[str, Any]]: if self._is_null: return None if not self._cached_result: - self._cached_result = MappingProxyType(dict(self._values)) + self._cached_result = dict(self._values) return self._cached_result def get_attributes(self) -> Iterator[Tuple[str, AttributeValue]]: @@ -115,7 +115,7 @@ class _CompletionAccumulator: def __init__(self) -> None: self._is_null = True - self._cached_result: Optional[Mapping[str, Any]] = None + self._cached_result: Optional[Dict[str, Any]] = None self._values = _ValuesAccumulator( choices=_IndexedAccumulator(lambda: _ValuesAccumulator(text=_StringAccumulator())), ) @@ -131,11 +131,11 @@ def process_chunk(self, chunk: Completion) -> None: values = chunk.model_dump(exclude_unset=True) self._values += values - def _result(self) -> Optional[Mapping[str, Any]]: + def _result(self) -> Optional[Dict[str, Any]]: if self._is_null: return None if not self._cached_result: - self._cached_result = MappingProxyType(dict(self._values)) + self._cached_result = dict(self._values) return self._cached_result def get_attributes(self) -> Iterator[Tuple[str, AttributeValue]]: