-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
148 lines (117 loc) · 4.55 KB
/
config.py
File metadata and controls
148 lines (117 loc) · 4.55 KB
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Copyright (c) 2010-2025 Evolveum and contributors
#
# Licensed under the EUPL-1.2 or later.
from enum import Enum
from typing import Any, Dict, Optional
from pydantic import BaseModel, Field
from pydantic_settings import BaseSettings, SettingsConfigDict
class LogLevel(str, Enum):
"""
Log level settings for the application.
:cvar debug: Debug-level logging, most verbose.
:cvar info: Informational messages, default level.
:cvar warning: Warning messages, potential issues.
:cvar error: Error messages, serious problems.
:cvar critical: Critical errors, application shutdown scenarios.
"""
debug = "debug"
info = "info"
warning = "warning"
error = "error"
critical = "critical"
class LoggingSettings(BaseModel):
"""
Configuration for application logging.
:param level: LogLevel enum specifying the logging threshold.
:param access_log: Enable or disable access logs.
:param colors: Enable or disable colored log output.
:param live_reload: Enable live reloading of logs on code changes.
"""
level: LogLevel = LogLevel.info
access_log: bool = True
colors: bool = False
live_reload: bool = False
class LLMSettings(BaseModel):
"""
Configuration for the LLM client.
:param openai_api_key: API key for OpenAI-compatible services.
:param openai_api_base: Base URL for the API endpoint.
:param model_name: Default model identifier to use.
:param request_timeout: Timeout for API requests in seconds.
:param extra_body: Extra body used for provider-specific requests.
"""
openai_api_key: str = ""
openai_api_base: str = "https://openrouter.ai/api/v1"
model_name: str = "openai/gpt-oss-20b"
request_timeout: int = 90
# extra_body is used for provider-specific requests
extra_body: Dict[str, Any] = Field(
default_factory=lambda: {
"provider": {"order": ["groq", "parasail", "deepinfra"]},
}
)
class LangfuseSettings(BaseModel):
"""
Configuration for the Langfuse client.
:param public_key: Public Langfuse host key.
:param secret_key: Secret Langfuse host key.
:param host: Langfuse host.
:param tracing_enabled: Enable/disable langfuse tracing.
:param environment: Environment name e.g. demo, dev-myname.
"""
public_key: str = "emptykey"
secret_key: str = "emptykey"
host: str = ""
tracing_enabled: bool = False
environment: str = "dev-whoami"
class AppSettings(BaseModel):
"""
Core application settings for the API service.
:param title: API title shown in docs.
:param version: API version string.
:param description: API description displayed in docs.
:param api_base_url: Base path for all routes.
:param host: Host address for Uvicorn server.
:param port: Port number for Uvicorn server.
:param live_reload: Enable Uvicorn live reload on changes.
:param workers: Number of worker processes.
:param proxy_headers: Trust proxy headers.
:param forwarded_allow_ips: IPs allowed to be forwarded.
:param root_path: Root path for mounting.
:param timeout_keep_alive: Keep-alive timeout for connections.
:param timeout_graceful_shutdown: Graceful shutdown timeout.
:param limit_concurrency: Optional limit on concurrent requests.
:param limit_max_requests: Optional max requests per worker.
:param ssl_certfile: Optional path to SSL certificate file.
:param ssl_keyfile: Optional path to SSL key file.
"""
title: str = "Smart Integration Microservice"
version: str = "0.1.0"
git_commit: str = ""
description: str = "Smart Integration Microservice for schema matching and mapping"
api_base_url: str = "/api/v1"
host: str = "0.0.0.0"
port: int = 8090
live_reload: bool = False
workers: int = 1
proxy_headers: bool = True
forwarded_allow_ips: str = "*"
root_path: str = ""
timeout_keep_alive: int = 10
timeout_graceful_shutdown: int = 15
limit_concurrency: Optional[int] = None
limit_max_requests: Optional[int] = None
ssl_certfile: Optional[str] = None
ssl_keyfile: Optional[str] = None
class Settings(BaseSettings):
"""
Application settings loaded from environment or defaults.
Uses nested environment variables with '__' delimiter.
Example: LOGGING__LEVEL=error
"""
model_config = SettingsConfigDict(env_nested_delimiter="__")
app: AppSettings = AppSettings()
logging: LoggingSettings = LoggingSettings()
llm: LLMSettings = LLMSettings()
langfuse: LangfuseSettings = LangfuseSettings()
config = Settings()