@@ -100,6 +100,32 @@ def __init__(self, instance, base_source:str=None, using_gguf:bool=False):
100100 )
101101 pg .add (context_sw )
102102
103+ pg = Adw .PreferencesGroup (
104+ title = _ ('Template' ),
105+ description = _ ("Some GGUF models require a template, please check the model's documentation for more information." ),
106+ #visible=self.using_gguf
107+ )
108+ pp .add (pg )
109+
110+ #TEMPLATE
111+ self .template_element = Gtk .TextView (
112+ wrap_mode = 3 ,
113+ accepts_tab = False ,
114+ overflow = 1 ,
115+ vexpand = True ,
116+ css_classes = ['p10' , 'modelfile_textview' ]
117+ )
118+
119+ template_sw = Gtk .ScrolledWindow (
120+ min_content_height = 100 ,
121+ vexpand = True ,
122+ propagate_natural_height = True ,
123+ child = self .template_element ,
124+ overflow = 1 ,
125+ css_classes = ['card' , 'undershoot-bottom' ]
126+ )
127+ pg .add (template_sw )
128+
103129 pg = Adw .PreferencesGroup (
104130 title = _ ('Behavior' )
105131 )
@@ -279,9 +305,12 @@ def save(self):
279305 for attachment in self .context_attachment_container .get_content ():
280306 system_message .append ('```{}\n {}\n ```' .format (attachment .get ('name' ), attachment .get ('content' ).strip ()))
281307
282- system_message .append (context_buffer .get_text (context_buffer .get_start_iter (), context_buffer .get_end_iter (), False ).replace ('"' , '\\ "' ))
308+ system_message .append (context_buffer .get_text (context_buffer .get_start_iter (), context_buffer .get_end_iter (), False ).replace ('"' , '\\ "' ). strip () )
283309 system_message = '\n \n ' .join (system_message ).strip ()
284310
311+ template_buffer = self .template_element .get_buffer ()
312+ template_text = template_buffer .get_text (template_buffer .get_start_iter (), template_buffer .get_end_iter (), False ).replace ('"' , '\\ "' ).strip ()
313+
285314 top_k = self .imagination_element .get_value ()
286315 top_p = self .focus_element .get_value () / 100
287316 num_ctx = self .num_ctx_element .get_value ()
@@ -299,6 +328,7 @@ def save(self):
299328 'top_p' : top_p ,
300329 'num_ctx' : num_ctx
301330 },
331+ "template" : template_text ,
302332 'stream' : True
303333 }
304334
0 commit comments