Update handler.py
Browse files- handler.py +14 -0
handler.py
CHANGED
|
@@ -39,6 +39,20 @@ class EndpointHandler:
|
|
| 39 |
}
|
| 40 |
|
| 41 |
def format_instruction(self, instruction):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
return PROMPT_FOR_GENERATION_FORMAT.format(instruction=instruction)
|
| 43 |
|
| 44 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
|
|
|
|
| 39 |
}
|
| 40 |
|
| 41 |
def format_instruction(self, instruction):
|
| 42 |
+
INSTRUCTION_KEY = "### Instruction:"
|
| 43 |
+
RESPONSE_KEY = "### Response:"
|
| 44 |
+
END_KEY = "### End"
|
| 45 |
+
INTRO_BLURB = "Below is an instruction that describes a task. Write a response that appropriately completes the request."
|
| 46 |
+
PROMPT_FOR_GENERATION_FORMAT = """{intro}
|
| 47 |
+
{instruction_key}
|
| 48 |
+
{instruction}
|
| 49 |
+
{response_key}
|
| 50 |
+
""".format(
|
| 51 |
+
intro=INTRO_BLURB,
|
| 52 |
+
instruction_key=INSTRUCTION_KEY,
|
| 53 |
+
instruction="{instruction}",
|
| 54 |
+
response_key=RESPONSE_KEY,
|
| 55 |
+
)
|
| 56 |
return PROMPT_FOR_GENERATION_FORMAT.format(instruction=instruction)
|
| 57 |
|
| 58 |
def __call__(self, data: Dict[str, Any]) -> Dict[str, str]:
|