renamed dataclass
This commit is contained in:
@@ -10,7 +10,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class PromptResult:
|
class ManagedPrompt:
|
||||||
"""Smart result object that holds template and can fill variables on demand."""
|
"""Smart result object that holds template and can fill variables on demand."""
|
||||||
template: str
|
template: str
|
||||||
name: str
|
name: str
|
||||||
@@ -181,7 +181,6 @@ class PromptManager:
|
|||||||
# Default to 'prompts' directory in the current working directory
|
# Default to 'prompts' directory in the current working directory
|
||||||
return Path.cwd() / 'prompts'
|
return Path.cwd() / 'prompts'
|
||||||
|
|
||||||
|
|
||||||
def _extract_variables(self, template: str) -> Set[str]:
|
def _extract_variables(self, template: str) -> Set[str]:
|
||||||
"""Extract all {{variable}} placeholders from template"""
|
"""Extract all {{variable}} placeholders from template"""
|
||||||
pattern = r'\{\{(\w+)\}\}'
|
pattern = r'\{\{(\w+)\}\}'
|
||||||
@@ -242,7 +241,7 @@ class PromptManager:
|
|||||||
instance.prompt_variables.clear()
|
instance.prompt_variables.clear()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_prompt(cls, prompt_name: str, **kwargs) -> PromptResult:
|
def get_prompt(cls, prompt_name: str, **kwargs) -> ManagedPrompt:
|
||||||
"""
|
"""
|
||||||
Get a PromptResult that can be filled with variables.
|
Get a PromptResult that can be filled with variables.
|
||||||
|
|
||||||
@@ -278,7 +277,7 @@ class PromptManager:
|
|||||||
schema = instance.schemas.get(prompt_name)
|
schema = instance.schemas.get(prompt_name)
|
||||||
|
|
||||||
# Create the result object
|
# Create the result object
|
||||||
result = PromptResult(
|
result = ManagedPrompt(
|
||||||
template=template,
|
template=template,
|
||||||
name=prompt_name,
|
name=prompt_name,
|
||||||
variables=variables,
|
variables=variables,
|
||||||
@@ -330,7 +329,7 @@ class PromptManager:
|
|||||||
return prompt_name in instance.schemas
|
return prompt_name in instance.schemas
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_prompt_with_schema(cls, prompt_name: str, **kwargs) -> PromptResult:
|
def get_prompt_with_schema(cls, prompt_name: str, **kwargs) -> ManagedPrompt:
|
||||||
"""
|
"""
|
||||||
Get both the processed prompt and its schema (if available)
|
Get both the processed prompt and its schema (if available)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user