forked from Archives/langchain
stash
This commit is contained in:
parent
9b674d3dc6
commit
67685b874e
@ -1,6 +1,7 @@
|
|||||||
"""BasePrompt schema definition."""
|
"""BasePrompt schema definition."""
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from typing import Any, List
|
from typing import Any, List, Union, Dict
|
||||||
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from langchain.formatting import formatter
|
from langchain.formatting import formatter
|
||||||
|
|
||||||
@ -41,11 +42,14 @@ class DefaultParser(OutputParser):
|
|||||||
"""Parse the output of an LLM call."""
|
"""Parse the output of an LLM call."""
|
||||||
return text
|
return text
|
||||||
|
|
||||||
class BasePromptTemplate(ABC):
|
|
||||||
|
class BasePromptTemplate(BaseModel, ABC):
|
||||||
"""Base prompt should expose the format method, returning a prompt."""
|
"""Base prompt should expose the format method, returning a prompt."""
|
||||||
|
|
||||||
input_variables: List[str]
|
input_variables: List[str]
|
||||||
"""A list of the names of the variables the prompt template expects."""
|
"""A list of the names of the variables the prompt template expects."""
|
||||||
|
output_parser: OutputParser = Field(default_factory=DefaultParser)
|
||||||
|
"""How to parse the output of calling an LLM on this formatted prompt."""
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def format(self, **kwargs: Any) -> str:
|
def format(self, **kwargs: Any) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user