Skip to content
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

Prints $0.00 now when token_cost is zero #168

Merged
merged 6 commits into from
Apr 30, 2024
Merged
Changes from 3 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
18 changes: 9 additions & 9 deletions agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ class Client(metaclass=MetaClient):

Args:

api_key (str, optional): API Key for AgentOps services. If none is provided, key will
api_key (str, optional): API Key for AgentOps services. If none is provided, key will
be read from the AGENTOPS_API_KEY environment variable.
parent_key (str, optional): Organization key to give visibility of all user sessions the user's organization. If none is provided, key will
parent_key (str, optional): Organization key to give visibility of all user sessions the user's organization. If none is provided, key will
be read from the AGENTOPS_PARENT_KEY environment variable.
endpoint (str, optional): The endpoint for the AgentOps service. If none is provided, key will
endpoint (str, optional): The endpoint for the AgentOps service. If none is provided, key will
be read from the AGENTOPS_API_ENDPOINT environment variable. Defaults to 'https://api.agentops.ai'.
max_wait_time (int, optional): The maximum time to wait in milliseconds before flushing the queue.
max_wait_time (int, optional): The maximum time to wait in milliseconds before flushing the queue.
Defaults to 30,000 (30 seconds)
max_queue_size (int, optional): The maximum size of the event queue. Defaults to 100.
tags (List[str], optional): Tags for the sessions that can be used for grouping or
tags (List[str], optional): Tags for the sessions that can be used for grouping or
sorting later (e.g. ["GPT-4"]).
override (bool, optional): [Deprecated] Use `instrument_llm_calls` instead. Whether to instrument LLM calls and emit LLMEvents..
instrument_llm_calls (bool): Whether to instrument LLM calls and emit LLMEvents..
Expand Down Expand Up @@ -95,7 +95,7 @@ def __init__(self,

def add_tags(self, tags: List[str]):
"""
Append to session tags at runtime.
Append to session tags at runtime.

Args:
tags (List[str]): The list of tags to append.
Expand All @@ -111,7 +111,7 @@ def add_tags(self, tags: List[str]):

def set_tags(self, tags: List[str]):
"""
Replace session tags at runtime.
Replace session tags at runtime.

Args:
tags (List[str]): The list of tags to set.
Expand Down Expand Up @@ -268,7 +268,7 @@ def end_session(self,
if token_cost == 'unknown':
print('🖇 AgentOps: Could not determine cost of run.')
else:
print('🖇 AgentOps: This run cost ${:.6f}'.format(float(token_cost)))
print('🖇 AgentOps: This run cost ${}'.format('{:.2f}'.format(token_cost) if token_cost == 0 else '{:.6f}'.format(float(token_cost))))
areibman marked this conversation as resolved.
Show resolved Hide resolved
self._session = None
self._worker = None

Expand Down Expand Up @@ -305,7 +305,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):
Args:
exc_type (Type[BaseException]): The type of the exception.
exc_value (BaseException): The exception instance.
exc_traceback (TracebackType): A traceback object encapsulating the call stack at the
exc_traceback (TracebackType): A traceback object encapsulating the call stack at the
point where the exception originally occurred.
"""
formatted_traceback = ''.join(traceback.format_exception(exc_type, exc_value,
Expand Down