Upload instructions.py with huggingface_hub
Browse files- instructions.py +32 -0
instructions.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from .artifact import Artifact
|
| 2 |
+
|
| 3 |
+
from abc import ABC, abstractmethod
|
| 4 |
+
from typing import Dict
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class Instruction(Artifact):
|
| 8 |
+
@abstractmethod
|
| 9 |
+
def __call__(self) -> str:
|
| 10 |
+
pass
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
class TextualInstruction(Instruction):
|
| 14 |
+
text: str
|
| 15 |
+
|
| 16 |
+
def __call__(self) -> str:
|
| 17 |
+
return self.text
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
from .collections import ListCollection
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class InstructionsList(ListCollection):
|
| 24 |
+
def verify(self):
|
| 25 |
+
for instruction in self.items:
|
| 26 |
+
assert isinstance(instruction, Instruction)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class InstructionsDict(Dict):
|
| 30 |
+
def verify(self):
|
| 31 |
+
for key, instruction in self.items():
|
| 32 |
+
assert isinstance(instruction, Instruction)
|