-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathdf_config.py
45 lines (39 loc) · 1.53 KB
/
df_config.py
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
from pydantic import BaseModel, validator, Field
from typing import Optional, List, Any, Dict, TypedDict
from pandasai.constants import DEFAULT_CHART_DIRECTORY
from ..middlewares.base import Middleware
from ..callbacks.base import BaseCallback
from ..llm import LLM, LangchainLLM
from ..exceptions import LLMNotFoundError
from ..helpers.viz_library_types.base import VisualizationLibrary
class LogServerConfig(TypedDict):
server_url: str
api_key: str
class Config(BaseModel):
save_logs: bool = True
verbose: bool = False
enforce_privacy: bool = False
enable_cache: bool = True
use_error_correction_framework: bool = True
use_advanced_reasoning_framework: bool = False
custom_prompts: Dict = Field(default_factory=dict)
custom_instructions: Optional[str] = None
open_charts: bool = True
save_charts: bool = False
save_charts_path: str = DEFAULT_CHART_DIRECTORY
custom_whitelisted_dependencies: List[str] = Field(default_factory=list)
max_retries: int = 3
middlewares: List[Middleware] = Field(default_factory=list)
callback: Optional[BaseCallback] = None
lazy_load_connector: bool = True
response_parser: Any = None
llm: Any = None
data_viz_library: Optional[VisualizationLibrary] = None
log_server: LogServerConfig = None
class Config:
arbitrary_types_allowed = True
@validator("llm")
def validate_llm(cls, llm):
if llm is None or not isinstance(llm, LLM or LangchainLLM):
raise LLMNotFoundError("LLM is required")
return llm