Przeglądaj źródła

gguf-py : allow key override when adding value to GGUFWriter (#14194)

Co-authored-by: dinhhuy <huy.dinh@brains-tech.co.jp>
Đinh Trọng Huy 7 miesięcy temu
rodzic
commit
4ad243677b
1 zmienionych plików z 1 dodań i 1 usunięć
  1. 1 1
      gguf-py/gguf/gguf_writer.py

+ 1 - 1
gguf-py/gguf/gguf_writer.py

@@ -271,7 +271,7 @@ class GGUFWriter:
 
 
     def add_key_value(self, key: str, val: Any, vtype: GGUFValueType, sub_type: GGUFValueType | None = None) -> None:
     def add_key_value(self, key: str, val: Any, vtype: GGUFValueType, sub_type: GGUFValueType | None = None) -> None:
         if any(key in kv_data for kv_data in self.kv_data):
         if any(key in kv_data for kv_data in self.kv_data):
-            raise ValueError(f'Duplicated key name {key!r}')
+            logger.warning(f'Duplicated key name {key!r}, overwriting it with new value {val!r} of type {vtype.name}')
 
 
         self.kv_data[0][key] = GGUFValue(value=val, type=vtype, sub_type=sub_type)
         self.kv_data[0][key] = GGUFValue(value=val, type=vtype, sub_type=sub_type)