Skip to content

Commit

Permalink
fix: nit param
Browse files Browse the repository at this point in the history
  • Loading branch information
ishaansehgal99 committed Jan 12, 2025
1 parent ab3db03 commit 4ebb5a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 5 additions & 4 deletions presets/ragengine/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Field, root_validator, ValidationError
from pydantic import BaseModel, Field, model_validator


class Document(BaseModel):
text: str
Expand Down Expand Up @@ -33,8 +34,8 @@ class QueryRequest(BaseModel):
description="Optional parameters for reranking, e.g., top_n, batch_size",
)

@root_validator(pre=True)
def validate_params(cls, values):
@model_validator(mode="before")
def validate_params(cls, values: Dict[str, Any]) -> Dict[str, Any]:
llm_params = values.get("llm_params", {})
rerank_params = values.get("rerank_params", {})

Expand All @@ -43,7 +44,7 @@ def validate_params(cls, values):
raise ValueError("Temperature must be between 0.0 and 1.0.")

# Validate rerank parameters
top_k = values["top_k"]
top_k = values.get("top_k")
if "top_n" in rerank_params and rerank_params["top_n"] > top_k:
raise ValueError("Invalid configuration: 'top_n' for reranking cannot exceed 'top_k' from the RAG query.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ class ModelConfig:
"""
Transformers Model Configuration Parameters
"""
pipeline: Optional[str] = field(default="text-generation", metadata={"help": "The model pipeline for the pre-trained model"})
pretrained_model_name_or_path: Optional[str] = field(default="/workspace/tfs/weights", metadata={"help": "Path to the pretrained model or model identifier from huggingface.co/models"})
combination_type: Optional[str]=field(default="svd", metadata={"help": "The combination type of multi adapters"})
state_dict: Optional[Dict[str, Any]] = field(default=None, metadata={"help": "State dictionary for the model"})
Expand Down

0 comments on commit 4ebb5a3

Please sign in to comment.