Hassankhwileh commited on
Commit
8fdbdd0
ยท
verified ยท
1 Parent(s): 07260fb

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +19 -15
config.py CHANGED
@@ -1,29 +1,32 @@
1
- # config.py
2
-
3
  import os
4
  from dotenv import load_dotenv
5
  from typing import Dict, Any
6
 
 
7
  load_dotenv()
8
- GROQ_API_KEY="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"
 
 
9
 
10
  # AI Provider Configuration
11
  AI_PROVIDER = "groq" # We're now using Groq exclusively
12
  AI_MODEL = os.getenv("AI_MODEL", "deepseek-ai/deepseek-r1-distill-llama-70b") # Default model
13
- AI_API_KEY = GROQ_API_KEY
14
 
15
- # Model Settings
16
  MODEL_SETTINGS = {
17
- "max_tokens": 4000,
18
- "temperature": 0.7,
19
- "top_p": 1.0
 
 
20
  }
21
 
22
  # Language Settings
23
  DEFAULT_LANGUAGE = 'ar' # Arabic by default
24
- SUPPORTED_LANGUAGES = ['ar', 'en']
25
 
26
- # UAE Legal Resources
27
  UAE_LEGAL_DOMAINS = [
28
  'https://elaws.moj.gov.ae',
29
  'https://www.mohre.gov.ae',
@@ -32,7 +35,7 @@ UAE_LEGAL_DOMAINS = [
32
  'https://www.dc.gov.ae'
33
  ]
34
 
35
- # Legal Categories
36
  LEGAL_CATEGORIES = {
37
  'civil': 'ุงู„ู‚ุงู†ูˆู† ุงู„ู…ุฏู†ูŠ',
38
  'criminal': 'ุงู„ู‚ุงู†ูˆู† ุงู„ุฌู†ุงุฆูŠ',
@@ -43,12 +46,13 @@ LEGAL_CATEGORIES = {
43
  }
44
 
45
  def get_ai_config() -> Dict[str, Any]:
46
- """Get AI configuration based on environment variables"""
 
 
 
47
  return {
48
  "provider": AI_PROVIDER,
49
  "model": AI_MODEL,
50
  "api_key": AI_API_KEY,
51
- "temperature": MODEL_SETTINGS["temperature"],
52
- "max_tokens": MODEL_SETTINGS["max_tokens"],
53
- "top_p": MODEL_SETTINGS["top_p"]
54
  }
 
 
 
1
  import os
2
  from dotenv import load_dotenv
3
  from typing import Dict, Any
4
 
5
+ # Load environment variables from .env file
6
  load_dotenv()
7
+
8
+ # Groq API Key (prefer loading from environment variables for security)
9
+ GROQ_API_KEY = os.getenv("GROQ_API_KEY", "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")
10
 
11
  # AI Provider Configuration
12
  AI_PROVIDER = "groq" # We're now using Groq exclusively
13
  AI_MODEL = os.getenv("AI_MODEL", "deepseek-ai/deepseek-r1-distill-llama-70b") # Default model
14
+ AI_API_KEY = GROQ_API_KEY # Use the Groq API key
15
 
16
+ # Model Settings (Groq-specific settings)
17
  MODEL_SETTINGS = {
18
+ "max_tokens": 4000, # Maximum tokens for the response
19
+ "temperature": 0.7, # Controls randomness (0.0 = deterministic, 1.0 = creative)
20
+ "top_p": 1.0, # Controls diversity via nucleus sampling
21
+ "frequency_penalty": 0.0, # Penalizes repeated tokens
22
+ "presence_penalty": 0.0, # Penalizes new tokens
23
  }
24
 
25
  # Language Settings
26
  DEFAULT_LANGUAGE = 'ar' # Arabic by default
27
+ SUPPORTED_LANGUAGES = ['ar', 'en'] # Supported languages for the application
28
 
29
+ # UAE Legal Resources (Domains for legal research)
30
  UAE_LEGAL_DOMAINS = [
31
  'https://elaws.moj.gov.ae',
32
  'https://www.mohre.gov.ae',
 
35
  'https://www.dc.gov.ae'
36
  ]
37
 
38
+ # Legal Categories (Mapping of legal categories to their Arabic names)
39
  LEGAL_CATEGORIES = {
40
  'civil': 'ุงู„ู‚ุงู†ูˆู† ุงู„ู…ุฏู†ูŠ',
41
  'criminal': 'ุงู„ู‚ุงู†ูˆู† ุงู„ุฌู†ุงุฆูŠ',
 
46
  }
47
 
48
  def get_ai_config() -> Dict[str, Any]:
49
+ """
50
+ Get AI configuration based on environment variables.
51
+ Returns a dictionary containing the provider, model, API key, and model settings.
52
+ """
53
  return {
54
  "provider": AI_PROVIDER,
55
  "model": AI_MODEL,
56
  "api_key": AI_API_KEY,
57
+ **MODEL_SETTINGS # Include all model settings in the config
 
 
58
  }