Skip to content

Commit

Permalink
docs: pydantic hint, make preview
Browse files Browse the repository at this point in the history
  • Loading branch information
zhudotexe committed Sep 5, 2023
1 parent 087aaa5 commit 3ccb737
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ help:

.PHONY: help Makefile

# make html and then open it in the browser
preview: html
open "$(BUILDDIR)/html/index.html"

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
Expand Down
6 changes: 6 additions & 0 deletions docs/customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ For example, here's how you might extend :meth:`.Kani.add_to_history` to log eve
This example is available in the
`GitHub repo <https://github.com/zhudotexe/kani/blob/main/examples/3_customization_log_messages.py>`__.

.. hint::
kani's :class:`.ChatMessage`\ s are `Pydantic models <https://docs.pydantic.dev/latest/usage/models/>`_
under the hood - which means they come with utilities for serialization and deserialization!

.. code-block:: python
class LogMessagesKani(Kani):
Expand Down Expand Up @@ -132,6 +136,8 @@ If we chat with this kani and then read ``kani-log.jsonl``, we can see that it l
{"role":"user","content":"Just saying hi!","name":null,"function_call":null}
{"role":"assistant","content":"Hi! It's great to have you here.","name":null,"function_call":null}
This kind of logging isn't just limited to chatting - this example will also log any function calls and retries.

.. _do_function_call:

Handle a Function Call
Expand Down

0 comments on commit 3ccb737

Please sign in to comment.