Spaces:
Running
Running
File size: 841 Bytes
6a71f13 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import os
from dotenv import load_dotenv
from typing import Literal
class LLMSettings:
def __init__(self):
load_dotenv()
self.openai_api_key = os.getenv('OPENAI_API_KEY')
self.anthropic_api_key = os.getenv('ANTHROPIC_API_KEY')
self.default_llm = os.getenv('DEFAULT_LLM', 'claude')
# API キーの存在確認
if not self.openai_api_key and not self.anthropic_api_key:
raise ValueError("少なくとも1つのAPIキーが必要です。")
def get_available_models(self) -> list[Literal['claude', 'gpt']]:
"""利用可能なモデルのリストを返す"""
models = []
if self.anthropic_api_key:
models.append('claude')
if self.openai_api_key:
models.append('gpt')
return models |