Skip to content

Commit

Permalink
Allow persona definition with None system prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Dec 19, 2024
1 parent 449dcca commit 55bf516
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions neon_data_models/models/api/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class LLMPersona(BaseModel):
name: str = Field(description="Unique name for this persona")
description: Optional[str] = Field(
None, description="Human-readable description of this persona")
system_prompt: str = Field(
system_prompt: Optional[str] = Field(
None, description="System prompt associated with this persona. "
"If None, `description` will be used.")
enabled: bool = Field(
Expand All @@ -48,8 +48,7 @@ class LLMPersona(BaseModel):

@model_validator(mode='after')
def validate_request(self):
assert any(x is not None for x in (self.description, self.system_prompt))
if self.system_prompt is None:
if self.system_prompt is None and self.description:
self.system_prompt = self.description
return self

Expand Down
2 changes: 1 addition & 1 deletion tests/models/api/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_llm_persona(self):
"A customized bot for something")

with self.assertRaises(ValidationError):
LLMPersona(name="underdefined persona")
LLMPersona(description="underdefined persona")

def test_llm_request(self):
from neon_data_models.models.api.llm import LLMRequest, LLMPersona
Expand Down

0 comments on commit 55bf516

Please sign in to comment.