Merge pull request #201 from ggozad/fix/allow-custom-config
Fix get_model() uses where default Config is forced
This commit is contained in:
commit
1ff8fc1b56
4 changed files with 10 additions and 10 deletions
|
|
@ -1,8 +1,7 @@
|
|||
from pydantic import BaseModel
|
||||
from pydantic_ai import Agent
|
||||
|
||||
from haiku.rag.config import Config
|
||||
from haiku.rag.config.models import ModelConfig
|
||||
from haiku.rag.config.models import AppConfig, ModelConfig
|
||||
from haiku.rag.utils import get_model
|
||||
|
||||
ANSWER_EQUIVALENCE_RUBRIC = """You are evaluating whether two answers to the same question are semantically equivalent.
|
||||
|
|
@ -36,10 +35,9 @@ class LLMJudgeResponseSchema(BaseModel):
|
|||
class LLMJudge:
|
||||
"""LLM-as-judge for evaluating answer equivalence using Pydantic AI."""
|
||||
|
||||
def __init__(self, model: str = "gpt-oss"):
|
||||
# Create model using get_model with thinking disabled
|
||||
def __init__(self, model: str = "gpt-oss", config: AppConfig | None = None):
|
||||
model_config = ModelConfig(provider="ollama", name=model, enable_thinking=False)
|
||||
model_obj = get_model(model_config, Config)
|
||||
model_obj = get_model(model_config, config)
|
||||
|
||||
# Create Pydantic AI agent
|
||||
self._agent = Agent(
|
||||
|
|
|
|||
|
|
@ -21,5 +21,6 @@ def get_qa_agent(
|
|||
return QuestionAnswerAgent(
|
||||
client=client,
|
||||
model_config=config.qa.model,
|
||||
config=config,
|
||||
system_prompt=system_prompt,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@ from pydantic_ai import Agent, RunContext
|
|||
from pydantic_ai.output import ToolOutput
|
||||
|
||||
from haiku.rag.client import HaikuRAG
|
||||
from haiku.rag.config import Config
|
||||
from haiku.rag.config.models import ModelConfig
|
||||
from haiku.rag.config.models import AppConfig, ModelConfig
|
||||
from haiku.rag.graph.research.models import Citation, RawSearchAnswer, resolve_citations
|
||||
from haiku.rag.qa.prompts import QA_SYSTEM_PROMPT
|
||||
from haiku.rag.store.models import SearchResult
|
||||
|
|
@ -23,10 +22,11 @@ class QuestionAnswerAgent:
|
|||
self,
|
||||
client: HaikuRAG,
|
||||
model_config: ModelConfig,
|
||||
config: AppConfig | None = None,
|
||||
system_prompt: str | None = None,
|
||||
):
|
||||
self._client = client
|
||||
model_obj = get_model(model_config, Config)
|
||||
model_obj = get_model(model_config, config)
|
||||
|
||||
self._agent = Agent(
|
||||
model=model_obj,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ from packaging.version import Version, parse
|
|||
if TYPE_CHECKING:
|
||||
from rich.console import RenderableType
|
||||
|
||||
from haiku.rag.config.models import AppConfig, ModelConfig
|
||||
from haiku.rag.graph.research.models import Citation
|
||||
|
||||
|
||||
|
|
@ -44,8 +45,8 @@ def apply_common_settings(
|
|||
|
||||
|
||||
def get_model(
|
||||
model_config: Any,
|
||||
app_config: Any | None = None,
|
||||
model_config: "ModelConfig",
|
||||
app_config: "AppConfig | None" = None,
|
||||
) -> Any:
|
||||
"""
|
||||
Get a model instance for the specified configuration.
|
||||
|
|
|
|||
Loading…
Reference in a new issue