Skip to content

Commit

Permalink
Use contextvar session id in http utils
Browse files Browse the repository at this point in the history
  • Loading branch information
nqn committed May 21, 2024
1 parent 13d529a commit 26f7880
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions log10/_httpx_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from httpx import Request, Response

from log10.llm import Log10Config
from log10.load import get_log10_session_tags, sessionID
from log10.load import get_log10_session_tags, session_id_var


logger: logging.Logger = logging.getLogger("LOG10")
Expand Down Expand Up @@ -139,7 +139,7 @@ async def log_request(request: Request):
"orig_module": orig_module,
"orig_qualname": orig_qualname,
"request": request.content.decode("utf-8"),
"session_id": sessionID,
"session_id": session_id_var.get(),
}
if get_log10_session_tags():
log_row["tags"] = get_log10_session_tags()
Expand Down Expand Up @@ -230,7 +230,7 @@ async def aiter_bytes(self, *args, **kwargs):
"stacktrace": json.dumps(stacktrace),
"kind": "chat",
"request": self.request.content.decode("utf-8"),
"session_id": sessionID,
"session_id": session_id_var.get(),
}
if get_log10_session_tags():
log_row["tags"] = get_log10_session_tags()
Expand Down Expand Up @@ -272,7 +272,7 @@ async def handle_async_request(self, request: httpx.Request) -> httpx.Response:
"stacktrace": json.dumps(stacktrace),
"kind": "chat",
"request": request.content.decode("utf-8"),
"session_id": sessionID,
"session_id": session_id_var.get(),
}
if get_log10_session_tags():
log_row["tags"] = get_log10_session_tags()
Expand Down

0 comments on commit 26f7880

Please sign in to comment.