refactor(agent/gemini): restore GeminiNativeClient context-manager surface (OpenAI-client duck type)

This commit is contained in:
Teknium
2026-09-02 20:32:51 -07:00
parent b21bc2f6da
commit fc48d6c8d0
+7
View File
@@ -614,6 +614,13 @@ class GeminiNativeClient:
with contextlib.suppress(Exception):
self._http.close()
# OpenAI-client duck-type surface: callers may use ``with client:``.
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.close()
def _headers(self) -> Dict[str, str]:
return {"Content-Type": "application/json", "Accept": "application/json", "x-goog-api-key": self.api_key,
"User-Agent": f"{_API_CLIENT} (gemini-native)", "X-Goog-Api-Client": _API_CLIENT, **self._default_headers}