diff --git a/dlplus/core/arabic_processor.py b/dlplus/core/arabic_processor.py index 0f7775f..be3c838 100644 --- a/dlplus/core/arabic_processor.py +++ b/dlplus/core/arabic_processor.py @@ -10,6 +10,7 @@ class IntentType(Enum): """Types of user intents / أنواع النوايا""" + GREETING = "greeting" SEARCH = "search" GENERATE_CODE = "generate_code" EXECUTE_COMMAND = "execute_command" @@ -30,6 +31,10 @@ class ArabicProcessor: def __init__(self): # Arabic intent keywords / كلمات مفتاحية للنوايا self.intent_keywords = { + IntentType.GREETING: [ + "اهلا", "مرحبا", "السلام عليكم", "صباح الخير", "مساء الخير", + "اهلا وسهلا", "حياك", "اهلين", "يا هلا", "أهلا" + ], IntentType.SEARCH: [ "ابحث", "بحث", "ابحث عن", "جد", "ايجاد", "أبحث" ], @@ -101,7 +106,9 @@ def detect_intent(self, text: str) -> IntentType: return intent # Check English keywords - if any(word in text.lower() for word in ['search', 'find', 'look for']): + if any(word in text.lower() for word in ['hello', 'hi', 'hey', 'greetings', 'good morning', 'good evening', 'howdy']): + return IntentType.GREETING + elif any(word in text.lower() for word in ['search', 'find', 'look for']): return IntentType.SEARCH elif any(word in text.lower() for word in ['code', 'program', 'script', 'generate']): return IntentType.GENERATE_CODE @@ -148,6 +155,7 @@ def generate_response(self, intent: IntentType, context: Dict) -> str: توليد استجابة عربية بناءً على النية """ responses = { + IntentType.GREETING: "أهلاً وسهلاً! أنا وكيل ذكي جاهز لمساعدتك. كيف يمكنني خدمتك اليوم؟", IntentType.SEARCH: "سأقوم بالبحث عن المعلومات المطلوبة...", IntentType.GENERATE_CODE: "سأقوم بتوليد الكود البرمجي المطلوب...", IntentType.EXECUTE_COMMAND: "سأقوم بتنفيذ الأمر المطلوب...", diff --git a/dlplus/core/intelligence_core.py b/dlplus/core/intelligence_core.py index 96c3c36..7e99fee 100644 --- a/dlplus/core/intelligence_core.py +++ b/dlplus/core/intelligence_core.py @@ -127,7 +127,11 @@ def _select_tools(self, intent: IntentType, entities: Dict) -> List[str]: """Select tools needed based on intent and entities""" tools = [] - if intent == IntentType.SEARCH: + if intent == IntentType.GREETING: + # Greetings don't need any special tools + pass + + elif intent == IntentType.SEARCH: tools.append("run_web_search") elif intent == IntentType.GENERATE_CODE: @@ -167,7 +171,13 @@ def _create_execution_plan( } # Build steps based on intent - if intent == IntentType.SEARCH: + if intent == IntentType.GREETING: + plan["steps"] = [ + {"action": "generate_greeting", "tool": "arabic_processor"} + ] + plan["expected_output"] = "Friendly greeting response" + + elif intent == IntentType.SEARCH: plan["steps"] = [ {"action": "web_search", "tool": "run_web_search"}, {"action": "analyze_results", "tool": "intelligence_core"}, @@ -217,7 +227,11 @@ async def _execute_plan( {} ) else: - response = f"Processing your request with intent: {intent}" + # English responses + if intent == IntentType.GREETING.value: + response = "Hello! I'm an intelligent AI agent ready to assist you. How can I help you today?" + else: + response = f"Processing your request with intent: {intent}" results["response"] = response results["steps_completed"] = [step["action"] for step in plan["steps"]] diff --git a/tests/test_dlplus.py b/tests/test_dlplus.py index f09c4a9..aa6fba1 100644 --- a/tests/test_dlplus.py +++ b/tests/test_dlplus.py @@ -46,6 +46,20 @@ def test_detect_intent_english(self): assert self.processor.detect_intent("generate code") == IntentType.GENERATE_CODE assert self.processor.detect_intent("run command") == IntentType.EXECUTE_COMMAND + def test_detect_greeting_arabic(self): + """Test greeting detection for Arabic""" + assert self.processor.detect_intent("اهلا") == IntentType.GREETING + assert self.processor.detect_intent("مرحبا") == IntentType.GREETING + assert self.processor.detect_intent("السلام عليكم") == IntentType.GREETING + assert self.processor.detect_intent("صباح الخير") == IntentType.GREETING + + def test_detect_greeting_english(self): + """Test greeting detection for English""" + assert self.processor.detect_intent("hello") == IntentType.GREETING + assert self.processor.detect_intent("hi") == IntentType.GREETING + assert self.processor.detect_intent("hey") == IntentType.GREETING + assert self.processor.detect_intent("good morning") == IntentType.GREETING + def test_extract_entities(self): """Test entity extraction""" text = "Read file test.py and search https://example.com"