Update api/utils.py
Browse files- api/utils.py +5 -3
api/utils.py
CHANGED
|
@@ -3,6 +3,7 @@ import json
|
|
| 3 |
import uuid
|
| 4 |
import asyncio
|
| 5 |
import random
|
|
|
|
| 6 |
from typing import Any, Dict, Optional
|
| 7 |
|
| 8 |
import httpx
|
|
@@ -23,9 +24,10 @@ from api.logger import setup_logger
|
|
| 23 |
|
| 24 |
logger = setup_logger(__name__)
|
| 25 |
|
| 26 |
-
# Helper function to create a
|
| 27 |
-
def generate_chat_id() -> str:
|
| 28 |
-
|
|
|
|
| 29 |
|
| 30 |
# Helper function to create chat completion data
|
| 31 |
def create_chat_completion_data(
|
|
|
|
| 3 |
import uuid
|
| 4 |
import asyncio
|
| 5 |
import random
|
| 6 |
+
import string
|
| 7 |
from typing import Any, Dict, Optional
|
| 8 |
|
| 9 |
import httpx
|
|
|
|
| 24 |
|
| 25 |
logger = setup_logger(__name__)
|
| 26 |
|
| 27 |
+
# Helper function to create a random alphanumeric chat ID
|
| 28 |
+
def generate_chat_id(length: int = 7) -> str:
|
| 29 |
+
characters = string.ascii_letters + string.digits
|
| 30 |
+
return ''.join(random.choices(characters, k=length))
|
| 31 |
|
| 32 |
# Helper function to create chat completion data
|
| 33 |
def create_chat_completion_data(
|