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