feat: iddianame-first case summary + remove hardcoded AI endpoint

- summarizeCase: if an iddianame is among the case's documents, run a
  narrow first-pass analysis on it alone (isnatEdilenSuc, iddiaOzeti,
  onemliTarihler), then feed that as context into the general
  case-wide evaluation instead of treating every document equally.
- ANALYSIS_SYSTEM_PROMPT no longer asks the AI to guess "taraflar" -
  that now comes from real UYAP data (cases.parties) instead.
- Removed the hardcoded RunPod proxy URL fallback from every call
  site (document/chat/precedent controllers + lib/openai.ts) - it was
  a real infra endpoint checked into source. New lib/aiConfig.ts
  throws if RUNPOD_API_BASE_URL isn't set rather than silently
  falling back to it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
mstfyldz
2026-08-09 20:00:06 +03:00
co-authored by Claude Sonnet 5
parent af5a03db92
commit c939dcf564
6 changed files with 105 additions and 33 deletions
+4 -7
View File
@@ -1,14 +1,14 @@
import { Response } from 'express';
import { supabase } from '../lib/supabase';
import { AuthenticatedRequest } from '../middleware/auth';
import { getAiConfig } from '../lib/aiConfig';
// Bir dosyanın ilk mesajından kısa bir başlık üretir (Claude/ChatGPT'nin yaptığı gibi).
// Başarısız olursa null döner — çağıran taraf bu durumda "Yeni Sohbet" başlığını korur,
// asıl sohbet cevabını etkilemez.
async function generateCaseTitle(firstMessage: string): Promise<string | null> {
try {
const aiModel = process.env.AI_MODEL || 'mizan-fixed';
const runpodUrl = process.env.RUNPOD_API_BASE_URL || 'https://q190env94stwis-11434.proxy.runpod.net';
const { runpodUrl, aiModel } = getAiConfig();
const response = await fetch(`${runpodUrl}/api/chat`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -69,8 +69,7 @@ export const chatMessage = async (req: AuthenticatedRequest, res: Response) => {
// AI'ye iletip yanıtı doğrudan döndürüyoruz.
if (caseId === 'general') {
const generalSystemPrompt = 'Sen bir hukuk asistanısın. Belirli bir dava dosyasına bağlı olmayan genel hukuki soruları cevaplıyorsun. Emin olmadığın noktalarda bunu açıkça belirt, uydurma bilgi verme.';
const aiModel = process.env.AI_MODEL || 'mizan-fixed';
const runpodUrl = process.env.RUNPOD_API_BASE_URL || 'https://q190env94stwis-11434.proxy.runpod.net';
const { runpodUrl, aiModel } = getAiConfig();
const response = await fetch(`${runpodUrl}/api/chat`, {
method: 'POST',
@@ -145,9 +144,7 @@ export const chatMessage = async (req: AuthenticatedRequest, res: Response) => {
messages.push({ role: 'user', content });
}
const aiModel = process.env.AI_MODEL || 'mizan-fixed';
// Native endpoint'e geçiş
const runpodUrl = process.env.RUNPOD_API_BASE_URL || 'https://q190env94stwis-11434.proxy.runpod.net';
const { runpodUrl, aiModel } = getAiConfig();
const response = await fetch(`${runpodUrl}/api/chat`, {
method: 'POST',