File size: 3,351 Bytes
20d5dab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"""
Configuration du projet AI Research Assistant.
Ce fichier contient les configurations par défaut qui peuvent être surchargées
par les variables d'environnement.
"""

from pydantic_settings import BaseSettings
from typing import Dict, Optional, List


class APIConfig(BaseSettings):
    """Configuration des clés API et des paramètres associés"""
    # LLM API (REQUIS)
    GROQ_API_KEY: str = ""
    
    # APIs de Recherche (Au moins une REQUISE)
    SERPER_API_KEY: str = ""
    TAVILY_API_KEY: str = ""
    BRAVE_API_KEY: str = ""
    
    # Configuration des modèles
    LLM_MODEL: str = "llama-3.1-8b-instant"
    LLM_TEMPERATURE: float = 0.1
    LLM_MAX_TOKENS: int = 4000
    EMBEDDING_MODEL: str = "all-MiniLM-L6-v2"
    
    # Limites de recherche
    MAX_SOURCES: int = 20
    MAX_SUMMARY_LENGTH: int = 500
    SEARCH_TIMEOUT: int = 30
    
    # Performance et sécurité
    API_RATE_LIMIT: int = 100
    MAX_CONCURRENT_REQUESTS: int = 10
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"
        extra = "ignore"


class DatabaseConfig(BaseSettings):
    """Configuration de la base de données"""
    DATABASE_URL: str = "sqlite:///data/research.db"
    CHROMA_PERSIST_DIRECTORY: str = "data/chroma"
    CHROMA_COLLECTION_NAME: str = "research_documents"
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"
        extra = "ignore"


class PathConfig(BaseSettings):
    """Configuration des chemins et répertoires"""
    DATA_DIR: str = "data"
    REPORTS_DIR: str = "data/reports"
    CACHE_DIR: str = "data/cache"
    LOGS_DIR: str = "logs"
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"
        extra = "ignore"


class FeatureConfig(BaseSettings):
    """Configuration des fonctionnalités"""
    ENABLE_CACHING: bool = True
    ENABLE_VECTOR_STORE: bool = True
    ENABLE_RATE_LIMITING: bool = True
    CACHE_TTL: int = 3600
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"
        extra = "ignore"


class LoggingConfig(BaseSettings):
    """Configuration du logging"""
    LOG_LEVEL: str = "INFO"
    ENABLE_FILE_LOGGING: bool = True
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"
        extra = "ignore"


class ExportConfig(BaseSettings):
    """Configuration d'export et rapports"""
    DEFAULT_EXPORT_FORMAT: str = "markdown"
    PDF_PAGE_SIZE: str = "A4"
    INCLUDE_CITATIONS: bool = True
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"
        extra = "ignore"


class DevelopmentConfig(BaseSettings):
    """Configuration de développement"""
    DEBUG: bool = False
    DEVELOPMENT_MODE: bool = False
    WORKER_THREADS: int = 4
    
    class Config:
        env_file = ".env"
        env_file_encoding = "utf-8"
        extra = "ignore"


# Instanciation des configurations
try:
    api_config = APIConfig()
    database_config = DatabaseConfig()
    path_config = PathConfig()
    feature_config = FeatureConfig()
    logging_config = LoggingConfig()
    export_config = ExportConfig()
    development_config = DevelopmentConfig()
except Exception as e:
    print(f"Erreur lors du chargement de la configuration: {e}")
    # Configuration par défaut en cas d'erreur
    api_config = None