-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
64 lines (52 loc) · 2.1 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# config.py
import os
from dotenv import load_dotenv
from typing import Optional
# Load environment variables from .env file
load_dotenv()
class Config:
# Supabase
SUPABASE_URL = os.getenv('SUPABASE_URL')
SUPABASE_KEY = os.getenv('SUPABASE_KEY')
# Twitter
TWITTER_CONSUMER_KEY = os.getenv('TWITTER_CONSUMER_KEY')
TWITTER_CONSUMER_SECRET = os.getenv('TWITTER_CONSUMER_SECRET')
TWITTER_ACCESS_TOKEN = os.getenv('TWITTER_ACCESS_TOKEN')
TWITTER_ACCESS_TOKEN_SECRET = os.getenv('TWITTER_ACCESS_TOKEN_SECRET')
# LLM Providers
OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
ANTHROPIC_API_KEY = os.getenv('ANTHROPIC_API_KEY')
# Application settings
TABLE_NAME = 'papers'
BOT_NAME = 'AI Agent [Alpha Testing]'
TEMPLATE_PATH = 'prompts/system_en.prompt'
SLEEP_TIME = 43200 # 12 hours in seconds
# Default LLM provider
# DEFAULT_LLM_PROVIDER = 'anthropic'
# MODEL = 'claude-3-5-sonnet-20240620'
DEFAULT_LLM_PROVIDER = 'openai'
MODEL = 'gpt-4o'
@classmethod
def get_llm_api_key(cls, provider: Optional[str] = None) -> str:
provider = provider or cls.DEFAULT_LLM_PROVIDER
if provider == 'openai':
return cls.OPENAI_API_KEY
elif provider == 'anthropic':
return cls.ANTHROPIC_API_KEY
else:
raise ValueError(f"Unsupported LLM provider: {provider}")
@classmethod
def validate(cls):
required_vars = [
'SUPABASE_URL', 'SUPABASE_KEY',
'TWITTER_CONSUMER_KEY', 'TWITTER_CONSUMER_SECRET',
'TWITTER_ACCESS_TOKEN', 'TWITTER_ACCESS_TOKEN_SECRET',
]
# Check if at least one LLM provider key is set
if not (cls.OPENAI_API_KEY or cls.ANTHROPIC_API_KEY):
raise ValueError("At least one LLM provider API key (OPENAI_API_KEY or ANTHROPIC_API_KEY) must be set")
missing = [var for var in required_vars if not getattr(cls, var)]
if missing:
raise ValueError(f"Missing required environment variables: {', '.join(missing)}")
# Validate configuration on import
Config.validate()