cleanup
This commit is contained in:
@ -5,18 +5,11 @@ import logging
|
||||
import regex
|
||||
|
||||
from aiohttp import ClientSession, ClientTimeout
|
||||
|
||||
from fastapi import FastAPI, Security, Request, HTTPException
|
||||
from fastapi.security import APIKeyHeader, APIKeyQuery
|
||||
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
api_key_header = APIKeyHeader(name="X-Authd-With")
|
||||
|
||||
|
||||
|
||||
class AI(FastAPI):
|
||||
"""AI Endpoints"""
|
||||
def __init__(self, app: FastAPI, my_util, constants, glob_state): # pylint: disable=super-init-not-called
|
||||
@ -51,11 +44,7 @@ class AI(FastAPI):
|
||||
local_llm_headers = {
|
||||
'Authorization': f'Bearer {self.constants.LOCAL_LLM_KEY}'
|
||||
}
|
||||
|
||||
forward_path = self.url_clean_regex.sub('', request.url.path)
|
||||
|
||||
print(f"Original path: {request.url.path}; Forward path: {forward_path}")
|
||||
print(f"Request data: {await request.json()}")
|
||||
try:
|
||||
async with ClientSession() as session:
|
||||
async with await session.post(f'{self.constants.LOCAL_LLM_HOST}/{forward_path}',
|
||||
@ -64,7 +53,6 @@ class AI(FastAPI):
|
||||
timeout=ClientTimeout(connect=15, sock_read=30)) as request:
|
||||
await self.glob_state.increment_counter('ai_requests')
|
||||
response = await request.json()
|
||||
print(f"Response received: {response}")
|
||||
return response
|
||||
except Exception as e: # pylint: disable=broad-exception-caught
|
||||
logging.error("Error: %s", e)
|
||||
|
Reference in New Issue
Block a user