JatsTheAIGen commited on
Commit
a3e5843
·
1 Parent(s): 80a97c8

Process flow visualizer + key skills [for validation only) V6

Browse files
integration_validation.py ADDED
@@ -0,0 +1 @@
 
 
1
+
src/agents/skills_identification_agent.py CHANGED
@@ -130,11 +130,18 @@ class SkillsIdentificationAgent:
130
  skill_classification = await self._classify_skills(user_input, context)
131
 
132
  # Combine results
 
 
 
 
 
 
 
133
  result = {
134
  "agent_id": self.agent_id,
135
  "market_analysis": market_analysis,
136
  "skill_classification": skill_classification,
137
- "identified_skills": self._extract_high_probability_skills(skill_classification),
138
  "processing_time": market_analysis.get("processing_time", 0) + skill_classification.get("processing_time", 0),
139
  "confidence_score": self._calculate_overall_confidence(market_analysis, skill_classification)
140
  }
@@ -423,7 +430,8 @@ Respond in JSON format:
423
  high_prob_skills = []
424
 
425
  # From market analysis
426
- market_skills = classification.get("market_analysis", {}).get("selected_skills", [])
 
427
  for skill in market_skills:
428
  if skill.get("relevance_score", 0) > 0.2:
429
  high_prob_skills.append({
@@ -434,7 +442,8 @@ Respond in JSON format:
434
  })
435
 
436
  # From skill classification
437
- classification_skills = classification.get("skill_classification", {}).get("top_skills", [])
 
438
  for skill in classification_skills:
439
  if skill.get("probability", 0) > 0.2:
440
  high_prob_skills.append({
@@ -444,6 +453,30 @@ Respond in JSON format:
444
  "source": "skill_classification"
445
  })
446
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  # Remove duplicates and sort by probability
448
  unique_skills = {}
449
  for skill in high_prob_skills:
 
130
  skill_classification = await self._classify_skills(user_input, context)
131
 
132
  # Combine results
133
+ combined_data = {
134
+ "market_analysis": market_analysis,
135
+ "skill_classification": skill_classification,
136
+ "user_input": user_input,
137
+ "context": context
138
+ }
139
+
140
  result = {
141
  "agent_id": self.agent_id,
142
  "market_analysis": market_analysis,
143
  "skill_classification": skill_classification,
144
+ "identified_skills": self._extract_high_probability_skills(combined_data),
145
  "processing_time": market_analysis.get("processing_time", 0) + skill_classification.get("processing_time", 0),
146
  "confidence_score": self._calculate_overall_confidence(market_analysis, skill_classification)
147
  }
 
430
  high_prob_skills = []
431
 
432
  # From market analysis
433
+ market_analysis = classification.get("market_analysis", {})
434
+ market_skills = market_analysis.get("selected_skills", [])
435
  for skill in market_skills:
436
  if skill.get("relevance_score", 0) > 0.2:
437
  high_prob_skills.append({
 
442
  })
443
 
444
  # From skill classification
445
+ skill_classification = classification.get("skill_classification", {})
446
+ classification_skills = skill_classification.get("top_skills", [])
447
  for skill in classification_skills:
448
  if skill.get("probability", 0) > 0.2:
449
  high_prob_skills.append({
 
453
  "source": "skill_classification"
454
  })
455
 
456
+ # If no skills found from LLM, use rule-based fallback
457
+ if not high_prob_skills:
458
+ logger.warning(f"{self.agent_id} No skills identified from LLM, using rule-based fallback")
459
+ # Extract user input from context if available
460
+ user_input = ""
461
+ if isinstance(classification, dict) and "user_input" in classification:
462
+ user_input = classification["user_input"]
463
+ elif isinstance(classification, dict) and "context" in classification:
464
+ context = classification["context"]
465
+ if isinstance(context, dict) and "user_input" in context:
466
+ user_input = context["user_input"]
467
+
468
+ if user_input:
469
+ rule_based_result = self._rule_based_skill_classification(user_input)
470
+ rule_skills = rule_based_result.get("top_skills", [])
471
+ for skill in rule_skills:
472
+ if skill.get("probability", 0) > 0.2:
473
+ high_prob_skills.append({
474
+ "skill": skill["skill"],
475
+ "category": "rule_based",
476
+ "probability": skill["probability"],
477
+ "source": "rule_based_fallback"
478
+ })
479
+
480
  # Remove duplicates and sort by probability
481
  unique_skills = {}
482
  for skill in high_prob_skills:
src/llm_router.py CHANGED
@@ -78,8 +78,9 @@ class LLMRouter:
78
  import requests
79
 
80
  model_id = model_config["model_id"]
 
81
 
82
- # Use the chat completions endpoint
83
  api_url = "https://router.huggingface.co/v1/chat/completions"
84
 
85
  logger.info(f"Calling HF Chat Completions API for model: {model_id}")
 
78
  import requests
79
 
80
  model_id = model_config["model_id"]
81
+ is_chat_model = model_config.get("is_chat_model", True)
82
 
83
+ # Use the chat completions endpoint for chat models
84
  api_url = "https://router.huggingface.co/v1/chat/completions"
85
 
86
  logger.info(f"Calling HF Chat Completions API for model: {model_id}")
src/models_config.py CHANGED
@@ -8,27 +8,31 @@ LLM_CONFIG = {
8
  "max_tokens": 2000,
9
  "temperature": 0.7,
10
  "cost_per_token": 0.000015,
11
- "fallback": "gpt2" # Simple but guaranteed working model
 
12
  },
13
  "embedding_specialist": {
14
  "model_id": "sentence-transformers/all-MiniLM-L6-v2",
15
  "task": "embeddings",
16
  "vector_dimensions": 384,
17
  "purpose": "semantic_similarity",
18
- "cost_advantage": "90%_cheaper_than_primary"
 
19
  },
20
  "classification_specialist": {
21
- "model_id": "cardiffnlp/twitter-roberta-base-emotion",
22
  "task": "intent_classification",
23
  "max_length": 512,
24
  "specialization": "fast_inference",
25
- "latency_target": "<100ms"
 
26
  },
27
  "safety_checker": {
28
- "model_id": "unitary/unbiased-toxic-roberta",
29
  "task": "content_moderation",
30
  "confidence_threshold": 0.85,
31
- "purpose": "bias_detection"
 
32
  }
33
  },
34
  "routing_logic": {
 
8
  "max_tokens": 2000,
9
  "temperature": 0.7,
10
  "cost_per_token": 0.000015,
11
+ "fallback": "gpt2", # Simple but guaranteed working model
12
+ "is_chat_model": True
13
  },
14
  "embedding_specialist": {
15
  "model_id": "sentence-transformers/all-MiniLM-L6-v2",
16
  "task": "embeddings",
17
  "vector_dimensions": 384,
18
  "purpose": "semantic_similarity",
19
+ "cost_advantage": "90%_cheaper_than_primary",
20
+ "is_chat_model": False
21
  },
22
  "classification_specialist": {
23
+ "model_id": "Qwen/Qwen2.5-7B-Instruct", # Use chat model for classification
24
  "task": "intent_classification",
25
  "max_length": 512,
26
  "specialization": "fast_inference",
27
+ "latency_target": "<100ms",
28
+ "is_chat_model": True
29
  },
30
  "safety_checker": {
31
+ "model_id": "Qwen/Qwen2.5-7B-Instruct", # Use chat model for safety
32
  "task": "content_moderation",
33
  "confidence_threshold": 0.85,
34
+ "purpose": "bias_detection",
35
+ "is_chat_model": True
36
  }
37
  },
38
  "routing_logic": {