Skip to content

Commit 89dadd7

Browse files
committed
Add llm config
1 parent ed63b8c commit 89dadd7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

dockers/llm.rag.service/config.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ def validate_float(value):
1313
raise ValueError("Value must be convertible to a float")
1414

1515

16+
def validate_int(value):
17+
if type(value) == int:
18+
return value
19+
try:
20+
return int(value.strip("'").strip("\""))
21+
except (TypeError, ValueError):
22+
raise ValueError("Value must be convertible to an integer")
23+
24+
1625
class WeaviateSettings(BaseSettings):
1726
weaviate_uri: Optional[str] = Field(
1827
default="localhost:8080",
@@ -60,3 +69,32 @@ def get_weaviate_grpc_uri(self):
6069

6170
def get_weaviate_grpc_port(self):
6271
return int(self.weaviate_grpc_uri.split(":")[1])
72+
73+
74+
class LlmSettings(BaseSettings):
75+
llm_server_url: Optional[str] = Field(
76+
default="http://localhost:9000/v1",
77+
alias="MODEL_LLM_SERVER_URL",
78+
)
79+
model_id: Optional[str] = Field(
80+
default="rubra-ai/Phi-3-mini-128k-instruct",
81+
alias="MODEL_ID",
82+
)
83+
max_tokens: Optional[int] = Field(
84+
default=256,
85+
alias="MAX_TOKENS",
86+
)
87+
model_temperature: Optional[float] = Field(
88+
default=0.01,
89+
alias="MODEL_TEMPERATURE",
90+
)
91+
92+
@field_validator("max_tokens", mode="before")
93+
@classmethod
94+
def validate_max_tokens(cls, v):
95+
return validate_int(v)
96+
97+
@field_validator("model_temperature", mode="before")
98+
@classmethod
99+
def validate_model_temperature(cls, v):
100+
return validate_float(v)

0 commit comments

Comments
 (0)