First commmit
This commit is contained in:
2
src/rag_eval/__init__.py
Normal file
2
src/rag_eval/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
def main() -> None:
|
||||
print("Hello from rag-eval!")
|
||||
121
src/rag_eval/config.py
Normal file
121
src/rag_eval/config.py
Normal file
@@ -0,0 +1,121 @@
|
||||
import os
|
||||
|
||||
from pydantic import BaseModel
|
||||
from pydantic_settings import (
|
||||
BaseSettings,
|
||||
PydanticBaseSettingsSource,
|
||||
SettingsConfigDict,
|
||||
YamlConfigSettingsSource,
|
||||
)
|
||||
|
||||
CONFIG_FILE_PATH = os.getenv("CONFIG_YAML", "config.yaml")
|
||||
|
||||
|
||||
class IndexConfig(BaseModel):
|
||||
name: str
|
||||
endpoint: str
|
||||
dimensions: int
|
||||
machine_type: str = "e2-standard-16"
|
||||
origin: str
|
||||
destination: str
|
||||
chunk_limit: int
|
||||
|
||||
@property
|
||||
def deployment(self) -> str:
|
||||
return self.name.replace("-", "_") + "_deployed"
|
||||
|
||||
@property
|
||||
def data(self) -> str:
|
||||
return self.destination + self.name
|
||||
|
||||
class AgentConfig(BaseModel):
|
||||
name: str
|
||||
instructions: str
|
||||
language_model: str
|
||||
embedding_model: str
|
||||
thinking: int
|
||||
|
||||
|
||||
class BigQueryConfig(BaseModel):
|
||||
dataset_id: str
|
||||
project_id: str | None = None
|
||||
table_ids: dict[str, str]
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
project_id: str
|
||||
location: str
|
||||
service_account: str
|
||||
|
||||
# Flattened fields from nested models
|
||||
agent_name: str
|
||||
agent_instructions: str
|
||||
agent_language_model: str
|
||||
agent_embedding_model: str
|
||||
agent_thinking: int
|
||||
|
||||
index_name: str
|
||||
index_endpoint: str
|
||||
index_dimensions: int
|
||||
index_machine_type: str = "e2-standard-16"
|
||||
index_origin: str
|
||||
index_destination: str
|
||||
index_chunk_limit: int
|
||||
|
||||
bigquery_dataset_id: str
|
||||
bigquery_project_id: str | None = None
|
||||
bigquery_table_ids: dict[str, str]
|
||||
|
||||
bucket: str
|
||||
base_image: str
|
||||
dialogflow_agent_id: str
|
||||
processing_image: str
|
||||
|
||||
model_config = SettingsConfigDict(yaml_file=CONFIG_FILE_PATH)
|
||||
|
||||
@property
|
||||
def agent(self) -> AgentConfig:
|
||||
return AgentConfig(
|
||||
name=self.agent_name,
|
||||
instructions=self.agent_instructions,
|
||||
language_model=self.agent_language_model,
|
||||
embedding_model=self.agent_embedding_model,
|
||||
thinking=self.agent_thinking,
|
||||
)
|
||||
|
||||
@property
|
||||
def index(self) -> IndexConfig:
|
||||
return IndexConfig(
|
||||
name=self.index_name,
|
||||
endpoint=self.index_endpoint,
|
||||
dimensions=self.index_dimensions,
|
||||
machine_type=self.index_machine_type,
|
||||
origin=self.index_origin,
|
||||
destination=self.index_destination,
|
||||
chunk_limit=self.index_chunk_limit,
|
||||
)
|
||||
|
||||
@property
|
||||
def bigquery(self) -> BigQueryConfig:
|
||||
return BigQueryConfig(
|
||||
dataset_id=self.bigquery_dataset_id,
|
||||
project_id=self.bigquery_project_id,
|
||||
table_ids=self.bigquery_table_ids,
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def settings_customise_sources(
|
||||
cls,
|
||||
settings_cls: type[BaseSettings],
|
||||
init_settings: PydanticBaseSettingsSource,
|
||||
env_settings: PydanticBaseSettingsSource,
|
||||
dotenv_settings: PydanticBaseSettingsSource,
|
||||
file_secret_settings: PydanticBaseSettingsSource,
|
||||
) -> tuple[PydanticBaseSettingsSource, ...]:
|
||||
return (
|
||||
env_settings,
|
||||
YamlConfigSettingsSource(settings_cls),
|
||||
)
|
||||
|
||||
|
||||
settings = Settings()
|
||||
Reference in New Issue
Block a user