49 lines
1.6 KiB
Python
49 lines
1.6 KiB
Python
class LLMInstructions:
|
||
"""
|
||
Defines structured instructions that are sent along with each request
|
||
to the LLM to guide its behavior (norms, goals, etc.).
|
||
"""
|
||
|
||
@staticmethod
|
||
def default_norms() -> list[str]:
|
||
return [
|
||
"Be friendly and respectful.",
|
||
"Make the conversation feel natural and engaging.",
|
||
]
|
||
|
||
@staticmethod
|
||
def default_goals() -> list[str]:
|
||
return [
|
||
"Try to learn the user's name during conversation.",
|
||
]
|
||
|
||
def __init__(self, norms: list[str] = None, goals: list[str] = None):
|
||
self.norms = norms or self.default_norms()
|
||
self.goals = goals or self.default_goals()
|
||
|
||
def build_developer_instruction(self) -> str:
|
||
"""
|
||
Builds a multi-line formatted instruction string for the LLM.
|
||
Includes only non-empty structured fields.
|
||
"""
|
||
sections = [
|
||
"You are a Pepper robot engaging in natural human conversation.",
|
||
"Keep responses between 1–3 sentences, unless told otherwise.\n",
|
||
"You're given goals to reach. Reach them in order, but make the conversation feel "
|
||
"natural. Some turns you should not try to achieve your goals.\n",
|
||
]
|
||
|
||
if self.norms:
|
||
sections.append("Norms to follow:")
|
||
for norm in self.norms:
|
||
sections.append("- " + norm)
|
||
sections.append("")
|
||
|
||
if self.goals:
|
||
sections.append("Goals to reach:")
|
||
for goal in self.goals:
|
||
sections.append("- " + goal)
|
||
sections.append("")
|
||
|
||
return "\n".join(sections).strip()
|