fix: add role-based strategic goals and winSteps to runStrategyAnalysis
This commit is contained in:
@@ -124,11 +124,15 @@ export const analyzeStatements = async (req: AuthenticatedRequest, res: Response
|
||||
.order('uploaded_at', { ascending: true });
|
||||
if (docsError) throw docsError;
|
||||
|
||||
// Sadece ifade, sorgu, beyan, tutanak, duruşma içeren belgeleri filtrele
|
||||
// Sadece ifade, sorgu, beyan, tutanak, duruşma içeren belgeleri filtrele.
|
||||
// "tutanak" tek başına çok geniş — "Tebligat Tutanağı" gibi ifade/beyan
|
||||
// İÇERMEYEN evrakları da yakalıyordu, çelişki analizine gürültü katıyordu.
|
||||
const keywords = ['ifade', 'sorgu', 'beyan', 'tutanak', 'duruşma'];
|
||||
const excludeKeywords = ['tebligat', 'tebliğ'];
|
||||
const statementDocs = (docs || []).filter((d) => {
|
||||
if (!d.extracted_text || !String(d.extracted_text).trim()) return false;
|
||||
const fn = normalizeTr(d.filename);
|
||||
if (excludeKeywords.some(kw => fn.includes(kw))) return false;
|
||||
return keywords.some(kw => fn.includes(kw));
|
||||
});
|
||||
|
||||
@@ -224,7 +228,7 @@ export const analyzeDeficiencies = async (req: AuthenticatedRequest, res: Respon
|
||||
export const analyzeStrategy = async (req: AuthenticatedRequest, res: Response) => {
|
||||
try {
|
||||
const { caseId } = req.params;
|
||||
const { clientName } = req.body;
|
||||
const { clientName, clientRole } = req.body;
|
||||
|
||||
if (!caseId) {
|
||||
return res.status(400).json({ error: 'Geçersiz caseId' });
|
||||
@@ -260,12 +264,12 @@ export const analyzeStrategy = async (req: AuthenticatedRequest, res: Response)
|
||||
|
||||
const analysisInput = `Aşağıdaki belgeler dava dosyasına aittir:\n\n${combinedText}`;
|
||||
|
||||
const { summaryJson, aiModel } = await runStrategyAnalysis(analysisInput, clientName);
|
||||
const { summaryJson, aiModel } = await runStrategyAnalysis(analysisInput, clientName, clientRole);
|
||||
|
||||
// Strateji analizi sonucunu 'analyses' tablosuna kaydet
|
||||
const { data: analysisRecord, error: analysisError } = await supabase
|
||||
.from('analyses')
|
||||
.insert([{ case_id: caseId, document_id: null, summary_json: { strategyAnalysis: summaryJson, clientName }, model_used: aiModel }])
|
||||
.insert([{ case_id: caseId, document_id: null, summary_json: { strategyAnalysis: summaryJson, clientName, clientRole }, model_used: aiModel }])
|
||||
.select()
|
||||
.single();
|
||||
if (analysisError) throw analysisError;
|
||||
|
||||
Reference in New Issue
Block a user