This commit is contained in:
Harrison Chase committed 2022-11-12 06:55:08 -08:00
1 parent eb54c0b847
commit 71cd6523a4
6 files changed
+9 -4

No files matched your search

+1
View File
@@ -35,6 +35,7 @@ class LLMMathExample(BaseExample):
question: str
answer: str
@property
def formatted(self) -> str:
return f"Question: {self.question}\n\n{self.answer}"
+1
View File
@@ -12,6 +12,7 @@ class ReActExample(BaseExample):
question: str
answer: str
@property
def formatted(self) -> str:
return f"Question: {self.question}\n{self.answer}"
@@ -12,6 +12,7 @@ class SelfAskWithSearchExample(BaseExample):
question: str
answer: str
@property
def formatted(self) -> str:
return f"Question: {self.question}\n{self.answer}"
+2 -1
View File
@@ -6,8 +6,8 @@ from pydantic import BaseModel
class BaseExample(BaseModel, ABC):
"""Base class for examples."""
@abstractmethod
@property
@abstractmethod
def formatted(self) -> str:
"""Returns a formatted example as a string."""
@@ -16,6 +16,7 @@ class SimpleExample(BaseExample):
text: str
@property
def formatted(self) -> str:
return self.text
+2 -1
View File
@@ -116,7 +116,8 @@ class DynamicPrompt(BaseModel, BasePrompt):
)
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:
values["examples"] = convert_to_examples(values["examples"])
return values
+2 -2
View File
@@ -51,8 +51,8 @@ Question: {question}
Answer:"""
input_variables = ["question"]
example_separator = "\n\n"
prefix = """Test Prompt:\n\n"""
suffix = """\n\nQuestion: {question}\nAnswer:"""
prefix = """Test Prompt:"""
suffix = """Question: {question}\nAnswer:"""
examples = [
"""Question: who are you?\nAnswer: foo""",
"""Question: what are you?\nAnswer: bar""",