Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion dlplus/core/arabic_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class IntentType(Enum):
"""Types of user intents / أنواع النوايا"""
GREETING = "greeting"
SEARCH = "search"
GENERATE_CODE = "generate_code"
EXECUTE_COMMAND = "execute_command"
Expand All @@ -30,6 +31,10 @@ class ArabicProcessor:
def __init__(self):
# Arabic intent keywords / كلمات مفتاحية للنوايا
self.intent_keywords = {
IntentType.GREETING: [
"اهلا", "مرحبا", "السلام عليكم", "صباح الخير", "مساء الخير",
"اهلا وسهلا", "حياك", "اهلين", "يا هلا", "أهلا"
],
IntentType.SEARCH: [
"ابحث", "بحث", "ابحث عن", "جد", "ايجاد", "أبحث"
],
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -148,6 +155,7 @@ def generate_response(self, intent: IntentType, context: Dict) -> str:
توليد استجابة عربية بناءً على النية
"""
responses = {
IntentType.GREETING: "أهلاً وسهلاً! أنا وكيل ذكي جاهز لمساعدتك. كيف يمكنني خدمتك اليوم؟",
IntentType.SEARCH: "سأقوم بالبحث عن المعلومات المطلوبة...",
IntentType.GENERATE_CODE: "سأقوم بتوليد الكود البرمجي المطلوب...",
IntentType.EXECUTE_COMMAND: "سأقوم بتنفيذ الأمر المطلوب...",
Expand Down
20 changes: 17 additions & 3 deletions dlplus/core/intelligence_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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"]]
Expand Down
14 changes: 14 additions & 0 deletions tests/test_dlplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down