You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you run into issues where it complains it can't find `'nmake'``'?'` or CMAKE_C_COMPILER, you can extract w64devkit as [mentioned in llama.cpp repo](https://github.com/ggerganov/llama.cpp#openblas) and add those manually to CMAKE_ARGS before running `pip` install:
{"role": "system", "content": "You are an assistant who perfectly describes images."},
@@ -205,6 +224,59 @@ Note that `chat_format` option must be set for the particular model you are usin
205
224
206
225
Chat completion is available through the [`create_chat_completion`](https://llama-cpp-python.readthedocs.io/en/latest/api-reference/#llama_cpp.Llama.create_chat_completion) method of the [`Llama`](https://llama-cpp-python.readthedocs.io/en/latest/api-reference/#llama_cpp.Llama) class.
207
226
227
+
### JSON and JSON Schema Mode
228
+
229
+
If you want to constrain chat responses to only valid JSON or a specific JSON Schema you can use the `response_format` argument to the `create_chat_completion` method.
230
+
231
+
#### JSON Mode
232
+
233
+
The following example will constrain the response to be valid JSON.
"content": "You are a helpful assistant that outputs in JSON.",
265
+
},
266
+
{"role": "user", "content": "Who won the world series in 2020"},
267
+
],
268
+
response_format={
269
+
"type": "json_object",
270
+
"schema": {
271
+
"type": "object",
272
+
"properties": {"team_name": {"type": "string"}},
273
+
"required": ["team_name"],
274
+
},
275
+
},
276
+
temperature=0.7,
277
+
)
278
+
```
279
+
208
280
### Function Calling
209
281
210
282
The high-level API also provides a simple interface for function calling.
@@ -410,6 +482,9 @@ pip install -e .[all]
410
482
make clean
411
483
```
412
484
485
+
You can also test out specific commits of `lama.cpp` by checking out the desired commit in the `vendor/llama.cpp` submodule and then running `make clean` and `pip install -e .` again. Any changes in the `llama.h` API will require
486
+
changes to the `llama_cpp/llama_cpp.py` file to match the new API (additional changes may be required elsewhere).
487
+
413
488
#
1241
# FAQ
414
489
415
490
### Are there pre-built binaries / binary wheels available?
0 commit comments