diff --git a/src/alpaca.gresource.xml b/src/alpaca.gresource.xml index 2027979..8fa13cf 100644 --- a/src/alpaca.gresource.xml +++ b/src/alpaca.gresource.xml @@ -33,6 +33,7 @@ icons/chat-bubble-text-symbolic.svg icons/execute-from-symbolic.svg icons/cross-large-symbolic.svg + icons/info-outline-symbolic.svg window.ui gtk/help-overlay.ui diff --git a/src/custom_widgets/model_widget.py b/src/custom_widgets/model_widget.py index 6c74e8a..c5585a6 100644 --- a/src/custom_widgets/model_widget.py +++ b/src/custom_widgets/model_widget.py @@ -56,7 +56,7 @@ class model_selector_popup(Gtk.Popover): class model_selector_row(Gtk.ListBoxRow): __gtype_name__ = 'AlpacaModelSelectorRow' - def __init__(self, model_name:str, image_recognition:bool): + def __init__(self, model_name:str, data:dict): super().__init__( child = Gtk.Label( label=window.convert_model_name(model_name, 0), @@ -68,7 +68,8 @@ class model_selector_row(Gtk.ListBoxRow): name=model_name, tooltip_text=window.convert_model_name(model_name, 0) ) - self.image_recognition = image_recognition + self.data = data + self.image_recognition = 'projector_info' in self.data class model_selector_button(Gtk.MenuButton): __gtype_name__ = 'AlpacaModelSelectorButton' @@ -109,16 +110,16 @@ class model_selector_button(Gtk.MenuButton): window.model_manager.verify_if_image_can_be_used() def add_model(self, model_name:str): - vision = False + data = None response = window.ollama_instance.request("POST", "api/show", json.dumps({"name": model_name})) if response.status_code != 200: logger.error(f"Status code was {response.status_code}") return try: - vision = 'projector_info' in json.loads(response.text) + data = json.loads(response.text) except Exception as e: - logger.error(f"Error fetching vision info: {str(e)}") - model_row = model_selector_row(model_name, vision) + logger.error(f"Error fetching 'api - show' info: {str(e)}") + model_row = model_selector_row(model_name, data) GLib.idle_add(self.get_popover().model_list_box.append, model_row) GLib.idle_add(self.change_model, model_name) @@ -248,6 +249,37 @@ class pulling_model_list(Gtk.ListBox): visible=False ) +class information_bow(Gtk.Box): + __gtype_name__ = 'AlpacaModelInformationBow' + + def __init__(self, title:str, subtitle:str): + self.title = title + self.subtitle = subtitle + title_label = Gtk.Label( + label=self.title, + css_classes=['subtitle', 'caption'], + hexpand=True, + margin_top=10, + margin_start=0, + margin_end=0 + ) + subtitle_label = Gtk.Label( + label=self.subtitle if self.subtitle else '(none)', + css_classes=['heading'], + hexpand=True, + margin_bottom=10, + margin_start=0, + margin_end=0 + ) + super().__init__( + spacing=5, + orientation=1, + css_classes=['card'] + ) + self.append(title_label) + self.append(subtitle_label) + + class local_model(Gtk.ListBoxRow): __gtype_name__ = 'AlpacaLocalModel' @@ -275,6 +307,16 @@ class local_model(Gtk.ListBoxRow): description_box.append(model_label) description_box.append(tag_label) + info_button = Gtk.Button( + icon_name = "info-outline-symbolic", + vexpand = False, + valign = 3, + css_classes = ["circular"], + tooltip_text = _("Details") + ) + + info_button.connect('clicked', self.show_information) + delete_button = Gtk.Button( icon_name = "user-trash-symbolic", vexpand = False, @@ -302,6 +344,7 @@ class local_model(Gtk.ListBoxRow): margin_end=10 ) container_box.append(description_box) + container_box.append(info_button) container_box.append(delete_button) super().__init__( @@ -309,6 +352,51 @@ class local_model(Gtk.ListBoxRow): name=model_name ) + def show_information(self, button): + model = next((element for element in list(window.model_manager.model_selector.get_popover().model_list_box) if element.get_name() == self.get_name()), None) + model_name = model.get_child().get_label() + + window.model_detail_page.set_title(' ('.join(model_name.split(' (')[:-1])) + window.model_detail_page.set_description(' ('.join(model_name.split(' (')[-1:])[:-1]) + + details_flow_box = Gtk.FlowBox( + valign=1, + hexpand=True, + vexpand=False, + selection_mode=0, + max_children_per_line=2, + min_children_per_line=1, + margin_top=12, + margin_bottom=12, + margin_start=12, + margin_end=12 + ) + + translation_strings={ + 'modified_at': _('Modified At'), + 'parent_model': _('Parent Model'), + 'format': _('Format'), + 'family': _('Family'), + 'parameter_size': _('Parameter Size'), + 'quantization_level': _('Quantization Level') + } + + if 'modified_at' in model.data and model.data['modified_at']: + details_flow_box.append(information_bow( + title=translation_strings['modified_at'], + subtitle=datetime.datetime.strptime(':'.join(model.data['modified_at'].split(':')[:-1]), '%Y-%m-%dT%H:%M').strftime('%Y-%m-%d %H:%M') + )) + + for name, value in model.data['details'].items(): + if isinstance(value, str): + details_flow_box.append(information_bow( + title=translation_strings[name] if name in translation_strings else name.replace('_', ' ').title(), + subtitle=value + )) + + window.model_detail_page.set_child(details_flow_box) + window.navigation_view_manage_models.push_by_tag('model_information') + class local_model_list(Gtk.ListBox): __gtype_name__ = 'AlpacaLocalModelList' diff --git a/src/icons/info-outline-symbolic.svg b/src/icons/info-outline-symbolic.svg new file mode 100644 index 0000000..254e7e8 --- /dev/null +++ b/src/icons/info-outline-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/src/window.py b/src/window.py index b824186..452dff8 100644 --- a/src/window.py +++ b/src/window.py @@ -102,6 +102,7 @@ class AlpacaWindow(Adw.ApplicationWindow): title_stack = Gtk.Template.Child() manage_models_dialog = Gtk.Template.Child() model_scroller = Gtk.Template.Child() + model_detail_page = Gtk.Template.Child() chat_list_container = Gtk.Template.Child() chat_list_box = None @@ -607,6 +608,7 @@ Generate a title following these rules: self.chat_list_box.prepend_chat(_("New Chat")) + def generate_numbered_name(self, chat_name:str, compare_list:list) -> str: if chat_name in compare_list: for i in range(len(compare_list)): diff --git a/src/window.ui b/src/window.ui index 42962d1..6baba95 100644 --- a/src/window.ui +++ b/src/window.ui @@ -6,7 +6,7 @@ True 400 - 400 + 600 1300 800 Alpaca @@ -637,6 +637,36 @@ + + + Model Details + model_information + + + + + + + + + + true + true + + + brain-augemnted-symbolic + text + + + + + + + + + Create Model