@@ -1712,6 +1712,93 @@ def llama_adapter_lora_init(
17121712 ...
17131713
17141714
1715+ # // Functions to access the adapter's GGUF metadata scalar values
1716+ # // - The functions return the length of the string on success, or -1 on failure
1717+ # // - The output string is always null-terminated and cleared on failure
1718+ # // - When retrieving a string, an extra byte must be allocated to account for the null terminator
1719+ # // - GGUF array values are not supported by these functions
1720+
1721+ # // Get metadata value as a string by key name
1722+ # LLAMA_API int32_t llama_adapter_meta_val_str(const struct llama_adapter_lora * adapter, const char * key, char * buf, size_t buf_size);
1723+ @ctypes_function (
1724+ "llama_adapter_meta_val_str" ,
1725+ [
1726+ llama_adapter_lora_p_ctypes ,
1727+ ctypes .c_char_p ,
1728+ ctypes .c_char_p ,
1729+ ctypes .c_size_t ,
1730+ ],
1731+ ctypes .c_int32 ,
1732+ )
1733+ def llama_adapter_meta_val_str (
1734+ adapter : llama_adapter_lora_p ,
1735+ key : ctypes .c_char_p ,
1736+ buf : ctypes .c_char_p ,
1737+ buf_size : ctypes .c_size_t ,
1738+ / ,
1739+ ) -> int :
1740+ """Get metadata value as a string by key name"""
1741+ ...
1742+
1743+
1744+ # // Get the number of metadata key/value pairs
1745+ # LLAMA_API int32_t llama_adapter_meta_count(const struct llama_adapter_lora * adapter);
1746+ @ctypes_function (
1747+ "llama_adapter_meta_count" ,
1748+ [llama_adapter_lora_p_ctypes ],
1749+ ctypes .c_int32 ,
1750+ )
1751+ def llama_adapter_meta_count (adapter : llama_adapter_lora_p ) -> int :
1752+ """Get the number of metadata key/value pairs"""
1753+ ...
1754+
1755+
1756+ # // Get metadata key name by index
1757+ # LLAMA_API int32_t llama_adapter_meta_key_by_index(const struct llama_adapter_lora * adapter, int32_t i, char * buf, size_t buf_size);
1758+ @ctypes_function (
1759+ "llama_adapter_meta_key_by_index" ,
1760+ [
1761+ llama_adapter_lora_p_ctypes ,
1762+ ctypes .c_int32 ,
1763+ ctypes .c_char_p ,
1764+ ctypes .c_size_t ,
1765+ ],
1766+ ctypes .c_int32 ,
1767+ )
1768+ def llama_adapter_meta_key_by_index (
1769+ adapter : llama_adapter_lora_p ,
1770+ i : ctypes .c_int32 ,
1771+ buf : ctypes .c_char_p ,
1772+ buf_size : ctypes .c_size_t ,
1773+ / ,
1774+ ) -> int :
1775+ """Get metadata key name by index"""
1776+ ...
1777+
1778+
1779+ # // Get metadata value as a string by index
1780+ # LLAMA_API int32_t llama_adapter_meta_val_str_by_index(const struct llama_adapter_lora * adapter, int32_t i, char * buf, size_t buf_size);
1781+ @ctypes_function (
1782+ "llama_adapter_meta_val_str_by_index" ,
1783+ [
1784+ llama_adapter_lora_p_ctypes ,
1785+ ctypes .c_int32 ,
1786+ ctypes .c_char_p ,
1787+ ctypes .c_size_t ,
1788+ ],
1789+ ctypes .c_int32 ,
1790+ )
1791+ def llama_adapter_meta_val_str_by_index (
1792+ adapter : llama_adapter_lora_p ,
1793+ i : ctypes .c_int32 ,
1794+ buf : ctypes .c_char_p ,
1795+ buf_size : ctypes .c_size_t ,
1796+ / ,
1797+ ) -> int :
1798+ """Get metadata value as a string by index"""
1799+ ...
1800+
1801+
17151802# // Manually free a LoRA adapter
17161803# // Note: loaded adapters will be free when the associated model is deleted
17171804# LLAMA_API void llama_adapter_lora_free(struct llama_adapter_lora * adapter);
0 commit comments