Skip to content

Commit

Permalink
use uuid to generate completion id and session id
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhe-log10 committed Apr 9, 2024
1 parent e16516a commit fbeb82a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
10 changes: 2 additions & 8 deletions log10/_httpx_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import time
import traceback
import uuid
from datetime import datetime, timezone

import httpx
Expand Down Expand Up @@ -112,14 +113,7 @@ async def get_completion_id(request: Request):
logger.warning("Currently logging is only available for v1/chat/completions.")
return

completion_url = "/api/completions"
res = await _try_post_request_async(url=f"{base_url}{completion_url}")
try:
completion_id = res.json().get("completionID")
except Exception as e:
logger.error(f"Failed to get completion ID. Error: {e}. Skipping completion recording.")
else:
request.headers["x-log10-completion-id"] = completion_id
request.headers["x-log10-completion-id"] = str(uuid.uuid4())


async def log_request(request: Request):
Expand Down
4 changes: 2 additions & 2 deletions log10/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import queue
import threading
import uuid
import time
import traceback
from contextlib import contextmanager
Expand Down Expand Up @@ -38,7 +39,6 @@
from log10.bigquery import initialize_bigquery

bigquery_client, bigquery_table = initialize_bigquery()
import uuid
from datetime import datetime, timezone
elif target_service is None:
target_service = "log10" # default to log10
Expand Down Expand Up @@ -130,7 +130,7 @@ def get_session_id():
+ "\nSee https://github.com/log10-io/log10#%EF%B8%8F-setup for details"
)

return session_id
return str(uuid.uuid4())


# Global variable to store the current sessionID.
Expand Down

0 comments on commit fbeb82a

Please sign in to comment.