Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b82b0e1

Browse filesBrowse files
committed
docs: Temporarily revert function calling docs
1 parent cb79171 commit b82b0e1
Copy full SHA for b82b0e1

File tree

Expand file treeCollapse file tree

1 file changed

+13
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-9
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
+13-9Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -292,18 +292,22 @@ To constrain the response to a specific JSON Schema, you can use the `schema` pr
292292

293293
### Function Calling
294294

295-
The high-level API also provides a simple interface for function calling.
295+
The high-level API also provides a simple interface for function calling. This is possible through the `functionary` pre-trained models chat format or through the generic `chatml-function-calling` chat forma.
296296

297-
The only set of models that supports full function calling at this time is [functionary](https://github.com/MeetKai/functionary). The various gguf-converted files for this set of models can be found [here](https://huggingface.co/meetkai). Functionary is able to intelligently call functions and also analyze any provided function outputs to generate coherent responses. All v2 models of functionary supports **parallel function calling**. You can provide either `functionary-v1` or `functionary-v2` for the `chat_format` when initializing the Llama class.
298-
299-
Note that due to discrepancies between llama.cpp and HuggingFace's tokenizers, it is required to provide HF Tokenizer for functionary. The `LlamaHFTokenizer` class can be initialized and passed into the Llama class. This will override the default llama.cpp tokenizer used in Llama class. The tokenizer files are already included in the respective HF repositories hosting the gguf files.
297+
The gguf-converted files for functionary can be found here: [functionary-7b-v1](https://huggingface.co/abetlen/functionary-7b-v1-GGUF)
300298

301299
```python
302-
>>> from llama_cpp import Llama, LlamaHFTokenizer
303-
>>> tokenizer = LlamaHFTokenizer.from_pretrained("path/to/functionary/")
304-
>>> llm = Llama(model_path="path/to/functionary/llama-model.gguf", tokenizer=tokenizer, chat_format="functionary-v2")
300+
>>> from llama_cpp import Llama
301+
>>> llm = Llama(model_path="path/to/functionary/llama-model.gguf", chat_format="functionary")
302+
>>> # or
303+
>>> llm = Llama(model_path="path/to/chatml/llama-model.gguf", chat_format="chatml-function-calling")
305304
>>> llm.create_chat_completion(
306305
messages = [
306+
{
307+
"role": "system",
308+
"content": "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. The assistant calls functions with appropriate input when necessary"
309+
310+
},
307311
{
308312
"role": "user",
309313
"content": "Extract Jason is 25 years old"
@@ -330,12 +334,12 @@ Note that due to discrepancies between llama.cpp and HuggingFace's tokenizers, i
330334
}
331335
}
332336
}],
333-
tool_choice={
337+
tool_choice=[{
334338
"type": "function",
335339
"function": {
336340
"name": "UserDetail"
337341
}
338-
},
342+
}]
339343
)
340344
```
341345

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.