-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy path__init__.py
More file actions
42 lines (34 loc) · 1.4 KB
/
__init__.py
File metadata and controls
42 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
from .anthropic import AnthropicLLM
from .base import LLM, Schema
from .gemini import GeminiLLM
from .groq import GroqLLM
from .openai import OpenAILLM
REGISTRY: dict[str, type[LLM]] = {
"anthropic": AnthropicLLM,
"gemini": GeminiLLM,
"groq": GroqLLM,
"openai": OpenAILLM,
}
def get_llm(name: str = "gemini") -> LLM:
if name not in REGISTRY:
raise ValueError(f"Unknown LLM: '{name}'. Available: {list(REGISTRY)}")
return REGISTRY[name]()
def get_answer_llm() -> LLM:
"""Return the LLM to use for RAG answer generation.
Configured via OMB_ANSWER_LLM (provider) and OMB_ANSWER_MODEL (optional model override)."""
provider = os.environ.get("OMB_ANSWER_LLM", "groq")
model = os.environ.get("OMB_ANSWER_MODEL")
cls = REGISTRY.get(provider)
if cls is None:
raise ValueError(f"Unknown OMB_ANSWER_LLM: '{provider}'. Available: {list(REGISTRY)}")
return cls(model) if model else cls()
def get_judge_llm() -> LLM:
"""Return the LLM to use for evaluation/judging.
Configured via OMB_JUDGE_LLM (provider) and OMB_JUDGE_MODEL (optional model override)."""
provider = os.environ.get("OMB_JUDGE_LLM", "gemini")
model = os.environ.get("OMB_JUDGE_MODEL")
cls = REGISTRY.get(provider)
if cls is None:
raise ValueError(f"Unknown OMB_JUDGE_LLM: '{provider}'. Available: {list(REGISTRY)}")
return cls(model) if model else cls()