File size: 2,601 Bytes
7ce3a9e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""

Direct Query for Insider Trading Case

"""

import os
import sys
import asyncio
import json
from pathlib import Path

# Add src directory to Python path
sys.path.insert(0, str(Path(__file__).parent / "src"))

async def query_insider_trading():
    """Query the insider trading regulations."""
    try:
        from src.ui.enhanced_gradio_app import EnhancedArabicChatbot
        app = EnhancedArabicChatbot()
        
        # Arabic query about insider trading
        query = """

        يشغل السيد خالد الأحمد منصب رئيس مجلس إدارة في بنك الكويت الدولي، وهو مساهم رئيسي (35%) في الشركة الخليجية للاستثمار المدرجة في بورصة الكويت. قام السيد خالد بتوجيه الصندوق الاستثماري (عبر شركته) لشراء أسهم إضافية في البنك بقيمة 15 مليون دينار كويتي، قبل أسبوع من الإعلان عن النتائج المالية القوية والتي تتضمن مؤشرات إيجابية غير معلنة.



        هل تشكل تصرفات السيد خالد انتهاكاً لقواعد منع الاستفادة من المعلومات الداخلية وفقاً للكتاب الحادي عشر (التعامل في الأوراق المالية) والكتاب الثامن (أخلاقيات العمل)؟

        """
        
        history = []
        result_history, status = await app.process_query(query, history)
        
        if result_history and len(result_history) >= 2:
            response = result_history[-1]['content']
            
            # Save results to file
            results = {
                "query": query,
                "response": response,
                "status": status,
                "response_length": len(response)
            }
            
            with open("insider_trading_results.json", "w", encoding="utf-8") as f:
                json.dump(results, f, indent=2, ensure_ascii=False)
            
            print(f"Query processed successfully. Response length: {len(response)} characters")
            print(f"Status: {status}")
            return True
            
        else:
            print(f"Query failed with status: {status}")
            return False
        
    except Exception as e:
        print(f"Error: {e}")
        return False

if __name__ == "__main__":
    success = asyncio.run(query_insider_trading())
    print(f"Success: {success}")