Hassankhwileh commited on
Commit
42cb866
ยท
verified ยท
1 Parent(s): 92b1cdc

Update config.py

Browse files
Files changed (1) hide show
  1. config.py +20 -25
config.py CHANGED
@@ -2,31 +2,23 @@ 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,7 +27,7 @@ UAE_LEGAL_DOMAINS = [
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,13 +38,16 @@ LEGAL_CATEGORIES = {
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
  }
 
2
  from dotenv import load_dotenv
3
  from typing import Dict, Any
4
 
 
5
  load_dotenv()
6
 
7
+ # Groq Configuration
8
+ GROQ_MODEL = os.getenv("GROQ_MODEL", "deepseek-ai/deepseek-r1-distill-llama-70b")
9
 
10
+ # Model Settings
 
 
 
 
 
11
  MODEL_SETTINGS = {
12
+ "max_tokens": 4000,
13
+ "temperature": 0.7,
14
+ "top_p": 1.0,
 
 
15
  }
16
 
17
  # Language Settings
18
  DEFAULT_LANGUAGE = 'ar' # Arabic by default
19
+ SUPPORTED_LANGUAGES = ['ar', 'en']
20
 
21
+ # UAE Legal Resources
22
  UAE_LEGAL_DOMAINS = [
23
  'https://elaws.moj.gov.ae',
24
  'https://www.mohre.gov.ae',
 
27
  'https://www.dc.gov.ae'
28
  ]
29
 
30
+ # Legal Categories
31
  LEGAL_CATEGORIES = {
32
  'civil': 'ุงู„ู‚ุงู†ูˆู† ุงู„ู…ุฏู†ูŠ',
33
  'criminal': 'ุงู„ู‚ุงู†ูˆู† ุงู„ุฌู†ุงุฆูŠ',
 
38
  }
39
 
40
  def get_ai_config() -> Dict[str, Any]:
41
+ """Get Groq configuration based on environment variables"""
42
+ api_key = os.getenv("GROQ_API_KEY")
43
+ if not api_key:
44
+ raise ValueError("GROQ_API_KEY must be set in environment variables")
45
+
46
  return {
47
+ "model": GROQ_MODEL,
48
+ "api_key": api_key,
49
+ "temperature": MODEL_SETTINGS["temperature"],
50
+ "max_tokens": MODEL_SETTINGS["max_tokens"],
51
+ "top_p": MODEL_SETTINGS["top_p"],
52
+ "llm_type": "groq"
53
  }