conversation
============

.. py:module:: conversation

.. autoapi-nested-parse::

   Conversation prompt templates.

   We kindly request that you import fastchat instead of copying this file if you wish to use it.
   If you have any changes in mind, please contribute back so the community can benefit collectively and continue to maintain these valuable templates.



Classes
-------

.. autoapisummary::

   conversation.SeparatorStyle
   conversation.Conversation


Functions
---------

.. autoapisummary::

   conversation.register_conv_template
   conversation.get_conv_template


Module Contents
---------------

.. py:class:: SeparatorStyle



   Separator styles.


.. py:class:: Conversation

   A class that manages prompt templates and keeps all conversation history.


   .. py:method:: get_prompt() -> str

      Get the prompt for generation.



   .. py:method:: set_system_message(system_message: str)

      Set the system message.



   .. py:method:: append_message(role: str, message: str)

      Append a new message.



   .. py:method:: update_last_message(message: str)

      Update the last output.

      The last message is typically set to be None when constructing the prompt,
      so we need to update it in-place after getting the response from a model.



   .. py:method:: convert_image_to_base64(image)

      Given an image, return the base64 encoded image string.



   .. py:method:: to_gradio_chatbot()

      Convert the conversation to gradio chatbot format.



   .. py:method:: to_openai_api_messages()

      Convert the conversation to OpenAI chat completion format.



.. py:function:: register_conv_template(template: Conversation, override: bool = False)

   Register a new conversation template.


.. py:function:: get_conv_template(name: str) -> Conversation

   Get a conversation template.