Skip to content

Commit

Permalink
Warn users about async being disabled in this version of the library
Browse files Browse the repository at this point in the history
  • Loading branch information
nqn committed Jan 30, 2024
1 parent babdda8 commit 24bfb12
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions log10/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
# log10, bigquery
target_service = os.environ.get("LOG10_DATA_STORE", "log10")
if target_service == "bigquery":
raise NotImplementedError("For big query support, please get in touch with us at support@log10.io")
raise NotImplementedError(
"For big query support, please get in touch with us at support@log10.io"
)


def is_openai_v1() -> bool:
Expand Down Expand Up @@ -103,7 +105,9 @@ def get_session_id():
try:
sessionID = res.json().get("sessionID")
except Exception as e:
logger.warning(f"LOG10: failed to get session ID. Error: {e}. Skipping session scope recording.")
logger.warning(
f"LOG10: failed to get session ID. Error: {e}. Skipping session scope recording."
)

return sessionID

Expand Down Expand Up @@ -166,7 +170,9 @@ def wrapper(*args, **kwargs):
organizationSlug = r.json().get("organizationSlug")
last_completion_response = r.json()
except Exception as e:
logger.warning(f"LOG10: failed to get completion ID. Error: {e}. Skipping completion recording.")
logger.warning(
f"LOG10: failed to get completion ID. Error: {e}. Skipping completion recording."
)
return func_with_backoff(func, *args, **kwargs)

completion_url = f"{url}/api/completions/{completionID}"
Expand Down Expand Up @@ -216,7 +222,11 @@ def wrapper(*args, **kwargs):
duration = time.perf_counter() - start_time
logger.debug(f"LOG10: failed - {e}")
# todo: change with openai v1 update
if type(e).__name__ == "InvalidRequestError" and "This model's maximum context length" in str(e):
if type(
e
).__name__ == "InvalidRequestError" and "This model's maximum context length" in str(
e
):
failure_kind = "ContextWindowExceedError"
else:
failure_kind = type(e).__name__
Expand Down Expand Up @@ -281,7 +291,7 @@ def log10(module, DEBUG_=False, USE_ASYNC_=True):
Keyword arguments:
module -- the module to be intercepted (e.g. openai)
DEBUG_ -- whether to show log10 related debug statements via python logging (default False)
USE_ASYNC_ -- whether to run in async mode (default True)
USE_ASYNC_ -- Disabled in 0.5.3. Calls are asynchronous.
Openai V0 example:
Example:
Expand Down Expand Up @@ -353,8 +363,11 @@ def log10(module, DEBUG_=False, USE_ASYNC_=True):
global DEBUG, USE_ASYNC, sync_log_text
DEBUG = DEBUG_ or os.environ.get("LOG10_DEBUG", False)
logger.setLevel(logging.DEBUG if DEBUG else logging.WARNING)
USE_ASYNC = USE_ASYNC_
sync_log_text = set_sync_log_text(USE_ASYNC=USE_ASYNC)

if USE_ASYNC_:
logger.debug(
"LOG10: USE_ASYNC is deprecated. Calls are synchronous by default."
)

# def intercept_nested_functions(obj):
# for name, attr in vars(obj).items():
Expand Down

0 comments on commit 24bfb12

Please sign in to comment.