Skip to content

Adding field validator to prevent system prompt from being empty. #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion elia_chat/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import os
from pydantic import AnyHttpUrl, BaseModel, ConfigDict, Field, SecretStr

from pydantic import (
AnyHttpUrl,
BaseModel,
ConfigDict,
Field,
SecretStr,
field_validator,
)


class EliaChatModel(BaseModel):
Expand Down Expand Up @@ -171,6 +179,12 @@ class LaunchConfig(BaseModel):
)
theme: str = Field(default="nebula")

@field_validator("system_prompt")
def non_empty(cls, value: str) -> str:
if not value or value.strip() == "":
raise ValueError("system prompt must not be empty")
return value

@property
def all_models(self) -> list[EliaChatModel]:
return self.models + self.builtin_models
Expand Down