-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
968fe75
commit 8bc71ce
Showing
5 changed files
with
48 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from typing import Optional, Union | ||
from pydantic import BaseModel, model_validator | ||
from chatsky.core import BaseResponse, BasePriority, AnyPriority, AnyResponse, MessageInitTypes, Message | ||
|
||
|
||
class DesaultPositionConfig(BaseModel): | ||
system_prompt: float = 0 | ||
history: float = 1 | ||
misc_prompt: float = 2 | ||
call_prompt: float = 3 | ||
last_response: float = 4 | ||
|
||
|
||
class Prompt(BaseModel): | ||
prompt: AnyResponse | ||
position: Optional[AnyPriority] = None | ||
|
||
def __init__( | ||
self, | ||
prompt: Union[MessageInitTypes, BaseResponse], | ||
position: Optional[Union[float, BasePriority]] = None | ||
): | ||
super().__init__(prompt=prompt, position=position) | ||
|
||
@model_validator(mode="before") | ||
@classmethod | ||
def validate_from_message(cls, data): | ||
# MISC: {"prompt": "message", "prompt": Message("text"), "prompt": FilledTemplate(), "prompt": Prompt(prompt=FilledTemplate(), position=-2) | ||
# Prompt.model_validate | ||
if isinstance(data, (str, Message, BaseResponse)): | ||
return {"prompt": data} | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters