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.
Files changed (23) hide show
  1. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/PKG-INFO +1 -1
  2. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/initialize.py +47 -8
  3. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/PKG-INFO +1 -1
  4. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/setup.py +1 -1
  5. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/LICENSE +0 -0
  6. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/README.md +0 -0
  7. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/TeLLMgramBot.py +0 -0
  8. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/__init__.py +0 -0
  9. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/conversation.py +0 -0
  10. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/message_handlers.py +0 -0
  11. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/__init__.py +0 -0
  12. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/anthropic_provider.py +0 -0
  13. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/base.py +0 -0
  14. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/factory.py +0 -0
  15. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/providers/openai_provider.py +0 -0
  16. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/tokenGPT.py +0 -0
  17. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/utils.py +0 -0
  18. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot/web_utils.py +0 -0
  19. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/SOURCES.txt +0 -0
  20. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/dependency_links.txt +0 -0
  21. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/requires.txt +0 -0
  22. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/TeLLMgramBot.egg-info/top_level.txt +0 -0
  23. {tellmgrambot-2.4.1 → tellmgrambot-2.4.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TeLLMgramBot
3
- Version: 2.4.1
3
+ Version: 2.4.2
4
4
  Summary: LLM-powered Telegram bot (OpenAI + Anthropic)
5
5
  Home-page: https://github.com/Digital-Heresy/TeLLMgramBot
6
6
  Author: Digital Heresy
@@ -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 (currently required at startup regardless of configured model; Phase 3 will make this conditional)
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
- The Anthropic key (TELLMGRAMBOT_ANTHROPIC_API_KEY) is read directly by
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"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TeLLMgramBot
3
- Version: 2.4.1
3
+ Version: 2.4.2
4
4
  Summary: LLM-powered Telegram bot (OpenAI + Anthropic)
5
5
  Home-page: https://github.com/Digital-Heresy/TeLLMgramBot
6
6
  Author: Digital Heresy
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
5
5
 
6
6
  setup(
7
7
  name='TeLLMgramBot',
8
- version='2.4.1',
8
+ version='2.4.2',
9
9
  packages=find_packages(),
10
10
  license='MIT',
11
11
  author='Digital Heresy',
File without changes
File without changes
File without changes