Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,19 +391,19 @@ def get_conv_template(self, model_path: str, task: str = "") -> Conversation:
if self.conv_template:
return
if not task:
self.conv_template = PromptTemplate(self.get_default_conv_template(model_path).name)
self.conv_template = PromptTemplate(self.get_default_conv_template(model_path).name, clear_history=True)
else:
clear_after_gen = True
clear_history = True
if task == "completion":
name = "alpaca_without_input"
elif task == "chat":
name = "neural-chat-7b-v2"
clear_after_gen = False
clear_history = False
elif task == "summarization":
name = "summarization"
else:
raise NotImplementedError(f"Unsupported task {task}.")
self.conv_template = PromptTemplate(name, clear_after_gen=clear_after_gen)
self.conv_template = PromptTemplate(name, clear_history=clear_history)

def prepare_prompt(self, prompt: str, model_path: str, task: str = ""):
self.get_conv_template(model_path, task)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@
)

class PromptTemplate:
def __init__(self, name="one_shot", clear_after_gen=False):
def __init__(self, name="one_shot", clear_history=False):
self.conv = get_conv_template(name)
self.clear_after_gen = clear_after_gen
self.clear_history = clear_history

@property
def roles(self):
Expand All @@ -215,7 +215,7 @@ def append_message(self, role: str, message: str):

def get_prompt(self) -> str:
res = self.conv.get_prompt()
if self.clear_after_gen:
if self.clear_history:
self.clear_messages()
return res

Expand Down