mirror of
https://github.com/mistralai/mistral-vibe
synced 2026-04-26 01:24:55 +02:00
v2.7.3 (#564)
Co-authored-by: Bastien <bastien.baret@gmail.com> Co-authored-by: Laure Hugo <201583486+laure0303@users.noreply.github.com> Co-authored-by: Michel Thomazo <51709227+michelTho@users.noreply.github.com> Co-authored-by: Paul Cacheux <paul.cacheux@mistral.ai> Co-authored-by: Val <102326092+vdeva@users.noreply.github.com> Co-authored-by: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -30,6 +30,7 @@ SAFETY_BORDER_CLASSES: dict[AgentSafety, str] = {
|
||||
|
||||
class ChatInputContainer(Vertical):
|
||||
ID_INPUT_BOX = "input-box"
|
||||
REMOTE_BORDER_CLASS = "border-remote"
|
||||
|
||||
class Submitted(Message):
|
||||
def __init__(self, value: str) -> None:
|
||||
@@ -59,6 +60,8 @@ class ChatInputContainer(Vertical):
|
||||
)
|
||||
self._nuage_enabled = nuage_enabled
|
||||
self._voice_manager = voice_manager
|
||||
self._custom_border_label: str | None = None
|
||||
self._custom_border_class: str | None = None
|
||||
|
||||
self._completion_manager = MultiCompletionManager([
|
||||
SlashCommandController(CommandCompleter(self._get_slash_entries), self),
|
||||
@@ -86,9 +89,9 @@ class ChatInputContainer(Vertical):
|
||||
self._completion_popup = CompletionPopup()
|
||||
yield self._completion_popup
|
||||
|
||||
border_class = SAFETY_BORDER_CLASSES.get(self._safety, "")
|
||||
border_class = self._get_border_class()
|
||||
with Vertical(id=self.ID_INPUT_BOX, classes=border_class) as input_box:
|
||||
input_box.border_title = self._agent_name
|
||||
input_box.border_title = self._get_border_title()
|
||||
self._body = ChatInputBody(
|
||||
history_file=self._history_file,
|
||||
id="input-body",
|
||||
@@ -195,23 +198,43 @@ class ChatInputContainer(Vertical):
|
||||
|
||||
def set_safety(self, safety: AgentSafety) -> None:
|
||||
self._safety = safety
|
||||
self._apply_input_box_chrome()
|
||||
|
||||
def set_agent_name(self, name: str) -> None:
|
||||
self._agent_name = name
|
||||
self._apply_input_box_chrome()
|
||||
|
||||
def set_custom_border(
|
||||
self, label: str | None, border_class: str | None = None
|
||||
) -> None:
|
||||
self._custom_border_label = label
|
||||
self._custom_border_class = border_class
|
||||
self._apply_input_box_chrome()
|
||||
|
||||
def _get_border_class(self) -> str:
|
||||
if self._custom_border_class is not None:
|
||||
return self._custom_border_class
|
||||
if self._custom_border_label is not None:
|
||||
return ""
|
||||
return SAFETY_BORDER_CLASSES.get(self._safety, "")
|
||||
|
||||
def _get_border_title(self) -> str:
|
||||
if self._custom_border_label is not None:
|
||||
return self._custom_border_label
|
||||
return self._agent_name
|
||||
|
||||
def _apply_input_box_chrome(self) -> None:
|
||||
try:
|
||||
input_box = self.get_widget_by_id(self.ID_INPUT_BOX)
|
||||
except Exception:
|
||||
return
|
||||
|
||||
input_box.remove_class(self.REMOTE_BORDER_CLASS)
|
||||
for border_class in SAFETY_BORDER_CLASSES.values():
|
||||
input_box.remove_class(border_class)
|
||||
|
||||
if safety in SAFETY_BORDER_CLASSES:
|
||||
input_box.add_class(SAFETY_BORDER_CLASSES[safety])
|
||||
border_class = self._get_border_class()
|
||||
if border_class:
|
||||
input_box.add_class(border_class)
|
||||
|
||||
def set_agent_name(self, name: str) -> None:
|
||||
self._agent_name = name
|
||||
|
||||
try:
|
||||
input_box = self.get_widget_by_id(self.ID_INPUT_BOX)
|
||||
input_box.border_title = name
|
||||
except Exception:
|
||||
pass
|
||||
input_box.border_title = self._get_border_title()
|
||||
|
||||
Reference in New Issue
Block a user