Improve AI filtering error handling and visibility
- Add listAvailableModels() and validateModel() to openai.ts - Improve testOpenAIConnection() to test configured model - Add checkAIStatus endpoint to filtering router - Add pre-execution AI config check in executeRules - Improve error messages in AI filtering service (rate limit, quota, etc.) - Add AI status warning banner on round detail page for filtering rounds Now admins get clear errors when AI is misconfigured instead of silent flags. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -84,6 +84,10 @@ function RoundDetailContent({ roundId }: { roundId: string }) {
|
||||
{ roundId },
|
||||
{ enabled: isFilteringRound }
|
||||
)
|
||||
const { data: aiStatus } = trpc.filtering.checkAIStatus.useQuery(
|
||||
{ roundId },
|
||||
{ enabled: isFilteringRound }
|
||||
)
|
||||
|
||||
const utils = trpc.useUtils()
|
||||
const updateStatus = trpc.round.updateStatus.useMutation({
|
||||
@@ -485,6 +489,22 @@ function RoundDetailContent({ roundId }: { roundId: string }) {
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{/* AI Status Warning */}
|
||||
{aiStatus?.hasAIRules && !aiStatus?.configured && (
|
||||
<div className="flex items-center gap-3 p-4 rounded-lg bg-amber-500/10 border border-amber-500/20">
|
||||
<AlertTriangle className="h-5 w-5 text-amber-600 flex-shrink-0" />
|
||||
<div className="flex-1">
|
||||
<p className="font-medium text-amber-700">AI Configuration Required</p>
|
||||
<p className="text-sm text-amber-600">
|
||||
{aiStatus.error || 'AI screening rules require OpenAI to be configured.'}
|
||||
</p>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" asChild>
|
||||
<Link href="/admin/settings">Configure AI</Link>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Stats */}
|
||||
{filteringStats && filteringStats.total > 0 ? (
|
||||
<div className="grid gap-4 sm:grid-cols-4">
|
||||
|
||||
Reference in New Issue
Block a user