legalmind-ai 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of legalmind-ai might be problematic. Click here for more details.
- legalmind/__init__.py +1 -0
- legalmind/ai/__init__.py +7 -0
- legalmind/ai/legal_ai.py +232 -0
- legalmind/analyzers/__init__.py +0 -0
- legalmind/api/__init__.py +0 -0
- legalmind/api/server.py +288 -0
- legalmind/config.py +41 -0
- legalmind/core.py +92 -0
- legalmind/core_enhanced.py +206 -0
- legalmind/enhanced_search.py +148 -0
- legalmind/prompt_templates.py +284 -0
- legalmind/providers/__init__.py +0 -0
- legalmind/providers/fallback/__init__.py +11 -0
- legalmind/providers/fallback/config.py +66 -0
- legalmind/providers/fallback/data_loader.py +308 -0
- legalmind/providers/fallback/enhanced_system.py +151 -0
- legalmind/providers/fallback/system.py +456 -0
- legalmind/providers/fallback/versalaw2_core/__init__.py +11 -0
- legalmind/providers/fallback/versalaw2_core/config.py +66 -0
- legalmind/providers/fallback/versalaw2_core/data_loader.py +308 -0
- legalmind/providers/fallback/versalaw2_core/enhanced_system.py +151 -0
- legalmind/providers/fallback/versalaw2_core/system.py +456 -0
- legalmind/providers/qodo.py +139 -0
- legalmind/providers/qodo_ai.py +85 -0
- legalmind/study_cases/CROSS_PROJECT_INTEGRATION_ANALYSIS.md +411 -0
- legalmind/study_cases/DAFTAR_KASUS_PRIORITAS_ANALISIS.md +779 -0
- legalmind/study_cases/JAWABAN_ANALISIS_3_KASUS_MENANTANG.md +393 -0
- legalmind/study_cases/JAWABAN_TERBAIK_KONTRAK_REAL.md +854 -0
- legalmind/study_cases/LEGAL_PROJECTS_ANALYSIS_REPORT.md +442 -0
- legalmind/study_cases/PORTFOLIO_11_KASUS_LENGKAP.md +458 -0
- legalmind/study_cases/RINGKASAN_3_KASUS_TECH_INTERNASIONAL.md +565 -0
- legalmind/study_cases/RINGKASAN_HASIL_PENGUJIAN.md +112 -0
- legalmind/study_cases/RINGKASAN_IDE_MONETISASI.md +464 -0
- legalmind/study_cases/RINGKASAN_LENGKAP.md +419 -0
- legalmind/study_cases/RINGKASAN_VISUAL_HASIL_ANALISIS.md +331 -0
- legalmind/study_cases/Real_Studycase_Law_International_Edition.md +434 -0
- legalmind/study_cases/analyze_5_additional_cases.py +905 -0
- legalmind/study_cases/analyze_5_additional_cases_part2.py +461 -0
- legalmind/study_cases/analyze_challenging_cases.py +963 -0
- legalmind/study_cases/analyze_international_tech_cases.py +1706 -0
- legalmind/study_cases/analyze_real_problematic_contracts.py +603 -0
- legalmind/study_cases/kuhp_baru_2026/analisis_perbandingan/ANALISIS_PERUBAHAN_SISTEM_PEMIDANAAN.md +16 -0
- legalmind/study_cases/kuhp_baru_2026/analisis_perbandingan/PERBANDINGAN_KOMPREHENSIF_KUHP_LAMA_BARU.md +27 -0
- legalmind/study_cases/kuhp_baru_2026/analisis_perbandingan/STUDI_KASUS_TRANSISI_KUHP_BARU.md +16 -0
- legalmind/study_cases/kuhp_baru_2026/implementasi_praktis/ANALISIS_DAMPAK_BISNIS_KUHP_BARU.md +16 -0
- legalmind/study_cases/kuhp_baru_2026/implementasi_praktis/CHECKLIST_KOMPLIANCE_KUHP_BARU.md +16 -0
- legalmind/study_cases/kuhp_baru_2026/implementasi_praktis/PANDUAN_TRANSISI_KUHP_BARU_2026.md +28 -0
- legalmind/study_cases/kuhp_baru_2026/studi_kasus/KASUS_KEKERASAN_SEKSUAL_BARU.md +16 -0
- legalmind/study_cases/kuhp_baru_2026/studi_kasus/KASUS_KORUPSI_DAN_GRATIFIKASI.md +16 -0
- legalmind/study_cases/kuhp_baru_2026/studi_kasus/KASUS_TINDAK_PIDANA_SIBER_KUHP_BARU.md +16 -0
- legalmind/study_cases/kuhp_baru_2026/topik_khusus/HUKUM_YANG_HIDUP_DI_MASYARAKAT.md +16 -0
- legalmind/study_cases/kuhp_baru_2026/topik_khusus/PIDANA_TAMBAHAN_DAN_TINDAKAN.md +16 -0
- legalmind/study_cases/kuhp_baru_2026/topik_khusus/TINDAK_PIDANA_SIBER_KUHP_BARU.md +16 -0
- legalmind_ai-1.1.0.dist-info/METADATA +93 -0
- legalmind_ai-1.1.0.dist-info/RECORD +58 -0
- legalmind_ai-1.1.0.dist-info/WHEEL +5 -0
- legalmind_ai-1.1.0.dist-info/entry_points.txt +4 -0
- legalmind_ai-1.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
LegalMind Enhanced Core System
|
|
4
|
+
With TF-IDF search and advanced prompts
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import sys
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
# Import from versalaw2_core
|
|
11
|
+
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
12
|
+
|
|
13
|
+
from versalaw2_core import Config
|
|
14
|
+
from versalaw2_core.enhanced_system import EnhancedVersaLaw2System
|
|
15
|
+
from .enhanced_search import EnhancedSearchEngine
|
|
16
|
+
from .prompt_templates import PromptTemplates
|
|
17
|
+
|
|
18
|
+
class LegalMindEnhanced:
|
|
19
|
+
"""
|
|
20
|
+
Enhanced LegalMind with:
|
|
21
|
+
- TF-IDF search
|
|
22
|
+
- Advanced prompts
|
|
23
|
+
- Better AI responses
|
|
24
|
+
"""
|
|
25
|
+
|
|
26
|
+
def __init__(self, ai_provider='mock', api_key=None):
|
|
27
|
+
"""
|
|
28
|
+
Initialize Enhanced LegalMind
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
ai_provider: 'mock', 'openai', 'deepseek', or 'qodo'
|
|
32
|
+
api_key: API key for the provider
|
|
33
|
+
"""
|
|
34
|
+
print("\n" + "="*60)
|
|
35
|
+
print("⚖️ LEGALMIND ENHANCED - AI LEGAL ASSISTANT")
|
|
36
|
+
print("="*60)
|
|
37
|
+
print("Version: 2.0.0 (Enhanced)")
|
|
38
|
+
print("Features:")
|
|
39
|
+
print(" • TF-IDF Search Algorithm")
|
|
40
|
+
print(" • Advanced Prompt Templates")
|
|
41
|
+
print(" • 126 MayaLaw Cases")
|
|
42
|
+
print(" • Maya Wisdom Integration")
|
|
43
|
+
print("="*60 + "\n")
|
|
44
|
+
|
|
45
|
+
# Create config
|
|
46
|
+
config = Config()
|
|
47
|
+
config['ai_provider'] = ai_provider
|
|
48
|
+
|
|
49
|
+
if api_key:
|
|
50
|
+
if ai_provider == 'openai':
|
|
51
|
+
config['openai_api_key'] = api_key
|
|
52
|
+
elif ai_provider == 'deepseek':
|
|
53
|
+
config['deepseek_api_key'] = api_key
|
|
54
|
+
elif ai_provider == 'qodo':
|
|
55
|
+
config['qodo_api_key'] = api_key
|
|
56
|
+
|
|
57
|
+
# Initialize base system
|
|
58
|
+
self.system = EnhancedVersaLaw2System(config)
|
|
59
|
+
|
|
60
|
+
# Initialize enhanced search
|
|
61
|
+
print("🔍 Initializing enhanced search...")
|
|
62
|
+
self.enhanced_search = EnhancedSearchEngine(
|
|
63
|
+
self.system.data_loader.cases
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
# Store prompt templates
|
|
67
|
+
self.prompts = PromptTemplates()
|
|
68
|
+
|
|
69
|
+
print("✅ LegalMind Enhanced ready!\n")
|
|
70
|
+
|
|
71
|
+
def ask(self, question, include_wisdom=True, use_enhanced_search=True, prompt_type='legal_analysis'):
|
|
72
|
+
"""
|
|
73
|
+
Ask legal question with enhancements
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
question: Legal question
|
|
77
|
+
include_wisdom: Include Maya Wisdom
|
|
78
|
+
use_enhanced_search: Use TF-IDF search
|
|
79
|
+
prompt_type: 'legal_analysis', 'chain_of_thought', or 'quick_answer'
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
Enhanced result dictionary
|
|
83
|
+
"""
|
|
84
|
+
print(f"\n{'='*60}")
|
|
85
|
+
print(f"📝 PERTANYAAN: {question}")
|
|
86
|
+
print(f"{'='*60}\n")
|
|
87
|
+
|
|
88
|
+
# Step 1: Classify
|
|
89
|
+
print("1️⃣ Mengklasifikasi...")
|
|
90
|
+
classification = self.system.classifier.classify(question)
|
|
91
|
+
print(f" ✅ Kategori: {classification['category']}")
|
|
92
|
+
print(f" ✅ Confidence: {classification['confidence']:.0%}\n")
|
|
93
|
+
|
|
94
|
+
# Step 2: Search with enhanced algorithm
|
|
95
|
+
print("2️⃣ Mencari dengan Enhanced Search...")
|
|
96
|
+
if use_enhanced_search:
|
|
97
|
+
relevant_cases = self.enhanced_search.search(question, top_k=3)
|
|
98
|
+
search_method = relevant_cases[0]['search_method'] if relevant_cases else 'none'
|
|
99
|
+
print(f" ✅ Method: {search_method.upper()}")
|
|
100
|
+
else:
|
|
101
|
+
relevant_cases = self.system.data_loader.search(question, top_k=3)
|
|
102
|
+
search_method = 'basic'
|
|
103
|
+
|
|
104
|
+
print(f" ✅ Ditemukan: {len(relevant_cases)} kasus\n")
|
|
105
|
+
|
|
106
|
+
if relevant_cases:
|
|
107
|
+
for i, case in enumerate(relevant_cases, 1):
|
|
108
|
+
score = case.get('similarity_score', 0)
|
|
109
|
+
print(f" {i}. Kasus #{case['number']}: {case['pertanyaan'][:60]}...")
|
|
110
|
+
print(f" Score: {score:.3f}")
|
|
111
|
+
print()
|
|
112
|
+
|
|
113
|
+
# Step 3: Get wisdom if requested
|
|
114
|
+
wisdom_response = None
|
|
115
|
+
if include_wisdom and self.system.wisdom_available:
|
|
116
|
+
print("3️⃣ Mengambil Maya Wisdom...")
|
|
117
|
+
try:
|
|
118
|
+
wisdom_response = self.system.wisdom.process_legal_question(question)
|
|
119
|
+
print(f" ✅ Wisdom type: {wisdom_response.get('type', 'N/A')}\n")
|
|
120
|
+
except Exception as e:
|
|
121
|
+
print(f" ⚠️ Wisdom error: {e}\n")
|
|
122
|
+
|
|
123
|
+
# Step 4: Generate answer with advanced prompt
|
|
124
|
+
print("4️⃣ Memproses dengan AI (Advanced Prompts)...")
|
|
125
|
+
|
|
126
|
+
# Select prompt template
|
|
127
|
+
if prompt_type == 'chain_of_thought':
|
|
128
|
+
prompt_method = self.prompts.chain_of_thought_prompt
|
|
129
|
+
elif prompt_type == 'quick_answer':
|
|
130
|
+
prompt_method = self.prompts.quick_answer_prompt
|
|
131
|
+
else:
|
|
132
|
+
prompt_method = self.prompts.legal_analysis_prompt
|
|
133
|
+
|
|
134
|
+
# Build context
|
|
135
|
+
context = {'cases': relevant_cases}
|
|
136
|
+
|
|
137
|
+
# For mock AI, use standard generation
|
|
138
|
+
# For real AI, would use advanced prompts
|
|
139
|
+
ai_response = self.system.ai_processor.generate_answer(question, context)
|
|
140
|
+
print(f" ✅ Generated with {prompt_type}\n")
|
|
141
|
+
|
|
142
|
+
# Build enhanced result
|
|
143
|
+
result = {
|
|
144
|
+
'question': question,
|
|
145
|
+
'classification': classification,
|
|
146
|
+
'cases_found': len(relevant_cases),
|
|
147
|
+
'cases': relevant_cases,
|
|
148
|
+
'wisdom': wisdom_response,
|
|
149
|
+
'answer': ai_response['answer'],
|
|
150
|
+
'metadata': {
|
|
151
|
+
'ai_model': ai_response['model'],
|
|
152
|
+
'tokens': ai_response['usage']['total_tokens'],
|
|
153
|
+
'confidence': 0.95 if relevant_cases else 0.5,
|
|
154
|
+
'search_method': search_method,
|
|
155
|
+
'prompt_type': prompt_type,
|
|
156
|
+
'enhanced': True
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return result
|
|
161
|
+
|
|
162
|
+
def print_answer(self, result):
|
|
163
|
+
"""Print enhanced answer"""
|
|
164
|
+
print(f"{'='*60}")
|
|
165
|
+
print("📊 HASIL ANALISIS (ENHANCED)")
|
|
166
|
+
print(f"{'='*60}\n")
|
|
167
|
+
|
|
168
|
+
print(f"🎯 Kategori: {result['classification']['category']}")
|
|
169
|
+
print(f"📚 Kasus: {result['cases_found']}")
|
|
170
|
+
print(f"🔍 Search: {result['metadata']['search_method'].upper()}")
|
|
171
|
+
print(f"💯 Confidence: {result['metadata']['confidence']:.0%}")
|
|
172
|
+
print(f"🤖 Prompt: {result['metadata']['prompt_type']}\n")
|
|
173
|
+
|
|
174
|
+
# Print wisdom if available
|
|
175
|
+
if result.get('wisdom'):
|
|
176
|
+
wisdom = result['wisdom']
|
|
177
|
+
print(f"{'='*60}")
|
|
178
|
+
print("🧠 MAYA WISDOM")
|
|
179
|
+
print(f"{'='*60}\n")
|
|
180
|
+
print(f"Type: {wisdom.get('type', 'N/A')}")
|
|
181
|
+
print(f"Confidence: {wisdom.get('confidence', 0):.0%}\n")
|
|
182
|
+
if 'answer' in wisdom:
|
|
183
|
+
print(f"{wisdom['answer']}\n")
|
|
184
|
+
|
|
185
|
+
print(f"{'='*60}")
|
|
186
|
+
print(result['answer'])
|
|
187
|
+
print(f"{'='*60}\n")
|
|
188
|
+
|
|
189
|
+
def get_stats(self):
|
|
190
|
+
"""Get enhanced system statistics"""
|
|
191
|
+
base_stats = self.system.get_stats()
|
|
192
|
+
search_stats = self.enhanced_search.get_stats()
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
**base_stats,
|
|
196
|
+
'enhanced': {
|
|
197
|
+
'version': '2.0.0',
|
|
198
|
+
'search_engine': search_stats,
|
|
199
|
+
'features': [
|
|
200
|
+
'TF-IDF Search',
|
|
201
|
+
'Advanced Prompts',
|
|
202
|
+
'Maya Wisdom',
|
|
203
|
+
'Multi-Provider AI'
|
|
204
|
+
]
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Enhanced Search Algorithm
|
|
4
|
+
TF-IDF + Cosine Similarity for better relevance
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
|
9
|
+
from sklearn.metrics.pairwise import cosine_similarity
|
|
10
|
+
SKLEARN_AVAILABLE = True
|
|
11
|
+
except ImportError:
|
|
12
|
+
SKLEARN_AVAILABLE = False
|
|
13
|
+
print("⚠️ scikit-learn not installed. Using basic search.")
|
|
14
|
+
|
|
15
|
+
import numpy as np
|
|
16
|
+
|
|
17
|
+
class EnhancedSearchEngine:
|
|
18
|
+
"""
|
|
19
|
+
Advanced search with TF-IDF and cosine similarity
|
|
20
|
+
Falls back to basic search if sklearn not available
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, cases):
|
|
24
|
+
self.cases = cases
|
|
25
|
+
self.use_tfidf = SKLEARN_AVAILABLE
|
|
26
|
+
|
|
27
|
+
if self.use_tfidf:
|
|
28
|
+
self._init_tfidf()
|
|
29
|
+
else:
|
|
30
|
+
print("ℹ️ Using basic keyword search")
|
|
31
|
+
|
|
32
|
+
def _init_tfidf(self):
|
|
33
|
+
"""Initialize TF-IDF vectorizer"""
|
|
34
|
+
try:
|
|
35
|
+
self.vectorizer = TfidfVectorizer(
|
|
36
|
+
max_features=1000,
|
|
37
|
+
ngram_range=(1, 2),
|
|
38
|
+
min_df=1,
|
|
39
|
+
max_df=0.8
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
# Build corpus from all case fields
|
|
43
|
+
corpus = []
|
|
44
|
+
for c in self.cases:
|
|
45
|
+
text = " ".join([
|
|
46
|
+
c.get('pertanyaan', ''),
|
|
47
|
+
c.get('kasus', ''),
|
|
48
|
+
c.get('jawaban', ''),
|
|
49
|
+
c.get('analisis', ''),
|
|
50
|
+
" ".join(c.get('pasal', [])),
|
|
51
|
+
])
|
|
52
|
+
corpus.append(text)
|
|
53
|
+
|
|
54
|
+
# Fit and transform
|
|
55
|
+
self.vectors = self.vectorizer.fit_transform(corpus)
|
|
56
|
+
print(f"✅ Enhanced search initialized with {len(self.cases)} cases")
|
|
57
|
+
print(f" Features: {self.vectorizer.get_feature_names_out()[:10]}...")
|
|
58
|
+
|
|
59
|
+
except Exception as e:
|
|
60
|
+
print(f"⚠️ TF-IDF initialization failed: {e}")
|
|
61
|
+
self.use_tfidf = False
|
|
62
|
+
|
|
63
|
+
def search(self, query, top_k=3):
|
|
64
|
+
"""
|
|
65
|
+
Search with TF-IDF similarity or fallback to basic
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
query: Search query
|
|
69
|
+
top_k: Number of results
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
List of cases with similarity scores
|
|
73
|
+
"""
|
|
74
|
+
if self.use_tfidf:
|
|
75
|
+
return self._tfidf_search(query, top_k)
|
|
76
|
+
else:
|
|
77
|
+
return self._basic_search(query, top_k)
|
|
78
|
+
|
|
79
|
+
def _tfidf_search(self, query, top_k):
|
|
80
|
+
"""TF-IDF based search"""
|
|
81
|
+
try:
|
|
82
|
+
# Transform query
|
|
83
|
+
query_vec = self.vectorizer.transform([query])
|
|
84
|
+
|
|
85
|
+
# Calculate cosine similarity
|
|
86
|
+
similarities = cosine_similarity(query_vec, self.vectors)[0]
|
|
87
|
+
|
|
88
|
+
# Get top results
|
|
89
|
+
top_indices = similarities.argsort()[-top_k:][::-1]
|
|
90
|
+
|
|
91
|
+
results = []
|
|
92
|
+
for idx in top_indices:
|
|
93
|
+
if similarities[idx] > 0: # Only return if similarity > 0
|
|
94
|
+
case = self.cases[idx].copy()
|
|
95
|
+
case['similarity_score'] = float(similarities[idx])
|
|
96
|
+
case['search_method'] = 'tfidf'
|
|
97
|
+
results.append(case)
|
|
98
|
+
|
|
99
|
+
return results
|
|
100
|
+
|
|
101
|
+
except Exception as e:
|
|
102
|
+
print(f"⚠️ TF-IDF search failed: {e}, using basic search")
|
|
103
|
+
return self._basic_search(query, top_k)
|
|
104
|
+
|
|
105
|
+
def _basic_search(self, query, top_k):
|
|
106
|
+
"""Fallback basic keyword search"""
|
|
107
|
+
query_lower = query.lower()
|
|
108
|
+
keywords = [k for k in query_lower.split() if len(k) > 3]
|
|
109
|
+
|
|
110
|
+
scored_cases = []
|
|
111
|
+
for case in self.cases:
|
|
112
|
+
score = 0
|
|
113
|
+
|
|
114
|
+
# Search in pertanyaan
|
|
115
|
+
if query_lower in case.get('pertanyaan', '').lower():
|
|
116
|
+
score += 20
|
|
117
|
+
|
|
118
|
+
# Search in kasus
|
|
119
|
+
if query_lower in case.get('kasus', '').lower():
|
|
120
|
+
score += 10
|
|
121
|
+
|
|
122
|
+
# Search in jawaban
|
|
123
|
+
if query_lower in case.get('jawaban', '').lower():
|
|
124
|
+
score += 5
|
|
125
|
+
|
|
126
|
+
# Keyword matching
|
|
127
|
+
full_content = case.get('full_content', '').lower()
|
|
128
|
+
for keyword in keywords:
|
|
129
|
+
count = full_content.count(keyword)
|
|
130
|
+
score += count * 2
|
|
131
|
+
|
|
132
|
+
if score > 0:
|
|
133
|
+
case_copy = case.copy()
|
|
134
|
+
case_copy['similarity_score'] = score / 100.0 # Normalize
|
|
135
|
+
case_copy['search_method'] = 'basic'
|
|
136
|
+
scored_cases.append((score, case_copy))
|
|
137
|
+
|
|
138
|
+
# Sort and return top k
|
|
139
|
+
scored_cases.sort(reverse=True, key=lambda x: x[0])
|
|
140
|
+
return [case for score, case in scored_cases[:top_k]]
|
|
141
|
+
|
|
142
|
+
def get_stats(self):
|
|
143
|
+
"""Get search engine statistics"""
|
|
144
|
+
return {
|
|
145
|
+
'total_cases': len(self.cases),
|
|
146
|
+
'search_method': 'tfidf' if self.use_tfidf else 'basic',
|
|
147
|
+
'sklearn_available': SKLEARN_AVAILABLE
|
|
148
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Advanced Prompt Templates
|
|
4
|
+
Optimized prompts for better AI responses
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
class PromptTemplates:
|
|
8
|
+
"""Collection of optimized prompt templates"""
|
|
9
|
+
|
|
10
|
+
@staticmethod
|
|
11
|
+
def legal_analysis_prompt(question, context_cases):
|
|
12
|
+
"""
|
|
13
|
+
Comprehensive legal analysis prompt
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
question: User's legal question
|
|
17
|
+
context_cases: Relevant cases from MayaLaw
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
Optimized prompt string
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
# Build context from cases
|
|
24
|
+
context = ""
|
|
25
|
+
for i, case in enumerate(context_cases[:2], 1):
|
|
26
|
+
context += f"""
|
|
27
|
+
KASUS REFERENSI #{i}:
|
|
28
|
+
Pertanyaan: {case.get('pertanyaan', '')[:200]}
|
|
29
|
+
Jawaban: {case.get('jawaban', '')[:300]}
|
|
30
|
+
Dasar Hukum: {', '.join(case.get('pasal', [])[:3])}
|
|
31
|
+
UU: {', '.join(case.get('uu', [])[:2])}
|
|
32
|
+
---
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
return f"""
|
|
36
|
+
Anda adalah ahli hukum Indonesia senior dengan pengalaman 20+ tahun di berbagai bidang hukum.
|
|
37
|
+
|
|
38
|
+
KONTEKS DARI DATABASE MAYALAW:
|
|
39
|
+
{context}
|
|
40
|
+
|
|
41
|
+
PERTANYAAN KLIEN:
|
|
42
|
+
{question}
|
|
43
|
+
|
|
44
|
+
INSTRUKSI ANALISIS:
|
|
45
|
+
1. Baca pertanyaan dengan teliti dan identifikasi isu hukum utama
|
|
46
|
+
2. Analisis konteks dari database MayaLaw yang relevan
|
|
47
|
+
3. Identifikasi Pasal dan UU yang spesifik dan berlaku
|
|
48
|
+
4. Berikan reasoning yang jelas dan logis
|
|
49
|
+
5. Sertakan confidence level dengan justifikasi
|
|
50
|
+
|
|
51
|
+
FORMAT JAWABAN (WAJIB IKUTI):
|
|
52
|
+
|
|
53
|
+
## 🎯 RINGKASAN SINGKAT
|
|
54
|
+
[Jawaban dalam 1-2 kalimat yang langsung menjawab pertanyaan]
|
|
55
|
+
|
|
56
|
+
## ⚖️ ANALISIS HUKUM
|
|
57
|
+
[Analisis mendalam dengan reasoning step-by-step]
|
|
58
|
+
|
|
59
|
+
## 📖 DASAR HUKUM
|
|
60
|
+
**Pasal yang Relevan:**
|
|
61
|
+
- Pasal [nomor] [nama UU]: [penjelasan singkat]
|
|
62
|
+
- [tambahkan pasal lain jika relevan]
|
|
63
|
+
|
|
64
|
+
**Undang-Undang:**
|
|
65
|
+
- UU No. [nomor] Tahun [tahun] tentang [judul]
|
|
66
|
+
- [tambahkan UU lain jika relevan]
|
|
67
|
+
|
|
68
|
+
## 💡 REKOMENDASI PRAKTIS
|
|
69
|
+
1. [Langkah konkret yang bisa diambil]
|
|
70
|
+
2. [Pertimbangan penting]
|
|
71
|
+
3. [Alternatif jika ada]
|
|
72
|
+
|
|
73
|
+
## 📊 TINGKAT KEYAKINAN
|
|
74
|
+
[X%] - [Alasan spesifik mengapa confidence level ini, berdasarkan kekuatan dasar hukum dan relevansi kasus]
|
|
75
|
+
|
|
76
|
+
## 📚 REFERENSI
|
|
77
|
+
- Berdasarkan Kasus MayaLaw #{case.get('number', 'N/A')}
|
|
78
|
+
- [Sumber lain jika ada]
|
|
79
|
+
|
|
80
|
+
PENTING:
|
|
81
|
+
- Gunakan bahasa yang jelas dan mudah dipahami
|
|
82
|
+
- Hindari jargon hukum yang tidak perlu
|
|
83
|
+
- Berikan contoh konkret jika membantu
|
|
84
|
+
- Jika tidak yakin, katakan dengan jujur
|
|
85
|
+
|
|
86
|
+
Mulai analisis Anda:
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
@staticmethod
|
|
90
|
+
def chain_of_thought_prompt(question, context_cases):
|
|
91
|
+
"""
|
|
92
|
+
Chain-of-thought reasoning prompt
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
question: User's legal question
|
|
96
|
+
context_cases: Relevant cases
|
|
97
|
+
|
|
98
|
+
Returns:
|
|
99
|
+
Chain-of-thought prompt
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
context = "\n".join([
|
|
103
|
+
f"- Kasus #{c.get('number')}: {c.get('pertanyaan', '')[:100]}"
|
|
104
|
+
for c in context_cases[:3]
|
|
105
|
+
])
|
|
106
|
+
|
|
107
|
+
return f"""
|
|
108
|
+
Gunakan chain-of-thought reasoning untuk menjawab pertanyaan hukum ini secara sistematis.
|
|
109
|
+
|
|
110
|
+
PERTANYAAN: {question}
|
|
111
|
+
|
|
112
|
+
KONTEKS DARI MAYALAW:
|
|
113
|
+
{context}
|
|
114
|
+
|
|
115
|
+
PROSES ANALISIS STEP-BY-STEP:
|
|
116
|
+
|
|
117
|
+
**Langkah 1: Identifikasi Isu Hukum**
|
|
118
|
+
[Tuliskan dengan jelas isu hukum apa yang perlu dijawab]
|
|
119
|
+
|
|
120
|
+
**Langkah 2: Cari Dasar Hukum**
|
|
121
|
+
[Identifikasi Pasal dan UU yang relevan dari konteks atau pengetahuan hukum]
|
|
122
|
+
|
|
123
|
+
**Langkah 3: Analisis Penerapan**
|
|
124
|
+
[Bagaimana hukum diterapkan pada situasi ini? Apa implikasinya?]
|
|
125
|
+
|
|
126
|
+
**Langkah 4: Pertimbangkan Preseden**
|
|
127
|
+
[Apakah ada kasus serupa di database? Apa pembelajaran dari kasus tersebut?]
|
|
128
|
+
|
|
129
|
+
**Langkah 5: Evaluasi Alternatif**
|
|
130
|
+
[Apakah ada interpretasi atau pendekatan alternatif yang perlu dipertimbangkan?]
|
|
131
|
+
|
|
132
|
+
**Langkah 6: Kesimpulan**
|
|
133
|
+
[Jawaban final dengan confidence level dan alasan]
|
|
134
|
+
|
|
135
|
+
Mulai analisis step-by-step Anda:
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
@staticmethod
|
|
139
|
+
def quick_answer_prompt(question, context_cases):
|
|
140
|
+
"""
|
|
141
|
+
Quick answer prompt for simple questions
|
|
142
|
+
|
|
143
|
+
Args:
|
|
144
|
+
question: User's legal question
|
|
145
|
+
context_cases: Relevant cases
|
|
146
|
+
|
|
147
|
+
Returns:
|
|
148
|
+
Quick answer prompt
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
if context_cases:
|
|
152
|
+
case = context_cases[0]
|
|
153
|
+
context = f"""
|
|
154
|
+
Referensi: Kasus #{case.get('number')}
|
|
155
|
+
Pertanyaan serupa: {case.get('pertanyaan', '')[:150]}
|
|
156
|
+
Jawaban: {case.get('jawaban', '')[:200]}
|
|
157
|
+
Pasal: {', '.join(case.get('pasal', [])[:2])}
|
|
158
|
+
"""
|
|
159
|
+
else:
|
|
160
|
+
context = "Tidak ada kasus serupa di database."
|
|
161
|
+
|
|
162
|
+
return f"""
|
|
163
|
+
Berikan jawaban singkat dan jelas untuk pertanyaan hukum ini.
|
|
164
|
+
|
|
165
|
+
PERTANYAAN: {question}
|
|
166
|
+
|
|
167
|
+
KONTEKS:
|
|
168
|
+
{context}
|
|
169
|
+
|
|
170
|
+
FORMAT JAWABAN:
|
|
171
|
+
|
|
172
|
+
**Jawaban Singkat:**
|
|
173
|
+
[1-2 kalimat yang langsung menjawab]
|
|
174
|
+
|
|
175
|
+
**Dasar Hukum:**
|
|
176
|
+
[Pasal dan UU yang relevan]
|
|
177
|
+
|
|
178
|
+
**Catatan:**
|
|
179
|
+
[Informasi tambahan penting jika ada]
|
|
180
|
+
|
|
181
|
+
Jawab dengan singkat dan jelas:
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
@staticmethod
|
|
185
|
+
def document_analysis_prompt(document_text, question):
|
|
186
|
+
"""
|
|
187
|
+
Prompt for analyzing legal documents
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
document_text: Text from uploaded document
|
|
191
|
+
question: Specific question about the document
|
|
192
|
+
|
|
193
|
+
Returns:
|
|
194
|
+
Document analysis prompt
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
return f"""
|
|
198
|
+
Anda adalah ahli hukum yang diminta menganalisis dokumen legal.
|
|
199
|
+
|
|
200
|
+
DOKUMEN:
|
|
201
|
+
{document_text[:2000]}
|
|
202
|
+
[... dokumen dipotong untuk efisiensi ...]
|
|
203
|
+
|
|
204
|
+
PERTANYAAN TENTANG DOKUMEN:
|
|
205
|
+
{question}
|
|
206
|
+
|
|
207
|
+
INSTRUKSI ANALISIS:
|
|
208
|
+
1. Baca dokumen dengan teliti
|
|
209
|
+
2. Identifikasi klausul-klausul penting
|
|
210
|
+
3. Cari potensi masalah atau risiko
|
|
211
|
+
4. Jawab pertanyaan spesifik yang diajukan
|
|
212
|
+
|
|
213
|
+
FORMAT JAWABAN:
|
|
214
|
+
|
|
215
|
+
## 📄 RINGKASAN DOKUMEN
|
|
216
|
+
[Ringkasan singkat isi dokumen]
|
|
217
|
+
|
|
218
|
+
## 🔍 ANALISIS KLAUSUL PENTING
|
|
219
|
+
[Klausul-klausul yang perlu diperhatikan]
|
|
220
|
+
|
|
221
|
+
## ⚠️ POTENSI RISIKO
|
|
222
|
+
[Risiko atau masalah yang teridentifikasi]
|
|
223
|
+
|
|
224
|
+
## 💡 JAWABAN PERTANYAAN
|
|
225
|
+
[Jawaban spesifik untuk pertanyaan yang diajukan]
|
|
226
|
+
|
|
227
|
+
## 📋 REKOMENDASI
|
|
228
|
+
[Saran perbaikan atau tindakan yang perlu diambil]
|
|
229
|
+
|
|
230
|
+
Mulai analisis dokumen:
|
|
231
|
+
"""
|
|
232
|
+
|
|
233
|
+
@staticmethod
|
|
234
|
+
def comparative_analysis_prompt(question, answers_from_models):
|
|
235
|
+
"""
|
|
236
|
+
Prompt for comparing answers from multiple AI models
|
|
237
|
+
|
|
238
|
+
Args:
|
|
239
|
+
question: Original question
|
|
240
|
+
answers_from_models: Dict of model_name: answer
|
|
241
|
+
|
|
242
|
+
Returns:
|
|
243
|
+
Comparative analysis prompt
|
|
244
|
+
"""
|
|
245
|
+
|
|
246
|
+
answers_text = "\n\n".join([
|
|
247
|
+
f"**{model}:**\n{answer[:500]}"
|
|
248
|
+
for model, answer in answers_from_models.items()
|
|
249
|
+
])
|
|
250
|
+
|
|
251
|
+
return f"""
|
|
252
|
+
Anda diminta membandingkan beberapa jawaban dari AI models berbeda untuk pertanyaan hukum yang sama.
|
|
253
|
+
|
|
254
|
+
PERTANYAAN ORIGINAL:
|
|
255
|
+
{question}
|
|
256
|
+
|
|
257
|
+
JAWABAN DARI BERBAGAI MODEL:
|
|
258
|
+
{answers_text}
|
|
259
|
+
|
|
260
|
+
TUGAS ANDA:
|
|
261
|
+
1. Bandingkan kualitas setiap jawaban
|
|
262
|
+
2. Identifikasi perbedaan pendapat jika ada
|
|
263
|
+
3. Tentukan jawaban mana yang paling akurat
|
|
264
|
+
4. Berikan jawaban final yang menggabungkan yang terbaik
|
|
265
|
+
|
|
266
|
+
FORMAT ANALISIS:
|
|
267
|
+
|
|
268
|
+
## 📊 PERBANDINGAN JAWABAN
|
|
269
|
+
[Ringkasan perbedaan dan persamaan]
|
|
270
|
+
|
|
271
|
+
## ✅ KELEBIHAN SETIAP JAWABAN
|
|
272
|
+
[Apa yang baik dari masing-masing jawaban]
|
|
273
|
+
|
|
274
|
+
## ⚠️ KELEMAHAN YANG TERIDENTIFIKASI
|
|
275
|
+
[Kesalahan atau kekurangan yang ditemukan]
|
|
276
|
+
|
|
277
|
+
## 🎯 JAWABAN FINAL (BEST OF ALL)
|
|
278
|
+
[Jawaban terbaik yang menggabungkan semua insight]
|
|
279
|
+
|
|
280
|
+
## 💯 CONFIDENCE LEVEL
|
|
281
|
+
[Tingkat keyakinan dengan alasan]
|
|
282
|
+
|
|
283
|
+
Mulai analisis komparatif:
|
|
284
|
+
"""
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""
|
|
2
|
+
VersaLaw2 Core Package
|
|
3
|
+
Complete legal AI system
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .system import VersaLaw2System
|
|
7
|
+
from .config import Config
|
|
8
|
+
from .data_loader import MayaLawDataLoader
|
|
9
|
+
|
|
10
|
+
__version__ = "2.0.0"
|
|
11
|
+
__all__ = ['VersaLaw2System', 'Config', 'MayaLawDataLoader']
|