Buckets:
| """Experimental bindings for non-public llama.cpp APIs from `llama-ext.h`. | |
| This module is not part of the stable llama-cpp-python public API. | |
| Downstream code should not import or depend on it directly. | |
| """ | |
| from __future__ import annotations | |
| import ctypes | |
| import functools | |
| from typing import Any, Iterable, Union | |
| from . import llama_cpp | |
| _lib = llama_cpp._lib | |
| def _ctypes_function_from_names( | |
| names: Iterable[str], | |
| argtypes: list[Any], | |
| restype: Any, | |
| ): | |
| """Decorator for extension functions whose exported symbol name can vary by ABI.""" | |
| def decorator(f): | |
| missing: list[str] = [] | |
| for name in names: | |
| try: | |
| func = getattr(_lib, name) | |
| except AttributeError: | |
| missing.append(name) | |
| continue | |
| func.argtypes = argtypes | |
| func.restype = restype | |
| functools.wraps(f)(func) | |
| return func | |
| raise AttributeError( | |
| f"None of the shared library symbols were found: {', '.join(missing)}" | |
| ) | |
| return decorator | |
| # LLAMA_API void llama_set_embeddings_nextn(struct llama_context * ctx, bool value, bool masked); | |
| def llama_set_embeddings_nextn( | |
| ctx: llama_cpp.llama_context_p, | |
| value: bool, | |
| masked: bool, | |
| /, | |
| ): | |
| """Set whether the context outputs nextn embeddings or not.""" | |
| ... | |
| # LLAMA_API float * llama_get_embeddings_nextn(struct llama_context * ctx); | |
| def llama_get_embeddings_nextn( | |
| ctx: llama_cpp.llama_context_p, | |
| /, | |
| ): | |
| """Get the nextn embeddings from the last evaluation.""" | |
| ... | |
| # LLAMA_API float * llama_get_embeddings_nextn_ith(struct llama_context * ctx, int32_t i); | |
| def llama_get_embeddings_nextn_ith( | |
| ctx: llama_cpp.llama_context_p, | |
| i: Union[ctypes.c_int32, int], | |
| /, | |
| ): | |
| """Get the nextn embeddings for the ith output row from the last evaluation.""" | |
| ... | |
| # LLAMA_API llama_context * llama_get_ctx_other(struct llama_context * ctx); | |
| def llama_get_ctx_other( | |
| ctx: llama_cpp.llama_context_p, | |
| /, | |
| ): | |
| """Get the context linked through llama_context_params.ctx_other.""" | |
| ... | |
Xet Storage Details
- Size:
- 3.28 kB
- Xet hash:
- 311bd7fceb4c1441d06852a117156b1e02b91539362e87e1e1cf804b5ad4dc96
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.