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.
31 lines
617 B
Python
31 lines
617 B
Python
# flake8: noqa
|
|
from pathlib import Path
|
|
|
|
from langchain.prompts.data import BaseExample
|
|
from langchain.prompts.prompt import Prompt
|
|
|
|
example_path = Path(__file__).parent / "examples.json"
|
|
import json
|
|
|
|
|
|
class ReActExample(BaseExample):
|
|
question: str
|
|
answer: str
|
|
|
|
@property
|
|
def formatted(self) -> str:
|
|
return f"Question: {self.question}\n{self.answer}"
|
|
|
|
|
|
with open(example_path) as f:
|
|
raw_examples = json.load(f)
|
|
examples = [ReActExample(**example) for example in raw_examples]
|
|
|
|
SUFFIX = """Question: {input}"""
|
|
|
|
PROMPT = Prompt.from_examples(
|
|
examples,
|
|
SUFFIX,
|
|
["input"],
|
|
)
|