Skip to content

Commit

Permalink
feat: chat prompt - yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
tvaroska committed Dec 9, 2024
1 parent 4b2f3e6 commit b85b5bb
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions promptgit/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
"""

import json
import string
import yaml

from enum import Enum
from typing import Dict, List, Optional, Union, NamedTuple
from typing import Dict, List, Optional, Union, NamedTuple, Literal
from pathlib import Path
from pydantic import BaseModel, field_validator, model_validator

Expand Down Expand Up @@ -101,13 +99,8 @@ def standardize_sections(key: str) -> str:

return content

class PromptRoles(Enum):
system = 'system'
human = 'human'
ai = 'ai'

class PromptTurn(BaseModel):
role: PromptRoles
role: Literal['system', 'user', 'human', 'model', 'ai']
content: str

class Prompt(BaseModel):
Expand Down Expand Up @@ -167,7 +160,7 @@ def from_json(cls, content: str):

@classmethod
def from_yaml(cls, content: str):
return cls(**yaml.load(content))
return cls.model_validate(yaml.safe_load(content))

@classmethod
def from_md(cls, content: str):
Expand Down

0 comments on commit b85b5bb

Please sign in to comment.