@@ -1497,22 +1497,9 @@ def save_file(self):
14971497 if field :
14981498 arch = field .contents ()
14991499
1500- # Determine endianness
1501- if np .uint32 (1 ) == np .uint32 (1 ).newbyteorder ("<" ):
1502- # Host is little endian
1503- host_endian = gguf .GGUFEndian .LITTLE
1504- swapped_endian = gguf .GGUFEndian .BIG
1505- else :
1506- host_endian = gguf .GGUFEndian .BIG
1507- swapped_endian = gguf .GGUFEndian .LITTLE
1508-
1509- if self .reader .byte_order == "S" :
1510- endianess = swapped_endian
1511- else :
1512- endianess = host_endian
1513-
15141500 # Create writer
1515- writer = GGUFWriter (file_path , arch = arch , endianess = endianess )
1501+ writer = GGUFWriter (file_path , arch = arch , endianess = self .reader .endianess )
1502+
15161503
15171504 # Get alignment if present
15181505 alignment = None
@@ -1594,31 +1581,6 @@ def save_file(self):
15941581 QMessageBox .critical (self , "Error" , f"Failed to save file: { str (e )} " )
15951582 self .statusBar ().showMessage ("Error saving file" )
15961583
1597- def decode_field (self , field : ReaderField ) -> Any :
1598- if field and field .types :
1599- main_type = field .types [0 ]
1600-
1601- if main_type == GGUFValueType .ARRAY :
1602- sub_type = field .types [- 1 ]
1603-
1604- if sub_type == GGUFValueType .STRING :
1605- return [str (bytes (field .parts [idx ]), encoding = 'utf-8' ) for idx in field .data ]
1606- else :
1607- values = [pv for idx in field .data for pv in field .parts [idx ].tolist ()]
1608-
1609- # Special handling for token types
1610- if field .name == gguf .Keys .Tokenizer .TOKEN_TYPE and sub_type == GGUFValueType .INT32 :
1611- # Return the raw values, they'll be converted to TokenType when needed
1612- return values
1613- return values
1614-
1615- if main_type == GGUFValueType .STRING :
1616- return str (bytes (field .parts [- 1 ]), encoding = 'utf-8' )
1617- else :
1618- return field .parts [- 1 ][0 ]
1619-
1620- return None
1621-
16221584
16231585def main () -> None :
16241586 parser = argparse .ArgumentParser (description = "GUI GGUF Editor" )
0 commit comments