Fixed models with '-' in their names don't work

This commit is contained in:
jeffser 2024-07-23 19:16:40 -06:00
parent 976fe138f7
commit a56631510d

View File

@ -184,7 +184,7 @@ class AlpacaWindow(Adw.ApplicationWindow):
self.chats['order'].insert(0, self.chats['selected_chat']) self.chats['order'].insert(0, self.chats['selected_chat'])
self.save_history() self.save_history()
current_model = self.model_drop_down.get_selected_item().get_string() current_model = self.model_drop_down.get_selected_item().get_string()
current_model = current_model.replace(' (', ':')[:-1].lower() current_model = current_model.replace(' (', ':').replace(' ', '-')[:-1].lower()
if current_model is None: if current_model is None:
self.show_toast(_("Please select a model before chatting"), self.main_overlay) self.show_toast(_("Please select a model before chatting"), self.main_overlay)
return return
@ -572,10 +572,12 @@ Generate a title following these rules:
{message['content']} {message['content']}
```""" ```"""
current_model = self.model_drop_down.get_selected_item().get_string() current_model = self.model_drop_down.get_selected_item().get_string()
current_model = current_model.replace(' (', ':')[:-1].lower() current_model = current_model.replace(' (', ':').replace(' ', '-')[:-1].lower()
data = {"model": current_model, "prompt": prompt, "stream": False} data = {"model": current_model, "prompt": prompt, "stream": False}
if 'images' in message: data["images"] = message['images'] if 'images' in message: data["images"] = message['images']
print(current_model)
response = connection_handler.simple_post(f"{connection_handler.url}/api/generate", data=json.dumps(data)) response = connection_handler.simple_post(f"{connection_handler.url}/api/generate", data=json.dumps(data))
new_chat_name = json.loads(response.text)["response"].strip().removeprefix("Title: ").removeprefix("title: ").strip('\'"').title() new_chat_name = json.loads(response.text)["response"].strip().removeprefix("Title: ").removeprefix("title: ").strip('\'"').title()
new_chat_name = new_chat_name[:50] + (new_chat_name[50:] and '...') new_chat_name = new_chat_name[:50] + (new_chat_name[50:] and '...')
self.rename_chat(label_element.get_name(), new_chat_name, label_element) self.rename_chat(label_element.get_name(), new_chat_name, label_element)