Hassankhwileh commited on
Commit
f263c99
·
verified ·
1 Parent(s): b6737fb

Update agents.py

Browse files
Files changed (1) hide show
  1. agents.py +13 -25
agents.py CHANGED
@@ -1,32 +1,22 @@
 
 
1
  from crewai import Agent
2
  from langchain.tools import Tool
3
  from utils import create_uae_legal_tools
4
  from config import get_ai_config
5
- from typing import Dict, Any
6
 
7
- def get_base_llm_config() -> Dict[str, Any]:
8
  """Get LLM configuration based on current settings"""
9
  ai_config = get_ai_config()
10
-
11
- return {
12
- "config_list": [{
13
- "model": ai_config["model"],
14
- "api_key": ai_config["api_key"]
15
- }],
16
- "temperature": ai_config["temperature"],
17
- "max_tokens": ai_config["max_tokens"],
18
- "request_timeout": 600,
19
- "seed": 42,
20
- "config": {
21
- "use_lite_llm": True,
22
- "lite_llm_model_name": ai_config["model"],
23
- "api_key": ai_config["api_key"]
24
- },
25
- "llm_type": "groq"
26
- }
27
 
28
  def create_judge_agent():
29
- llm_config = get_base_llm_config()
30
  return Agent(
31
  role='قاضي قانوني إماراتي',
32
  goal='تقديم أحكام وتفسيرات قانونية دقيقة بناءً على القانون الإماراتي',
@@ -38,12 +28,11 @@ def create_judge_agent():
38
  """,
39
  verbose=True,
40
  allow_delegation=False,
41
- llm_config=llm_config,
42
  tools=create_uae_legal_tools()
43
  )
44
 
45
  def create_advocate_agent():
46
- llm_config = get_base_llm_config()
47
  return Agent(
48
  role='محامي إماراتي',
49
  goal='تقديم التمثيل القانوني والمشورة المتخصصة بناءً على القانون الإماراتي',
@@ -54,12 +43,11 @@ def create_advocate_agent():
54
  """,
55
  verbose=True,
56
  allow_delegation=False,
57
- llm_config=llm_config,
58
  tools=create_uae_legal_tools()
59
  )
60
 
61
  def create_consultant_agent():
62
- llm_config = get_base_llm_config()
63
  return Agent(
64
  role='مستشار قضائي إماراتي',
65
  goal='تقديم الاستشارات والتوجيه القانوني المتخصص في القانون الإماراتي',
@@ -70,6 +58,6 @@ def create_consultant_agent():
70
  """,
71
  verbose=True,
72
  allow_delegation=False,
73
- llm_config=llm_config,
74
  tools=create_uae_legal_tools()
75
  )
 
1
+ # agents.py
2
+
3
  from crewai import Agent
4
  from langchain.tools import Tool
5
  from utils import create_uae_legal_tools
6
  from config import get_ai_config
7
+ from ai_providers import AIProviderFactory
8
 
9
+ def get_base_llm_config():
10
  """Get LLM configuration based on current settings"""
11
  ai_config = get_ai_config()
12
+ provider = AIProviderFactory.create_provider(
13
+ ai_config["provider"],
14
+ api_key=ai_config["api_key"],
15
+ model=ai_config["model"]
16
+ )
17
+ return provider.get_config()
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  def create_judge_agent():
 
20
  return Agent(
21
  role='قاضي قانوني إماراتي',
22
  goal='تقديم أحكام وتفسيرات قانونية دقيقة بناءً على القانون الإماراتي',
 
28
  """,
29
  verbose=True,
30
  allow_delegation=False,
31
+ llm_config=get_base_llm_config(),
32
  tools=create_uae_legal_tools()
33
  )
34
 
35
  def create_advocate_agent():
 
36
  return Agent(
37
  role='محامي إماراتي',
38
  goal='تقديم التمثيل القانوني والمشورة المتخصصة بناءً على القانون الإماراتي',
 
43
  """,
44
  verbose=True,
45
  allow_delegation=False,
46
+ llm_config=get_base_llm_config(),
47
  tools=create_uae_legal_tools()
48
  )
49
 
50
  def create_consultant_agent():
 
51
  return Agent(
52
  role='مستشار قضائي إماراتي',
53
  goal='تقديم الاستشارات والتوجيه القانوني المتخصص في القانون الإماراتي',
 
58
  """,
59
  verbose=True,
60
  allow_delegation=False,
61
+ llm_config=get_base_llm_config(),
62
  tools=create_uae_legal_tools()
63
  )