Skip to content

Commit

Permalink
dev: code cleanup, maybe better exit behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Oct 3, 2024
1 parent 97eb175 commit 7294719
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion kani/prompts/impl/mistral.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ async def stream(self, messages: list[ChatMessage], functions: list[AIFunction]
content, tool_calls = self._parse_tool_calls(content)
if inner_completion:
tool_calls = (inner_completion.message.tool_calls or []) + tool_calls
yield Completion(ChatMessage.assistant(content.removesuffix(self.eos_token).strip(), tool_calls=tool_calls))
clean_content = content.removesuffix(self.eos_token).strip()
yield Completion(ChatMessage.assistant(clean_content, tool_calls=tool_calls))


MistralFunctionCallingAdapter = MixtralFunctionCallingAdapter
7 changes: 5 additions & 2 deletions kani/utils/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ async def chat_in_terminal_async(
# function
elif msg.role == ChatRole.FUNCTION and show_function_returns:
print_width(msg.text, width=width, prefix="FUNC: ")
except KeyboardInterrupt:
await kani.engine.close()
except (KeyboardInterrupt, asyncio.CancelledError):
# we won't close the engine here since it's common enough that people close the session in colab
# and if the process is closing then this will clean itself up anyway
# await kani.engine.close()
return


@overload
Expand Down

0 comments on commit 7294719

Please sign in to comment.