Skip to content

Commit

Permalink
Added prepend string
Browse files Browse the repository at this point in the history
  • Loading branch information
HowieG committed Sep 16, 2024
1 parent 8bbc4d1 commit cc441c5
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions agentops/time_travel.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from .exceptions import ApiServerException
from .singleton import singleton

ttd_prepend_string = "🖇️ Agentops: ⏰ Time Travel |"


@singleton
class TimeTravel:
Expand Down Expand Up @@ -47,9 +49,9 @@ def fetch_time_travel_id(ttd_id):

set_time_travel_active_state(True)
except ApiServerException as e:
print(f"🖇️ Agentops: ⏰ Time Travel Error - {e}")
print(f"{ttd_prepend_string} Error - {e}")

Check warning on line 52 in agentops/time_travel.py

View check run for this annotation

Codecov / codecov/patch

agentops/time_travel.py#L52

Added line #L52 was not covered by tests
except Exception as e:
print(f"🖇️ Agentops: ⏰ Time Travel Error - {e}")
print(f"{ttd_prepend_string} Error - {e}")

Check warning on line 54 in agentops/time_travel.py

View check run for this annotation

Codecov / codecov/patch

agentops/time_travel.py#L54

Added line #L54 was not covered by tests


def fetch_completion_override_from_time_travel_cache(kwargs):
Expand All @@ -64,14 +66,14 @@ def fetch_completion_override_from_time_travel_cache(kwargs):
def find_cache_hit(prompt_messages, completion_overrides):
if not isinstance(prompt_messages, (list, tuple)):
print(
"🖇️ Agentops: ⏰ Time Travel Error - unexpected type for prompt_messages. Expected 'list' or 'tuple'. Got ",
f"{ttd_prepend_string} Error - unexpected type for prompt_messages. Expected 'list' or 'tuple'. Got ",
type(prompt_messages),
)
return None

if not isinstance(completion_overrides, dict):
print(
"🖇️ Agentops: ⏰ Time Travel Error - unexpected type for completion_overrides. Expected 'dict'. Got ",
f"{ttd_prepend_string} Error - unexpected type for completion_overrides. Expected 'dict'. Got ",
type(completion_overrides),
)
return None
Expand All @@ -80,15 +82,15 @@ def find_cache_hit(prompt_messages, completion_overrides):
completion_override_dict = eval(key)
if not isinstance(completion_override_dict, dict):
print(
"🖇️ Agentops: ⏰ Time Travel Error - unexpected type for completion_override_dict. Expected 'dict'. Got ",
f"{ttd_prepend_string} Error - unexpected type for completion_override_dict. Expected 'dict'. Got ",
type(completion_override_dict),
)
continue

cached_messages = completion_override_dict.get("messages")
if not isinstance(cached_messages, list):
print(
"🖇️ Agentops: ⏰ Time Travel Error - unexpected type for cached_messages. Expected 'list'. Got ",
f"{ttd_prepend_string} Error - unexpected type for cached_messages. Expected 'list'. Got ",
type(cached_messages),
)
continue
Expand All @@ -105,11 +107,11 @@ def find_cache_hit(prompt_messages, completion_overrides):
return value
except (SyntaxError, ValueError, TypeError) as e:
print(
f"🖇️ Agentops: ⏰ Time Travel Error - Error processing completion_overrides item: {e}"
f"{ttd_prepend_string} Error - Error processing completion_overrides item: {e}"
)
except Exception as e:
print(

Check warning on line 113 in agentops/time_travel.py

View check run for this annotation

Codecov / codecov/patch

agentops/time_travel.py#L113

Added line #L113 was not covered by tests
f"🖇️ Agentops: ⏰ Time Travel Error - Unexpected error in find_cache_hit: {e}"
f"{ttd_prepend_string} Error - Unexpected error in find_cache_hit: {e}"
)
return None

Expand Down Expand Up @@ -142,11 +144,11 @@ def set_time_travel_active_state(is_active: bool):
yaml.dump(config, config_file)
except:
print(
f"🖇️ Agentops: ⏰ Time Travel Error - Unable to write to {config_path}. Time Travel not activated"
f"{ttd_prepend_string} Error - Unable to write to {config_path}. Time Travel not activated"
)
return

if is_active:
print("🖇️ Agentops: ⏰ Time Travel Activated")
print(f"{ttd_prepend_string} Activated")

Check warning on line 152 in agentops/time_travel.py

View check run for this annotation

Codecov / codecov/patch

agentops/time_travel.py#L152

Added line #L152 was not covered by tests
else:
print("🖇️ Agentops: ⏰ Time Travel Deactivated")
print(f"{ttd_prepend_string} Deactivated")

Check warning on line 154 in agentops/time_travel.py

View check run for this annotation

Codecov / codecov/patch

agentops/time_travel.py#L154

Added line #L154 was not covered by tests

0 comments on commit cc441c5

Please sign in to comment.