Skip to content

Commit 8297371

Browse files
style: Apply ruff-format fixes to Gemini integration
Co-Authored-By: Alex Reibman <meta.alex.r@gmail.com>
1 parent aed3a1b commit 8297371

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

agentops/llms/providers/gemini.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def override(self):
134134
import google.generativeai as genai
135135

136136
# Store original method if not already stored
137-
if 'generate_content' not in _ORIGINAL_METHODS:
138-
_ORIGINAL_METHODS['generate_content'] = genai.GenerativeModel.generate_content
137+
if "generate_content" not in _ORIGINAL_METHODS:
138+
_ORIGINAL_METHODS["generate_content"] = genai.GenerativeModel.generate_content
139139

140140
# Store provider instance for the closure
141141
provider = self
@@ -145,8 +145,8 @@ def patched_function(self, *args, **kwargs):
145145
session = kwargs.pop("session", None) # Always try to pop session, returns None if not present
146146

147147
# Call original method and track event
148-
if 'generate_content' in _ORIGINAL_METHODS:
149-
result = _ORIGINAL_METHODS['generate_content'](self, *args, **kwargs)
148+
if "generate_content" in _ORIGINAL_METHODS:
149+
result = _ORIGINAL_METHODS["generate_content"](self, *args, **kwargs)
150150
return provider.handle_response(result, kwargs, init_timestamp, session=session)
151151
else:
152152
logger.error("Original generate_content method not found. Cannot proceed with override.")
@@ -161,6 +161,7 @@ def undo_override(self):
161161
Note:
162162
This method is called automatically by AgentOps during cleanup.
163163
Users should not call this method directly."""
164-
if 'generate_content' in _ORIGINAL_METHODS:
164+
if "generate_content" in _ORIGINAL_METHODS:
165165
import google.generativeai as genai
166-
genai.GenerativeModel.generate_content = _ORIGINAL_METHODS['generate_content']
166+
167+
genai.GenerativeModel.generate_content = _ORIGINAL_METHODS["generate_content"]

agentops/llms/tracker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ def override_api(self):
220220
if Version(module_version) >= parse("0.1.0"):
221221
import google.generativeai as genai
222222
import os
223+
223224
api_key = os.getenv("GEMINI_API_KEY")
224225
if api_key:
225226
try:

examples/gemini_examples/run_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
23
os.environ["GEMINI_API_KEY"] = "${GEMINI_API_KEY}"
34

45
# Now run the test notebook

0 commit comments

Comments
 (0)