> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# llama_cpp

> <a href="https://github.com/pixeltable/pixeltable/blob/main/pixeltable/functions/llama_cpp.py#L0" id="viewSource" target="_blank" rel="noopener noreferrer"><img src="https://img.shields.io/badge/View%20Source%20on%20Github-blue?logo=github&labelColor=gray" alt="View Source on GitHub" style={{ display: 'inline', margin: '0px' }} noZoom /></a>

# <span style={{ 'color': 'gray' }}>module</span>  pixeltable.functions.llama\_cpp

Pixeltable UDFs for llama.cpp models.

Provides integration with llama.cpp for running quantized language models locally,
supporting chat completions and embeddings with GGUF format models.

## <span style={{ 'color': 'gray' }}>udf</span>  create\_chat\_completion()

```python Signature theme={"theme":{"light":"light-plus","dark":"dark-plus"}}
@pxt.udf
create_chat_completion(
    messages: pxt.Json[(Json, ...)],
    *,
    model_path: pxt.String | None = None,
    repo_id: pxt.String | None = None,
    repo_filename: pxt.String | None = None,
    chat_format: pxt.String | None = None,
    tools: pxt.Json[(Json, ...)] | None = None,
    tool_choice: pxt.Json | None = None,
    model_kwargs: pxt.Json | None = None
) -> pxt.Json
```

Generate a chat completion from a list of messages.

The model can be specified either as a local path, or as a repo\_id and repo\_filename that reference a pretrained
model on the Hugging Face model hub. Exactly one of `model_path` or `repo_id` must be provided; if `model_path`
is provided, then an optional `repo_filename` can also be specified.

For additional details, see the
[llama\_cpp create\_chat\_completion documentation](https://llama-cpp-python.readthedocs.io/en/latest/api-reference/#llama_cpp.Llama.create_chat_completion).

**Parameters:**

* **`messages`** (`pxt.Json[(Json`): A list of messages to generate a response for.
* **`model_path`** (`Any`): Path to the model (if using a local model).
* **`repo_id`** (`Any`): The Hugging Face model repo id (if using a pretrained model).
* **`repo_filename`** (`Any`): A filename or glob pattern to match the model file in the repo (optional, if using a
  pretrained model).
* **`chat_format`** (`Any`): An optional string specifying the chat format to use with the model.
* **`tools`** (`Any`): An optional list of tools (functions) the model may call, specified as `pxt.func.tools.Tools`.
* **`tool_choice`** (`Any`): An optional `pxt.func.tools.ToolChoice` controlling which tool(s) the model should use.
* **`model_kwargs`** (`Any`): Additional keyword args for the llama\_cpp `create_chat_completion` API, such as `max_tokens`,
  `temperature`, `top_p`, and `top_k`. For details, see the
  [llama\_cpp create\_chat\_completion documentation](https://llama-cpp-python.readthedocs.io/en/latest/api-reference/#llama_cpp.Llama.create_chat_completion).
