Skip to content

Commit

Permalink
Address #4: Brief description of the fix
Browse files Browse the repository at this point in the history
#4

- Creates the log folder if doesn't exist
- Fixed the issue for routing a normal chat message

Further testing is required before closing the issue.
  • Loading branch information
unclecode committed Mar 14, 2024
1 parent 18d903f commit 2c5cd6f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/libs/chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class DefaultCompletionHandler(Handler):
async def handle(self, context: Context):
if context.is_normal_chat:
# Assuming context.client is set and has a method for creating chat completions
completion = await context.client.chat.completions.create(
completion = context.client.route(
messages=context.messages,
**context.client.clean_params(context.params),
)
Expand Down
2 changes: 0 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from starlette.requests import Request
from routes import proxy
from routes import examples


from utils import create_logger
import os
from dotenv import load_dotenv
Expand Down
3 changes: 3 additions & 0 deletions app/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ def __init__(self, api_key: str, base_url = None):
def route(self, model: str, messages: list, **kwargs):
pass

async def route_async(self, model: str, messages: list, **kwargs):
pass

def clean_params(self, params):
pass

Expand Down
8 changes: 6 additions & 2 deletions app/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import logging
import os

# To be developed
def create_logger(lof_path:str = ".logs/access.log"):
def create_logger(log_path:str = ".logs/access.log"):
log_dir = os.path.dirname(log_path)
if not os.path.exists(log_dir):
os.makedirs(log_dir)
logger = logging.getLogger("app")
logger.setLevel(logging.DEBUG)
file_handler = logging.FileHandler(lof_path)
file_handler = logging.FileHandler(log_path)
file_handler.setLevel(logging.DEBUG)
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
file_handler.setFormatter(formatter)
Expand Down

0 comments on commit 2c5cd6f

Please sign in to comment.