|
|
@@ -21,8 +21,6 @@ from email.message import EmailMessage
|
|
|
load_dotenv()
|
|
|
import fudo.fudo as fd
|
|
|
|
|
|
-
|
|
|
-
|
|
|
# Configuration
|
|
|
OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
|
|
|
PORT = int(os.getenv("PORT", 6001))
|
|
|
@@ -39,7 +37,6 @@ if not OPENAI_API_KEY:
|
|
|
# Potentially exit or prevent app startup if critical env var is missing
|
|
|
# raise ValueError("OPENAI_API_KEY is not set, cannot start application.")
|
|
|
|
|
|
-
|
|
|
# --- FastAPI App Initialization ---
|
|
|
app = FastAPI(title="Web Pedidos Klein - FastAPI Backend")
|
|
|
|
|
|
@@ -142,7 +139,6 @@ def send_email():
|
|
|
smtp.login(EMAIL_ORIGEN, CONTRASENA)
|
|
|
smtp.send_message(msg)
|
|
|
|
|
|
-
|
|
|
def load_bg_data() -> List[Dict[str, str]]:
|
|
|
try:
|
|
|
with open(BG_DATA_PATH, 'r', encoding='utf-8') as f:
|
|
|
@@ -332,7 +328,6 @@ async def printer_order(order: OrderWeb):
|
|
|
writer = csv.writer(f)
|
|
|
writer.writerow([order.customerName, order.table, order.orderDate, list(map(lambda item: item.name, items))])
|
|
|
|
|
|
-
|
|
|
@app.post("/api/chat/completions",
|
|
|
summary="Get chat completions from OpenAI",
|
|
|
dependencies=[Depends(protect_chat_api)])
|
|
|
@@ -355,7 +350,6 @@ async def chat_completions(request_data: ChatCompletionRequest, request: Request
|
|
|
print(f"Unexpected error in /api/chat/completions: {e}")
|
|
|
raise HTTPException(status_code=500, detail="Error interno del servidor al procesar el chat.")
|
|
|
|
|
|
-
|
|
|
@app.get("/", response_class=HTMLResponse, include_in_schema=False)
|
|
|
async def serve_index_html():
|
|
|
index_path = os.path.join("public", "index.html")
|