LegalAI-DS / config.py
Hassankhwileh's picture
Update config.py
8fdbdd0 verified
raw
history blame
2.03 kB
import os
from dotenv import load_dotenv
from typing import Dict, Any
# Load environment variables from .env file
load_dotenv()
# Groq API Key (prefer loading from environment variables for security)
GROQ_API_KEY = os.getenv("GROQ_API_KEY", "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")
# AI Provider Configuration
AI_PROVIDER = "groq" # We're now using Groq exclusively
AI_MODEL = os.getenv("AI_MODEL", "deepseek-ai/deepseek-r1-distill-llama-70b") # Default model
AI_API_KEY = GROQ_API_KEY # Use the Groq API key
# Model Settings (Groq-specific settings)
MODEL_SETTINGS = {
"max_tokens": 4000, # Maximum tokens for the response
"temperature": 0.7, # Controls randomness (0.0 = deterministic, 1.0 = creative)
"top_p": 1.0, # Controls diversity via nucleus sampling
"frequency_penalty": 0.0, # Penalizes repeated tokens
"presence_penalty": 0.0, # Penalizes new tokens
}
# Language Settings
DEFAULT_LANGUAGE = 'ar' # Arabic by default
SUPPORTED_LANGUAGES = ['ar', 'en'] # Supported languages for the application
# UAE Legal Resources (Domains for legal research)
UAE_LEGAL_DOMAINS = [
'https://elaws.moj.gov.ae',
'https://www.mohre.gov.ae',
'https://www.dm.gov.ae',
'https://www.adjd.gov.ae',
'https://www.dc.gov.ae'
]
# Legal Categories (Mapping of legal categories to their Arabic names)
LEGAL_CATEGORIES = {
'civil': 'ุงู„ู‚ุงู†ูˆู† ุงู„ู…ุฏู†ูŠ',
'criminal': 'ุงู„ู‚ุงู†ูˆู† ุงู„ุฌู†ุงุฆูŠ',
'commercial': 'ุงู„ู‚ุงู†ูˆู† ุงู„ุชุฌุงุฑูŠ',
'labor': 'ู‚ุงู†ูˆู† ุงู„ุนู…ู„',
'family': 'ู‚ุงู†ูˆู† ุงู„ุฃุณุฑุฉ',
'property': 'ู‚ุงู†ูˆู† ุงู„ุนู‚ุงุฑุงุช'
}
def get_ai_config() -> Dict[str, Any]:
"""
Get AI configuration based on environment variables.
Returns a dictionary containing the provider, model, API key, and model settings.
"""
return {
"provider": AI_PROVIDER,
"model": AI_MODEL,
"api_key": AI_API_KEY,
**MODEL_SETTINGS # Include all model settings in the config
}