-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathformal.py
More file actions
48 lines (41 loc) · 1.97 KB
/
Copy pathformal.py
File metadata and controls
48 lines (41 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Chat template for formal tone augmentation."""
from typing import ClassVar
from autointent.generation.utterances.schemas import Message, Role
from autointent.schemas import Intent
from .base import EvolutionChatTemplate
class FormalEvolution(EvolutionChatTemplate):
"""Chat template for formal tone augmentation."""
_messages: ClassVar[list[Message]] = [
Message(
role=Role.USER,
content=(
"I want you to act as a rewriter. "
"You will be provided with an utterance and the topic (name of intent class) of the utterance. "
"You need to rewrite the utterance in a more formal tone using the following method:\n"
"1. Rewrite the utterance in a more formal tone.\n"
"2. Use polite and professional language while maintaining clarity.\n"
"3. The rewritten utterance should be grammatically correct and complete.\n"
"4. Keep the rewritten utterance within 15 words.\n\n"
"Intent name: Reserve Restaurant"
"Utterance: I want to reserve a table for 4 persons at 9 pm."
),
),
Message(role=Role.ASSISTANT, content="I would like to make a reservation for four guests at 9 pm."),
Message(
role=Role.ASSISTANT,
content=(
"Intent name: requesting technical support\n"
"Utterance: My Lenovo laptop is constantly rebooting and overheating."
),
),
Message(
role=Role.ASSISTANT,
content="My Lenovo laptop frequently restarts and experiences overheating issues. Kindly assist.",
),
]
def __call__(self, utterance: str, intent_data: Intent) -> list[Message]:
"""Generate chat for formal tone adaptation."""
return [
*self._messages,
Message(role=Role.USER, content=f"Intent name: {intent_data.name or ''}\nUtterance: {utterance}"),
]