forked from Archives/langchain
cr
This commit is contained in:
parent
eb54c0b847
commit
71cd6523a4
@ -35,6 +35,7 @@ class LLMMathExample(BaseExample):
|
|||||||
question: str
|
question: str
|
||||||
answer: str
|
answer: str
|
||||||
|
|
||||||
|
@property
|
||||||
def formatted(self) -> str:
|
def formatted(self) -> str:
|
||||||
return f"Question: {self.question}\n\n{self.answer}"
|
return f"Question: {self.question}\n\n{self.answer}"
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ class ReActExample(BaseExample):
|
|||||||
question: str
|
question: str
|
||||||
answer: str
|
answer: str
|
||||||
|
|
||||||
|
@property
|
||||||
def formatted(self) -> str:
|
def formatted(self) -> str:
|
||||||
return f"Question: {self.question}\n{self.answer}"
|
return f"Question: {self.question}\n{self.answer}"
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ class SelfAskWithSearchExample(BaseExample):
|
|||||||
question: str
|
question: str
|
||||||
answer: str
|
answer: str
|
||||||
|
|
||||||
|
@property
|
||||||
def formatted(self) -> str:
|
def formatted(self) -> str:
|
||||||
return f"Question: {self.question}\n{self.answer}"
|
return f"Question: {self.question}\n{self.answer}"
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ from pydantic import BaseModel
|
|||||||
class BaseExample(BaseModel, ABC):
|
class BaseExample(BaseModel, ABC):
|
||||||
"""Base class for examples."""
|
"""Base class for examples."""
|
||||||
|
|
||||||
@abstractmethod
|
|
||||||
@property
|
@property
|
||||||
|
@abstractmethod
|
||||||
def formatted(self) -> str:
|
def formatted(self) -> str:
|
||||||
"""Returns a formatted example as a string."""
|
"""Returns a formatted example as a string."""
|
||||||
|
|
||||||
@ -16,6 +16,7 @@ class SimpleExample(BaseExample):
|
|||||||
|
|
||||||
text: str
|
text: str
|
||||||
|
|
||||||
|
@property
|
||||||
def formatted(self) -> str:
|
def formatted(self) -> str:
|
||||||
return self.text
|
return self.text
|
||||||
|
|
||||||
|
@ -116,7 +116,8 @@ class DynamicPrompt(BaseModel, BasePrompt):
|
|||||||
)
|
)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
@root_validator()
|
# Needs to be pre=True to convert to the right type.
|
||||||
|
@root_validator(pre=True)
|
||||||
def convert_examples(cls, values: Dict) -> Dict:
|
def convert_examples(cls, values: Dict) -> Dict:
|
||||||
values["examples"] = convert_to_examples(values["examples"])
|
values["examples"] = convert_to_examples(values["examples"])
|
||||||
return values
|
return values
|
||||||
|
@ -51,8 +51,8 @@ Question: {question}
|
|||||||
Answer:"""
|
Answer:"""
|
||||||
input_variables = ["question"]
|
input_variables = ["question"]
|
||||||
example_separator = "\n\n"
|
example_separator = "\n\n"
|
||||||
prefix = """Test Prompt:\n\n"""
|
prefix = """Test Prompt:"""
|
||||||
suffix = """\n\nQuestion: {question}\nAnswer:"""
|
suffix = """Question: {question}\nAnswer:"""
|
||||||
examples = [
|
examples = [
|
||||||
"""Question: who are you?\nAnswer: foo""",
|
"""Question: who are you?\nAnswer: foo""",
|
||||||
"""Question: what are you?\nAnswer: bar""",
|
"""Question: what are you?\nAnswer: bar""",
|
||||||
|
Loading…
Reference in New Issue
Block a user