Skip to content

Commit b8d38e4

Browse files
committed
feat: enhance logging
1 parent c3b38cf commit b8d38e4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/rai/rai/utils/model_initialization.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import logging
1616
import os
1717
from dataclasses import dataclass
18-
from typing import List, Literal, cast
18+
from typing import List, Literal, Optional, cast
1919

2020
import coloredlogs
2121
import tomli
@@ -101,7 +101,7 @@ def load_config() -> RAIConfig:
101101

102102

103103
def get_llm_model(
104-
model_type: Literal["simple_model", "complex_model"], vendor: str = None
104+
model_type: Literal["simple_model", "complex_model"], vendor: Optional[str] = None
105105
):
106106
config = load_config()
107107
if vendor is None:
@@ -113,7 +113,7 @@ def get_llm_model(
113113
model_config = getattr(config, vendor)
114114

115115
model = getattr(model_config, model_type)
116-
logger.info(f"Using LLM model: {vendor}-{model}")
116+
logger.info(f"Initializing {model_type}: Vendor: {vendor}, Model: {model}")
117117
if vendor == "openai":
118118
from langchain_openai import ChatOpenAI
119119

@@ -124,7 +124,10 @@ def get_llm_model(
124124
else os.getenv("OPENAI_API_KEY", None)
125125
)
126126
if api_key is None:
127-
raise ValueError("OPENAI_API_KEY is not set")
127+
raise ValueError(
128+
"OPENAI_API_KEY is not set. Set it either in config.toml "
129+
"(for openai compatible apis) or as an environment variable."
130+
)
128131

129132
return ChatOpenAI(
130133
model=model, base_url=model_config.base_url, api_key=SecretStr(api_key)

0 commit comments

Comments
 (0)