forked from Archives/langchain
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
820 B
Python
35 lines
820 B
Python
"""BasePrompt schema definition."""
|
|
from abc import ABC, abstractmethod
|
|
from typing import Any, List
|
|
|
|
from langchain.formatting import formatter
|
|
from langchain.prompts.data import BaseExample
|
|
|
|
DEFAULT_FORMATTER_MAPPING = {
|
|
"f-string": formatter.format,
|
|
}
|
|
|
|
|
|
class BasePrompt(ABC):
|
|
"""Base prompt should expose the format method, returning a prompt."""
|
|
|
|
input_variables: List[str]
|
|
"""A list of the names of the variables the prompt template expects."""
|
|
|
|
@abstractmethod
|
|
def format(self, **kwargs: Any) -> str:
|
|
"""Format the prompt with the inputs.
|
|
|
|
Args:
|
|
kwargs: Any arguments to be passed to the prompt template.
|
|
|
|
Returns:
|
|
A formatted string.
|
|
|
|
Example:
|
|
|
|
.. code-block:: python
|
|
|
|
prompt.format(variable1="foo")
|
|
"""
|