conversation

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

SeparatorStyle

Separator styles.

Conversation

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

Functions

register_conv_template(template[, override])

Register a new conversation template.

get_conv_template(→ Conversation)

Get a conversation template.

Module Contents

class conversation.SeparatorStyle[source]

Separator styles.

class conversation.Conversation[source]

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

get_prompt() str[source]

Get the prompt for generation.

set_system_message(system_message: str)[source]

Set the system message.

append_message(role: str, message: str)[source]

Append a new message.

update_last_message(message: str)[source]

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.

convert_image_to_base64(image)[source]

Given an image, return the base64 encoded image string.

to_gradio_chatbot()[source]

Convert the conversation to gradio chatbot format.

to_openai_api_messages()[source]

Convert the conversation to OpenAI chat completion format.

conversation.register_conv_template(template: Conversation, override: bool = False)[source]

Register a new conversation template.

conversation.get_conv_template(name: str) Conversation[source]

Get a conversation template.