Spaces:
Sleeping
Sleeping
| import os | |
| from dataclasses import dataclass | |
| class Settings: | |
| """Global configuration for the agentic multiwriter system.""" | |
| # ollama | openai | hf_endpoint | |
| llm_provider: str = os.getenv("AMW_LLM_PROVIDER", "ollama").lower() | |
| llm_model: str = os.getenv("AMW_LLM_MODEL", "llama3") | |
| temperature: float = float(os.getenv("AMW_TEMPERATURE", "0.4")) | |
| max_search_results: int = int(os.getenv("AMW_MAX_SEARCH_RESULTS", "8")) | |
| def validate(self) -> None: | |
| allowed = {"ollama", "openai", "hf_endpoint"} | |
| if self.llm_provider not in allowed: | |
| raise ValueError( | |
| f"Unsupported LLM provider '{self.llm_provider}'. " | |
| f"Use one of: {', '.join(sorted(allowed))}." | |
| ) | |
| if self.llm_provider == "openai" and not os.getenv("OPENAI_API_KEY"): | |
| raise ValueError( | |
| "OPENAI_API_KEY is required when AMW_LLM_PROVIDER is 'openai'." | |
| ) | |
| if self.llm_provider == "hf_endpoint" and not os.getenv( | |
| "HUGGINGFACEHUB_API_TOKEN" | |
| ): | |
| raise ValueError( | |
| "HUGGINGFACEHUB_API_TOKEN is required when " | |
| "AMW_LLM_PROVIDER is 'hf_endpoint'." | |
| ) | |
| settings = Settings() | |