fix: backend improvements (customer health, tests, middleware, corpus)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from typing import Dict, Any, Optional, List
|
||||
from sqlalchemy import select, func, and_
|
||||
from sqlalchemy import select, func, and_, String
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from datetime import datetime, timedelta
|
||||
import logging
|
||||
@@ -58,7 +58,7 @@ class CorpusTrainer:
|
||||
select(
|
||||
CorpusEntry.source_text,
|
||||
CorpusEntry.task_type,
|
||||
func.min(CorpusEntry.id).label("keep_id"),
|
||||
func.min(CorpusEntry.id.cast(String)).label("keep_id"),
|
||||
)
|
||||
.group_by(CorpusEntry.source_text, CorpusEntry.task_type)
|
||||
.having(func.count(CorpusEntry.id) > 1)
|
||||
@@ -70,7 +70,7 @@ class CorpusTrainer:
|
||||
and_(
|
||||
CorpusEntry.source_text == subquery.c.source_text,
|
||||
CorpusEntry.task_type == subquery.c.task_type,
|
||||
CorpusEntry.id != subquery.c.keep_id,
|
||||
CorpusEntry.id.cast(String) != subquery.c.keep_id,
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -170,7 +170,7 @@ class CorpusTrainer:
|
||||
from app.config import settings
|
||||
import httpx
|
||||
|
||||
if settings.OPENAI_API_KEY:
|
||||
if getattr(settings, 'OPENAI_API_KEY', None):
|
||||
async with httpx.AsyncClient() as client:
|
||||
resp = await client.post(
|
||||
"https://api.openai.com/v1/embeddings",
|
||||
|
||||
Reference in New Issue
Block a user