This module is designed to make it easy to represent and work with conversations in Golang. It consists of two packages: conversation, and message.
A conversation is an ordered collection of messages. A message is a string of text (the content) that is associated with its sender (the role). Since OpenAI prices their API usage based on the combined number of tokens in a request/completion, messages can make use of a tokenizer to convert their content into a list of integers (tokens). The Conversation struct contains a helper method to count the total number of tokens in a conversation.
To install this module, run the following command:
go get github.com/bradfair/chat
Below is a brief overview of each package. For more detailed information, see the READMEs in each package's directory.
The conversation package provides a Conversation struct with relevant methods/functions to create and manipulate conversations.
The message package provides a Message struct with relevant methods/functions to create and manipulate messages. It also defines a Tokenizer interface and provides a TokenizerFunc type in order to satisfy the Tokenizer interface using custom functions. This allows you to use your own tokenizer function, or one of the small number of available open-source tokenizers.
This module is licensed under the MIT License. See LICENSE for more information.