krushnakant27 commited on
Commit
d8815b9
·
verified ·
1 Parent(s): 52ec1ca

Update agents/router.py

Browse files
Files changed (1) hide show
  1. agents/router.py +49 -49
agents/router.py CHANGED
@@ -1,50 +1,50 @@
1
-
2
- import os
3
- from typing import Dict
4
- from google.generativeai import configure
5
- import google.generativeai as genai
6
-
7
- class RouterAgent:
8
- def __init__(self):
9
- configure(api_key=os.getenv('GEMINI_API_KEY'))
10
- self.model = genai.GenerativeModel('models/gemini-2.0-flash-lite')
11
-
12
- def route(self, parsed_problem: Dict) -> Dict:
13
- topic = parsed_problem.get('topic', 'unknown')
14
- needs_clarification = parsed_problem.get('needs_clarification', False)
15
-
16
- if needs_clarification:
17
- return {
18
- 'action': 'request_clarification',
19
- 'requires_hitl': True,
20
- 'reason': 'Problem statement is ambiguous or incomplete'
21
- }
22
-
23
- if topic == 'unknown':
24
- return {
25
- 'action': 'request_clarification',
26
- 'requires_hitl': True,
27
- 'reason': 'Cannot determine problem topic'
28
- }
29
-
30
- strategy = self._determine_strategy(parsed_problem)
31
-
32
- return {
33
- 'action': 'solve',
34
- 'requires_hitl': False,
35
- 'strategy': strategy,
36
- 'topic': topic
37
- }
38
-
39
- def _determine_strategy(self, problem: Dict) -> str:
40
- topic = problem.get('topic', '')
41
-
42
- strategies = {
43
- 'algebra': 'algebraic_manipulation',
44
- 'probability': 'counting_and_probability',
45
- 'calculus': 'differentiation_integration',
46
- 'linear_algebra': 'matrix_operations'
47
- }
48
-
49
-
50
  return strategies.get(topic, 'general_problem_solving')
 
1
+
2
+ import os
3
+ from typing import Dict
4
+ from google.generativeai import configure
5
+ import google.generativeai as genai
6
+
7
+ class RouterAgent:
8
+ def __init__(self):
9
+ configure(api_key=os.getenv('GEMINI_API_KEY'))
10
+ self.model = genai.GenerativeModel('models/gemini-2.5-flash-lite')
11
+
12
+ def route(self, parsed_problem: Dict) -> Dict:
13
+ topic = parsed_problem.get('topic', 'unknown')
14
+ needs_clarification = parsed_problem.get('needs_clarification', False)
15
+
16
+ if needs_clarification:
17
+ return {
18
+ 'action': 'request_clarification',
19
+ 'requires_hitl': True,
20
+ 'reason': 'Problem statement is ambiguous or incomplete'
21
+ }
22
+
23
+ if topic == 'unknown':
24
+ return {
25
+ 'action': 'request_clarification',
26
+ 'requires_hitl': True,
27
+ 'reason': 'Cannot determine problem topic'
28
+ }
29
+
30
+ strategy = self._determine_strategy(parsed_problem)
31
+
32
+ return {
33
+ 'action': 'solve',
34
+ 'requires_hitl': False,
35
+ 'strategy': strategy,
36
+ 'topic': topic
37
+ }
38
+
39
+ def _determine_strategy(self, problem: Dict) -> str:
40
+ topic = problem.get('topic', '')
41
+
42
+ strategies = {
43
+ 'algebra': 'algebraic_manipulation',
44
+ 'probability': 'counting_and_probability',
45
+ 'calculus': 'differentiation_integration',
46
+ 'linear_algebra': 'matrix_operations'
47
+ }
48
+
49
+
50
  return strategies.get(topic, 'general_problem_solving')