44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""
|
|
Configuration management for the multi-agent workflow.
|
|
"""
|
|
import os
|
|
from dotenv import load_dotenv
|
|
from typing import Optional
|
|
|
|
# Load environment variables from .env file
|
|
load_dotenv()
|
|
|
|
class Config:
|
|
"""Configuration class for managing API keys and settings."""
|
|
|
|
def __init__(self):
|
|
self.perplexity_api_key = os.getenv("PERPLEXITY_API_KEY")
|
|
self.openai_api_key = os.getenv("OPENAI_API_KEY")
|
|
|
|
# Validate required API keys
|
|
self._validate_config()
|
|
|
|
def _validate_config(self):
|
|
"""Validate that required API keys are present."""
|
|
missing_keys = []
|
|
|
|
if not self.perplexity_api_key and not self.openai_api_key:
|
|
print("Warning: No LLM API key found (PERPLEXITY_API_KEY or OPENAI_API_KEY)")
|
|
missing_keys.append("PERPLEXITY_API_KEY or OPENAI_API_KEY")
|
|
|
|
if missing_keys:
|
|
print(f"Please set the following environment variables: {', '.join(missing_keys)}")
|
|
return False
|
|
|
|
return True
|
|
|
|
@property
|
|
def llm_model(self) -> str:
|
|
"""Return the preferred LLM model."""
|
|
return "gpt-3.5-turbo" if self.openai_api_key else "llama-2-70b-chat"
|
|
|
|
@property
|
|
def llm_api_key(self) -> Optional[str]:
|
|
"""Return the preferred LLM API key."""
|
|
return self.perplexity_api_key or self.openai_api_key
|