fix: fix prompt to tell user that conversation has ended

pull/5/head
hanchchch 1 year ago
parent 41237d5532
commit 264467d660

@ -14,7 +14,7 @@ class EvalOutputParser(BaseOutputParser):
regex = r"Action: (.*?)[\n]*Action Input: (.*)"
match = re.search(regex, text, re.DOTALL)
if not match:
return {"action": "Exit Conversation", "action_input": text}
raise Exception("parse error")
action = match.group(1).strip()
action_input = match.group(2)
return {"action": action, "action_input": action_input.strip(" ").strip('"')}

@ -35,7 +35,6 @@ toolsets: List[BaseToolSet] = [
Terminal(),
CodeEditor(),
RequestsGet(),
WineDB(),
ExitConversation(),
Text2Image("cuda"),
ImageEditing("cuda"),
@ -90,6 +89,7 @@ async def command(request: Request) -> Response:
try:
res = executor({"input": promptedQuery})
except Exception as e:
logger.error(f"error while processing request: ", str(e))
try:
res = executor(
{

@ -57,8 +57,6 @@ Here is the user's input:
EVAL_TOOL_RESPONSE = """TOOL RESPONSE:
---------------------
{observation}
USER'S INPUT
--------------------
After exiting conversation, you must choose Final Answer Action.
"""

@ -227,15 +227,14 @@ class ExitConversation(BaseToolSet):
name="Exit Conversation",
description="A tool to exit the conversation. "
"Use this when you want to exit the conversation. "
"Input should be a user's session."
"The output will be a message that the conversation is over.",
"The input should be a message that the conversation is over.",
scope=ToolScope.SESSION,
)
def exit(self, *args, get_session: SessionGetter) -> str:
def exit(self, message: str, get_session: SessionGetter) -> str:
"""Run the tool."""
_, executor = get_session()
del executor
logger.debug(f"\nProcessed ExitConversation.")
return f"Exit conversation."
return message

Loading…
Cancel
Save