sigma-terminal 2.0.2__py3-none-any.whl → 3.2.0__py3-none-any.whl

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.
sigma/config.py ADDED
@@ -0,0 +1,195 @@
1
+ """Configuration management for Sigma v3.2.0."""
2
+
3
+ import os
4
+ from enum import Enum
5
+ from pathlib import Path
6
+ from typing import Optional
7
+
8
+ from pydantic import Field
9
+ from pydantic_settings import BaseSettings
10
+
11
+
12
+ __version__ = "3.2.0"
13
+
14
+
15
+ class LLMProvider(str, Enum):
16
+ """Supported LLM providers."""
17
+ GOOGLE = "google"
18
+ OPENAI = "openai"
19
+ ANTHROPIC = "anthropic"
20
+ GROQ = "groq"
21
+ XAI = "xai"
22
+ OLLAMA = "ollama"
23
+
24
+
25
+ # Available models per provider
26
+ AVAILABLE_MODELS = {
27
+ "google": ["gemini-2.0-flash", "gemini-1.5-flash", "gemini-1.5-pro"],
28
+ "openai": ["gpt-4o", "gpt-4o-mini", "gpt-4-turbo", "o1-preview", "o1-mini"],
29
+ "anthropic": ["claude-sonnet-4-20250514", "claude-3-5-sonnet-20241022", "claude-3-opus-20240229"],
30
+ "groq": ["llama-3.3-70b-versatile", "llama-3.1-8b-instant", "mixtral-8x7b-32768"],
31
+ "xai": ["grok-2", "grok-2-mini"],
32
+ "ollama": ["llama3.2", "llama3.1", "mistral", "codellama", "phi3"],
33
+ }
34
+
35
+ # Config directory
36
+ CONFIG_DIR = Path.home() / ".sigma"
37
+ CONFIG_FILE = CONFIG_DIR / "config.env"
38
+
39
+
40
+ class Settings(BaseSettings):
41
+ """Application settings."""
42
+
43
+ # Provider settings
44
+ default_provider: LLMProvider = LLMProvider.GOOGLE
45
+ default_model: str = Field(default="gemini-2.0-flash", alias="DEFAULT_MODEL")
46
+
47
+ # API Keys
48
+ google_api_key: Optional[str] = Field(default=None, alias="GOOGLE_API_KEY")
49
+ openai_api_key: Optional[str] = Field(default=None, alias="OPENAI_API_KEY")
50
+ anthropic_api_key: Optional[str] = Field(default=None, alias="ANTHROPIC_API_KEY")
51
+ groq_api_key: Optional[str] = Field(default=None, alias="GROQ_API_KEY")
52
+ xai_api_key: Optional[str] = Field(default=None, alias="XAI_API_KEY")
53
+
54
+ # Model settings
55
+ google_model: str = "gemini-2.0-flash"
56
+ openai_model: str = "gpt-4o"
57
+ anthropic_model: str = "claude-sonnet-4-20250514"
58
+ groq_model: str = "llama-3.3-70b-versatile"
59
+ xai_model: str = "grok-2"
60
+ ollama_model: str = "llama3.2"
61
+
62
+ # Ollama settings
63
+ ollama_host: str = "http://localhost:11434"
64
+
65
+ # Data API keys
66
+ alpha_vantage_api_key: str = "6ER128DD3NQUPTVC" # Built-in free key
67
+ exa_api_key: Optional[str] = None
68
+
69
+ class Config:
70
+ env_file = str(CONFIG_FILE)
71
+ env_file_encoding = "utf-8"
72
+ extra = "ignore"
73
+
74
+ def get_api_key(self, provider: LLMProvider) -> Optional[str]:
75
+ """Get API key for a provider."""
76
+ key_map = {
77
+ LLMProvider.GOOGLE: self.google_api_key,
78
+ LLMProvider.OPENAI: self.openai_api_key,
79
+ LLMProvider.ANTHROPIC: self.anthropic_api_key,
80
+ LLMProvider.GROQ: self.groq_api_key,
81
+ LLMProvider.XAI: self.xai_api_key,
82
+ LLMProvider.OLLAMA: None, # No key needed
83
+ }
84
+ return key_map.get(provider)
85
+
86
+ def get_model(self, provider: LLMProvider) -> str:
87
+ """Get model for a provider."""
88
+ model_map = {
89
+ LLMProvider.GOOGLE: self.google_model,
90
+ LLMProvider.OPENAI: self.openai_model,
91
+ LLMProvider.ANTHROPIC: self.anthropic_model,
92
+ LLMProvider.GROQ: self.groq_model,
93
+ LLMProvider.XAI: self.xai_model,
94
+ LLMProvider.OLLAMA: self.ollama_model,
95
+ }
96
+ return model_map.get(provider, "")
97
+
98
+ def get_available_providers(self) -> list[LLMProvider]:
99
+ """Get list of providers with configured API keys."""
100
+ available = []
101
+ for provider in LLMProvider:
102
+ if provider == LLMProvider.OLLAMA:
103
+ available.append(provider) # Always available
104
+ elif self.get_api_key(provider):
105
+ available.append(provider)
106
+ return available
107
+
108
+ def is_configured(self) -> bool:
109
+ """Check if at least one provider is configured."""
110
+ return len(self.get_available_providers()) > 0
111
+
112
+
113
+ def get_settings() -> Settings:
114
+ """Get application settings."""
115
+ # Ensure config directory exists
116
+ CONFIG_DIR.mkdir(parents=True, exist_ok=True)
117
+
118
+ # Load from environment and config file
119
+ return Settings()
120
+
121
+
122
+ def save_api_key(provider: str, key: str) -> None:
123
+ """Save an API key to the config file."""
124
+ CONFIG_DIR.mkdir(parents=True, exist_ok=True)
125
+
126
+ # Read existing config
127
+ config = {}
128
+ if CONFIG_FILE.exists():
129
+ with open(CONFIG_FILE) as f:
130
+ for line in f:
131
+ line = line.strip()
132
+ if "=" in line and not line.startswith("#"):
133
+ k, v = line.split("=", 1)
134
+ config[k] = v
135
+
136
+ # Update key
137
+ key_map = {
138
+ "google": "GOOGLE_API_KEY",
139
+ "openai": "OPENAI_API_KEY",
140
+ "anthropic": "ANTHROPIC_API_KEY",
141
+ "groq": "GROQ_API_KEY",
142
+ "xai": "XAI_API_KEY",
143
+ }
144
+
145
+ env_key = key_map.get(provider.lower())
146
+ if env_key:
147
+ config[env_key] = key
148
+
149
+ # Write back
150
+ with open(CONFIG_FILE, "w") as f:
151
+ f.write("# Sigma Configuration\n\n")
152
+ for k, v in sorted(config.items()):
153
+ f.write(f"{k}={v}\n")
154
+
155
+
156
+ def get_api_key(provider: str) -> Optional[str]:
157
+ """Get API key for a provider."""
158
+ settings = get_settings()
159
+ try:
160
+ return settings.get_api_key(LLMProvider(provider.lower()))
161
+ except ValueError:
162
+ return None
163
+
164
+
165
+ def save_setting(key: str, value: str) -> None:
166
+ """Save a setting to the config file."""
167
+ CONFIG_DIR.mkdir(parents=True, exist_ok=True)
168
+
169
+ # Read existing config
170
+ config = {}
171
+ if CONFIG_FILE.exists():
172
+ with open(CONFIG_FILE) as f:
173
+ for line in f:
174
+ line = line.strip()
175
+ if "=" in line and not line.startswith("#"):
176
+ k, v = line.split("=", 1)
177
+ config[k] = v
178
+
179
+ # Map setting name to config key
180
+ setting_map = {
181
+ "default_provider": "DEFAULT_PROVIDER",
182
+ "default_model": "DEFAULT_MODEL",
183
+ "output_dir": "OUTPUT_DIR",
184
+ "cache_enabled": "CACHE_ENABLED",
185
+ "lean_cli_path": "LEAN_CLI_PATH",
186
+ }
187
+
188
+ config_key = setting_map.get(key, key.upper())
189
+ config[config_key] = str(value)
190
+
191
+ # Write back
192
+ with open(CONFIG_FILE, "w") as f:
193
+ f.write("# Sigma Configuration\n\n")
194
+ for k, v in sorted(config.items()):
195
+ f.write(f"{k}={v}\n")
sigma/core/__init__.py CHANGED
@@ -1,18 +1,5 @@
1
- """Core module initialization."""
1
+ """Core infrastructure for Sigma Financial Intelligence Platform."""
2
2
 
3
- from sigma.core.agent import SigmaAgent
4
- from sigma.core.config import LLMProvider, Settings, get_settings
5
- from sigma.core.llm import get_llm
6
- from sigma.core.models import Message, MessageRole, ToolCall, ToolResult
7
-
8
- __all__ = [
9
- "SigmaAgent",
10
- "LLMProvider",
11
- "Settings",
12
- "get_settings",
13
- "get_llm",
14
- "Message",
15
- "MessageRole",
16
- "ToolCall",
17
- "ToolResult",
18
- ]
3
+ from .models import *
4
+ from .intent import *
5
+ from .engine import *