MCPcopy Create free account
hub / github.com/ContextualAI/HALOs / __setattr__

Method __setattr__

train/data.py:52–68  ·  view source on GitHub ↗

Set prompt ID automatically.

(self, name, value)

Source from the content-addressed store, hash-verified

50 original_prompt: str = '' # the unformatted prompt (needed to recover instruction for AlpacaEval)
51
52 def __setattr__(self, name, value):
53 """Set prompt ID automatically."""
54 if name == 'prompt' and value is not None:
55 content = ''
56
57 for turn in value:
58 if "role" not in turn:
59 raise ValueError("every turn in an example must have a 'role' field")
60
61 if "content" not in turn:
62 raise ValueError("every turn in an example must have a 'content' field")
63
64 content = content + turn['content']
65
66 self.prompt_id = hashlib.sha256(content.encode()).hexdigest()
67
68 super().__setattr__(name, value)
69
70 def __getitem__(self, key):
71 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected