Spaces:
Sleeping
Sleeping
| #!/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}") |