TeLLMgramBot 2.4.1__tar.gz → 2.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/PKG-INFO +1 -1
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/initialize.py +47 -8
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/PKG-INFO +1 -1
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/setup.py +1 -1
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/LICENSE +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/README.md +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/TeLLMgramBot.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/__init__.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/conversation.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/message_handlers.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/__init__.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/anthropic_provider.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/base.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/factory.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/openai_provider.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/tokenGPT.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/utils.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/web_utils.py +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/SOURCES.txt +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/dependency_links.txt +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/requires.txt +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/top_level.txt +0 -0
- {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/setup.cfg +0 -0
|
@@ -4,9 +4,9 @@ import sys
|
|
|
4
4
|
|
|
5
5
|
# Handle relative modules if running this script vs. elsewhere
|
|
6
6
|
try:
|
|
7
|
-
from .utils import read_text, generate_file_path
|
|
7
|
+
from .utils import read_text, generate_file_path, read_yaml
|
|
8
8
|
except ImportError:
|
|
9
|
-
from utils import read_text, generate_file_path
|
|
9
|
+
from utils import read_text, generate_file_path, read_yaml
|
|
10
10
|
|
|
11
11
|
INIT_BOT_CONFIG = {
|
|
12
12
|
'bot_owner': '<YOUR USERNAME>',
|
|
@@ -48,28 +48,67 @@ def init_directories():
|
|
|
48
48
|
except Exception as e:
|
|
49
49
|
sys.exit(f"{type(e).__name__} on {env_var} directory '{os.environ[env_var]}': {e}\nExiting...")
|
|
50
50
|
|
|
51
|
+
def _requires_provider(config_path: str) -> dict:
|
|
52
|
+
"""
|
|
53
|
+
Read config.yaml and return which provider keys are required based on model prefixes.
|
|
54
|
+
|
|
55
|
+
Provider inference mirrors factory.py: models starting with 'claude-' require Anthropic,
|
|
56
|
+
all other non-empty models require OpenAI. If config.yaml is missing or unreadable,
|
|
57
|
+
both providers are marked as required to err on the side of caution.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
config_path: Path to config.yaml file.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
Dict with keys 'openai' and 'anthropic', each a bool indicating if that provider key is needed.
|
|
64
|
+
"""
|
|
65
|
+
needs = {'openai': False, 'anthropic': False}
|
|
66
|
+
try:
|
|
67
|
+
config = read_yaml(config_path) or {}
|
|
68
|
+
for field in ('chat_model', 'url_model'):
|
|
69
|
+
model = config.get(field, '')
|
|
70
|
+
if isinstance(model, str) and model.startswith('claude-'):
|
|
71
|
+
needs['anthropic'] = True
|
|
72
|
+
elif isinstance(model, str) and model:
|
|
73
|
+
needs['openai'] = True
|
|
74
|
+
except Exception:
|
|
75
|
+
# If config is missing or unreadable, require both providers to be safe
|
|
76
|
+
needs['openai'] = True
|
|
77
|
+
needs['anthropic'] = True
|
|
78
|
+
return needs
|
|
79
|
+
|
|
51
80
|
def init_keys():
|
|
52
81
|
"""
|
|
53
82
|
TeLLMgramBot utilizes the following API keys via environment variables:
|
|
54
|
-
- TELLMGRAMBOT_OPENAI_API_KEY (
|
|
83
|
+
- TELLMGRAMBOT_OPENAI_API_KEY (required only when chat_model or url_model starts with 'gpt-' or other non-claude prefix)
|
|
84
|
+
- TELLMGRAMBOT_ANTHROPIC_API_KEY (required only when chat_model or url_model starts with 'claude-')
|
|
55
85
|
- TELLMGRAMBOT_TELEGRAM_API_KEY (always required)
|
|
56
86
|
- TELLMGRAMBOT_VIRUSTOTAL_API_KEY (always required)
|
|
57
87
|
|
|
58
|
-
|
|
59
|
-
AnthropicProvider at call time and is required when using claude-* models.
|
|
60
|
-
Key file support (anthropic.key) is planned for Phase 3.
|
|
61
|
-
|
|
88
|
+
Provider requirement is inferred from the configured models in config.yaml.
|
|
62
89
|
If an environment variable is not set, its key file is read from the base execution
|
|
63
90
|
path or TELLMGRAMBOT_KEYS_PATH. If no file exists, a placeholder is created.
|
|
64
91
|
- openai.key
|
|
65
92
|
- telegram.key
|
|
66
93
|
- virustotal.key
|
|
94
|
+
- anthropic.key
|
|
67
95
|
"""
|
|
68
|
-
keys
|
|
96
|
+
# Determine which provider keys are needed based on configured models
|
|
97
|
+
config_path = os.path.join(os.environ.get('TELLMGRAMBOT_CONFIGS_PATH', execution_dir()), 'config.yaml')
|
|
98
|
+
provider_needs = _requires_provider(config_path)
|
|
99
|
+
|
|
100
|
+
# Build the ordered set of keys to check: provider keys first (conditional), then always-required keys
|
|
101
|
+
provider_keys = {
|
|
69
102
|
'openai': 'https://platform.openai.com/api-keys',
|
|
103
|
+
'anthropic': 'https://docs.anthropic.com/en/api/getting-started',
|
|
104
|
+
}
|
|
105
|
+
always_keys = {
|
|
70
106
|
'telegram': 'https://core.telegram.org/api',
|
|
71
107
|
'virustotal': 'https://developers.virustotal.com/reference/overview'
|
|
72
108
|
}
|
|
109
|
+
|
|
110
|
+
keys = {k: v for k, v in provider_keys.items() if provider_needs.get(k)} | always_keys
|
|
111
|
+
|
|
73
112
|
keys_need = 0
|
|
74
113
|
for key, url in keys.items():
|
|
75
114
|
env_var = f"TELLMGRAMBOT_{key.upper()}_API_KEY"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|