Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ddtrace/contrib/internal/openai/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,6 @@ def patched_client_init(openai, pin, func, instance, args, kwargs):
func(*args, **kwargs)
integration = openai._datadog_integration
integration._client = instance
api_key = kwargs.get("api_key")
if api_key is None:
api_key = instance.api_key
if api_key is not None:
integration.user_api_key = api_key
return


Expand Down
13 changes: 0 additions & 13 deletions ddtrace/llmobs/_integrations/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,7 @@ def __init__(self, integration_config, openai):
# object that is strongly linked with configuration.
super().__init__(integration_config)
self._openai = openai
self._user_api_key = None
self._client = None
if self._openai.api_key is not None:
self.user_api_key = self._openai.api_key

@property
def user_api_key(self) -> Optional[str]:
"""Get a representation of the user API key for tagging."""
return self._user_api_key

@user_api_key.setter
def user_api_key(self, value: str) -> None:
# Match the API key representation that OpenAI uses in their UI.
self._user_api_key = "sk-...%s" % value[-4:]

def trace(self, pin: Pin, operation_id: str, submit_to_llmobs: bool = False, **kwargs: Dict[str, Any]) -> Span:
traced_operations = (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
fixes:
- |
openai: Resolves an issue where instantiating an OpenAI client with a non-string API key resulted in parsing issues.
Loading