-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
190 lines (151 loc) · 6.17 KB
/
Copy pathconfig.py
File metadata and controls
190 lines (151 loc) · 6.17 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
"""
Sidekick AI — Application Configuration
All settings are loaded from environment variables / .env file.
No secrets are hardcoded here.
"""
from typing import Optional
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
# ------------------------------------------------------------------ #
# Project
# ------------------------------------------------------------------ #
PROJECT_NAME: str = "Sidekick AI"
VERSION: str = "1.0.0"
DESCRIPTION: str = (
"An AI-powered executive assistant that prioritises messages, "
"generates smart replies, remembers context, and helps users "
"stay organised across Gmail, Calendar, WhatsApp, X and more."
)
DEBUG: bool = False
# ------------------------------------------------------------------ #
# Server
# ------------------------------------------------------------------ #
HOST: str = "0.0.0.0"
PORT: int = 8000
# ------------------------------------------------------------------ #
# Security / JWT
# ------------------------------------------------------------------ #
SECRET_KEY: str
JWT_ALGORITHM: str = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES: int = 15
REFRESH_TOKEN_EXPIRE_DAYS: int = 30
COOKIE_SECURE: bool = True
COOKIE_SAMESITE: str = "none"
COOKIE_DOMAIN: Optional[str] = None
# ------------------------------------------------------------------ #
# Database
# ------------------------------------------------------------------ #
DATABASE_URL: str = "sqlite:///./sidekick.db"
# ------------------------------------------------------------------ #
# LLM Configuration
#
# Supported providers:
# - ollama
# - openrouter
#
# The provider can later be overridden by a user's request/config.
# ------------------------------------------------------------------ #
# Default provider
LLM_PROVIDER: str = "openrouter"
# ------------------------------------------------------------------ #
# Ollama
# ------------------------------------------------------------------ #
# Default local Ollama server.
OLLAMA_BASE_URL: str = "http://localhost:11434"
# Default Ollama model.
OLLAMA_MODEL: str = "llama3.2"
# ------------------------------------------------------------------ #
# OpenRouter
# ------------------------------------------------------------------ #
OPENROUTER_API_KEY: Optional[str] = None
OPENROUTER_BASE_URL: str = (
"https://openrouter.ai/api/v1"
)
# Default model.
# This can later be overridden by the user's selected model.
OPENROUTER_MODEL: str = "openrouter/free"
OPENROUTER_TIMEOUT: float = 60.0
OPENROUTER_TEMPERATURE: float = 0.4
OPENROUTER_MAX_TOKENS: int = 2048
# OpenRouter optional metadata
HTTP_REFERER: str = "https://sidekick.ai"
APP_TITLE: str = "Sidekick AI"
# ------------------------------------------------------------------ #
# Background Ingestion Poller
# ------------------------------------------------------------------ #
POLLER_INTERVAL_SECONDS: int = 3600
POLLER_ENABLED: bool = False
# ------------------------------------------------------------------ #
# Google OAuth
# ------------------------------------------------------------------ #
GOOGLE_CLIENT_ID: str
GOOGLE_CLIENT_SECRET: str
GOOGLE_REDIRECT_URI: str = (
"http://localhost:8000/api/v1/gmail/callback"
)
# ------------------------------------------------------------------ #
# Slack OAuth
# ------------------------------------------------------------------ #
SLACK_CLIENT_ID: str = ""
SLACK_CLIENT_SECRET: str = ""
SLACK_REDIRECT_URI: str = (
"https://sidekickai-1.onrender.com/api/v1/slack/callback"
)
# ------------------------------------------------------------------ #
# Twitter / X OAuth 2.0
# ------------------------------------------------------------------ #
TWITTER_CLIENT_ID: str = ""
TWITTER_CLIENT_SECRET: str = ""
TWITTER_REDIRECT_URI: str = (
"http://localhost:8000/api/v1/twitter/callback"
)
TWITTER_APP_SECRET: str = ""
# ------------------------------------------------------------------ #
# Twitter / X Legacy
# ------------------------------------------------------------------ #
TWITTER_API_KEY: str = ""
TWITTER_API_SECRET: str = ""
TWITTER_BEARER_TOKEN: str = ""
TWITTER_ACCESS_TOKEN: str = ""
TWITTER_ACCESS_SECRET: str = ""
TWITTER_USER_ID: str = ""
# ------------------------------------------------------------------ #
# Telegram
# ------------------------------------------------------------------ #
TELEGRAM_API_ID: int = 123456
TELEGRAM_API_HASH: str = "mock_api_hash_value"
TELEGRAM_SESSION_ENCRYPTION_KEY: str = ""
ALLOWED_ORIGINS: list[str] = [
"http://localhost:3000",
"http://localhost:8000",
"http://127.0.0.1:3000",
"http://127.0.0.1:8000",
"https://sidekickai.onrender.com",
"https://sidekickai-1.onrender.com",
"*",
]
from pydantic import model_validator
@model_validator(mode="after")
def validate_and_adjust_settings(self) -> "Settings":
if self.DATABASE_URL and self.DATABASE_URL.startswith("postgres://"):
self.DATABASE_URL = self.DATABASE_URL.replace("postgres://", "postgresql://", 1)
# Relax cookie security parameters for local development on HTTP
if self.DEBUG:
if self.COOKIE_SECURE:
self.COOKIE_SECURE = False
if self.COOKIE_SAMESITE == "none":
self.COOKIE_SAMESITE = "lax"
# Clean empty domain configurations to None
if not self.COOKIE_DOMAIN:
self.COOKIE_DOMAIN = None
return self
# ------------------------------------------------------------------ #
# Pydantic config
# ------------------------------------------------------------------ #
model_config = SettingsConfigDict(
env_file=".env",
env_file_encoding="utf-8",
case_sensitive=True,
extra="ignore",
)
settings = Settings()