-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Fireworks Python SDK support #592
base: main
Are you sure you want to change the base?
Changes from 12 commits
b3035d7
84e44b3
e822933
58fee49
2608f16
566ced9
8c8fa36
bb3b056
26c71cf
68b276e
e9a5a34
0f10f0a
9d22c6e
a28c0f1
49d3f27
74eed4a
c5d6c21
9cb419d
bf9355a
7203a76
001921e
5a8341c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
import traceback | ||
from decimal import Decimal | ||
from functools import cached_property | ||
from typing import List, Optional, Tuple, Union | ||
from typing import Any, Dict, List, Optional, Set, Tuple, Union | ||
from uuid import UUID, uuid4 | ||
|
||
from termcolor import colored | ||
|
@@ -247,7 +247,7 @@ | |
end_state_reason: Optional[str] = None, | ||
video: Optional[str] = None, | ||
is_auto_end: Optional[bool] = None, | ||
) -> Optional[Decimal]: | ||
) -> Optional[Dict[str, Any]]: | ||
""" | ||
End the current session with the AgentOps service. | ||
|
||
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with caution to avoid runtime errors or unexpected behavior in the application. 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change should be communicated clearly to all team members to prevent any unexpected issues in the system. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to avoid introducing bugs or breaking existing functionality. 🛠️
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be approached with caution to avoid introducing bugs into the system. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to avoid breaking existing functionality. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be approached with caution to prevent breaking existing functionality. 🛠️
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix:
By following these steps, you can mitigate the risk of introducing bugs due to this change. 🛠️ 📜 Guidelines• Use docstrings for modules, functions, and classes • Use type annotations to improve code clarity and maintainability • Write unit tests for your code
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix:
This change should be communicated clearly to all stakeholders to prevent unexpected issues in production environments. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be communicated clearly to all developers involved in the project to prevent runtime errors or logical issues. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change should be communicated clearly to the team to prevent any unexpected issues in the application. 📢 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
247
to
253
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to avoid introducing bugs into the system. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability |
||
|
@@ -258,17 +258,15 @@ | |
is_auto_end (bool, optional): is this an automatic use of end_session and should be skipped with skip_auto_end_session | ||
|
||
Returns: | ||
Decimal: The token cost of the session. Returns 0 if the cost is unknown. | ||
Dict[str, Any]: Session statistics including duration, cost, and event counts. | ||
""" | ||
session = self._safe_get_session() | ||
if session is None: | ||
return | ||
return None | ||
if is_auto_end and self._config.skip_auto_end_session: | ||
return | ||
|
||
token_cost = session.end_session(end_state=end_state, end_state_reason=end_state_reason, video=video) | ||
return None | ||
|
||
return token_cost | ||
return session.end_session(end_state=end_state, end_state_reason=end_state_reason, video=video) | ||
|
||
def create_agent( | ||
self, | ||
Comment on lines
258
to
272
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with caution to avoid breaking existing functionality. 🛠️
Comment on lines
258
to
272
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical as it affects the core functionality of session handling and could lead to incorrect behavior if not addressed properly. 🛠️ 📜 Guidelines• Encourage type annotations for clarity and error reduction
Comment on lines
258
to
272
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to avoid breaking existing functionality. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
import logging | ||
import time | ||
import asyncio | ||
from typing import Optional, AsyncGenerator | ||
import pprint | ||
from agentops.session import Session | ||
from agentops.helpers import get_ISO_time | ||
from agentops.event import LLMEvent | ||
from agentops.enums import EventType | ||
from .instrumented_provider import InstrumentedProvider | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class FireworksProvider(InstrumentedProvider): | ||
"""Provider for Fireworks.ai API.""" | ||
|
||
def __init__(self, client): | ||
super().__init__(client) | ||
self._provider_name = "Fireworks" | ||
self._original_completion = None | ||
self._original_async_completion = None | ||
self._session = None # Initialize session attribute | ||
self._accumulated_content = "" # Track accumulated content for streaming | ||
self._init_timestamp = None # Track stream start time | ||
logger.info(f"Initializing {self._provider_name} provider") | ||
|
||
def set_session(self, session: Session): | ||
"""Set the session for event tracking.""" | ||
self._session = session | ||
logger.debug(f"Set session {session.session_id} for {self._provider_name} provider") | ||
|
||
async def handle_response(self, response, kwargs, init_timestamp, session: Optional[Session] = None) -> dict: | ||
"""Handle the response from the Fireworks API.""" | ||
try: | ||
# Use existing session if provided, otherwise use provider's session | ||
current_session = session if session else self._session | ||
if not current_session: | ||
logger.warning("No session available for event tracking") | ||
return response | ||
|
||
# Pass ChatML messages directly to LLMEvent | ||
messages = kwargs.get("messages", []) | ||
logger.debug(f"Using ChatML messages: {messages}") | ||
|
||
# Create base LLMEvent | ||
event = LLMEvent( | ||
model=kwargs.get("model", ""), | ||
prompt=messages, # Pass ChatML messages directly | ||
init_timestamp=init_timestamp, | ||
end_timestamp=time.time(), | ||
completion="", # Will be updated for streaming responses | ||
prompt_tokens=0, # Will be updated based on response | ||
completion_tokens=0, | ||
cost=0.0, | ||
) | ||
|
||
# Handle streaming response | ||
if kwargs.get("stream", False): | ||
async def async_generator(stream_response): | ||
accumulated_content = "" | ||
try: | ||
async for chunk in stream_response: | ||
if hasattr(chunk, "choices") and chunk.choices: | ||
content = chunk.choices[0].delta.content if hasattr(chunk.choices[0].delta, "content") else "" | ||
if content: | ||
accumulated_content += content | ||
yield chunk | ||
# Update event with final accumulated content | ||
event.completion = accumulated_content | ||
event.end_timestamp = time.time() | ||
if current_session: | ||
current_session.record(event) | ||
logger.info("Recorded streaming LLM event") | ||
except Exception as e: | ||
logger.error(f"Error in async_generator: {str(e)}") | ||
raise | ||
|
||
def generator(stream_response): | ||
accumulated_content = "" | ||
try: | ||
for chunk in stream_response: | ||
if hasattr(chunk, "choices") and chunk.choices: | ||
content = chunk.choices[0].delta.content if hasattr(chunk.choices[0].delta, "content") else "" | ||
if content: | ||
accumulated_content += content | ||
yield chunk | ||
# Update event with final accumulated content | ||
event.completion = accumulated_content | ||
event.end_timestamp = time.time() | ||
if current_session: | ||
current_session.record(event) | ||
logger.info("Recorded streaming LLM event") | ||
except Exception as e: | ||
logger.error(f"Error in generator: {str(e)}") | ||
raise | ||
|
||
if hasattr(response, "__aiter__"): | ||
return async_generator(response) # Return async generator | ||
else: | ||
return generator(response) # Return sync generator | ||
|
||
# Handle non-streaming response | ||
if hasattr(response, "choices") and response.choices: | ||
event.completion = response.choices[0].message.content | ||
event.end_timestamp = time.time() | ||
if current_session: | ||
current_session.record(event) | ||
logger.info("Recorded non-streaming LLM event") | ||
|
||
return response | ||
|
||
except Exception as e: | ||
logger.error(f"Error handling response: {str(e)}") | ||
raise | ||
|
||
def override(self): | ||
"""Override Fireworks API methods with instrumented versions.""" | ||
logger.info("Overriding Fireworks provider methods") | ||
if not self._original_completion: | ||
self._original_completion = self.client.chat.completions.create | ||
self._override_fireworks_completion() | ||
|
||
if not self._original_async_completion: | ||
self._original_async_completion = self.client.chat.completions.acreate | ||
self._override_fireworks_async_completion() | ||
|
||
def _override_fireworks_completion(self): | ||
"""Override synchronous completion method.""" | ||
original_create = self._original_completion | ||
provider = self | ||
|
||
def patched_function(*args, **kwargs): | ||
try: | ||
init_timestamp = time.time() | ||
response = original_create(*args, **kwargs) | ||
if kwargs.get("stream", False): | ||
return provider.handle_response(response, kwargs, init_timestamp, provider._session) | ||
else: | ||
loop = asyncio.new_event_loop() | ||
asyncio.set_event_loop(loop) | ||
return loop.run_until_complete(provider.handle_response(response, kwargs, init_timestamp, provider._session)) | ||
except Exception as e: | ||
logger.error(f"Error in Fireworks completion: {str(e)}") | ||
raise | ||
|
||
self.client.chat.completions.create = patched_function | ||
|
||
def _override_fireworks_async_completion(self): | ||
"""Override asynchronous completion method.""" | ||
original_acreate = self._original_async_completion | ||
provider = self | ||
|
||
async def patched_function(*args, **kwargs): | ||
try: | ||
init_timestamp = time.time() | ||
response = await original_acreate(*args, **kwargs) | ||
|
||
if kwargs.get("stream", False): | ||
return await provider.handle_response(response, kwargs, init_timestamp, provider._session) | ||
else: | ||
return await provider.handle_response(response, kwargs, init_timestamp, provider._session) | ||
except Exception as e: | ||
logger.error(f"Error in Fireworks async completion: {str(e)}") | ||
raise | ||
|
||
self.client.chat.completions.acreate = patched_function | ||
|
||
def undo_override(self): | ||
"""Restore original Fireworks API methods.""" | ||
logger.info(f"Restoring original {self._provider_name} provider methods") | ||
if self._original_completion: | ||
self.client.chat.completions.create = self._original_completion | ||
if self._original_async_completion: | ||
self.client.chat.completions.acreate = self._original_async_completion | ||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -16,6 +16,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from .providers.anthropic import AnthropicProvider | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from .providers.mistral import MistralProvider | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from .providers.ai21 import AI21Provider | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from .providers.fireworks import FireworksProvider | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
original_func = {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
original_create = None | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -48,6 +49,9 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"mistralai": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"1.0.1": ("chat.complete", "chat.stream"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"fireworks-ai": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"0.1.0": ("chat.completions.create",), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"ai21": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"2.0.0": ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
"chat.completions.create", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -155,6 +159,15 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.warning(f"Only AI21>=2.0.0 supported. v{module_version} found.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if api == "fireworks-ai": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
module_version = version(api) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if Version(module_version) >= parse("0.1.0"): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
provider = FireworksProvider(self.client) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
provider.override() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logger.warning(f"Only Fireworks>=0.1.0 supported. v{module_version} found.") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if api == "llama_stack_client": | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
module_version = version(api) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
159
to
173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
🔧 Suggested Code Diff: else:
logger.warning(f"Only Fireworks>=0.1.0 supported. v{module_version} found.")
+ raise RuntimeError(f"Unsupported Fireworks version: {module_version}. Please upgrade to >=0.1.0.") 📝 Committable Code Suggestion
Suggested change
📜 Guidelines• Use exceptions for error handling rather than return codes |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
@@ -174,3 +187,4 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
MistralProvider(self.client).undo_override() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
AI21Provider(self.client).undo_override() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LlamaStackClientProvider(self.client).undo_override() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FireworksProvider(self.client).undo_override() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,7 +284,7 @@ | |
end_state: str = "Indeterminate", | ||
end_state_reason: Optional[str] = None, | ||
video: Optional[str] = None, | ||
) -> Union[Decimal, None]: | ||
) -> Union[Dict[str, Any], None]: | ||
with self._end_session_lock: | ||
if not self.is_running: | ||
return None | ||
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Actionable Steps:
By following these steps, you can mitigate the risk of runtime errors and ensure that the codebase remains robust and maintainable. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix:
This change is critical and should be handled with caution to avoid introducing bugs into the system. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change should be communicated clearly to all stakeholders to prevent any unexpected issues in production environments. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is high-impact and requires careful consideration and communication to avoid disruptions. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be approached with caution to avoid breaking existing functionality.
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to avoid introducing bugs. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be approached with caution to avoid introducing bugs or breaking existing functionality. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to avoid breaking existing systems. 🛠️ 📜 Guidelines• Encourage type annotations for clarity and error reduction
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
By following these steps, you can mitigate the risks associated with this change and ensure that the codebase remains stable and functional. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to avoid introducing bugs into the system. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to avoid breaking existing functionality. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be approached with caution to prevent any runtime errors or logical inconsistencies in the application. 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to prevent runtime errors and ensure the stability of the application. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability
Comment on lines
284
to
290
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix: Actionable Steps:
This change is critical and should be handled with care to prevent runtime errors or logical issues in the application. 📜 Guidelines• Use type annotations to improve code clarity and maintainability |
||
|
@@ -324,8 +324,9 @@ | |
finally: | ||
del self._span_processor | ||
|
||
# 5. Final session update | ||
if not (analytics_stats := self.get_analytics()): | ||
# 5. Final session update and get analytics | ||
analytics_stats = self.get_analytics() | ||
if not analytics_stats: | ||
return None | ||
|
||
analytics = ( | ||
|
@@ -341,6 +342,7 @@ | |
|
||
except Exception as e: | ||
logger.exception(f"Error during session end: {e}") | ||
return None | ||
finally: | ||
active_sessions.remove(self) # First thing, get rid of the session | ||
|
||
|
@@ -350,7 +352,7 @@ | |
"blue", | ||
) | ||
) | ||
return self.token_cost | ||
return analytics_stats | ||
|
||
def add_tags(self, tags: List[str]) -> None: | ||
""" | ||
Comment on lines
352
to
358
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Bug Fix:
By following these steps, you can mitigate the risk of introducing logical errors and ensure that the system remains robust and reliable. 🛠️ 📜 Guidelines• Use type annotations to improve code clarity and maintainability |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 Bug Fix:
Change in Return Type from Decimal to Dict
The change in the return type from
Optional[Decimal]
toOptional[Dict[str, Any]]
is significant and can lead to logical errors if not handled properly. This change requires a thorough review of all the places where this function is called to ensure that the new return type is managed correctly.Actionable Steps:
Decimal
.This change is critical and should be prioritized to prevent runtime errors and ensure system stability. 🛠️
📜 Guidelines
• Use type annotations to improve code clarity and maintainability
• Write unit tests for your code