Skip to content

bradfair/chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Module

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.

Installation

To install this module, run the following command:

go get github.com/bradfair/chat

Usage

Below is a brief overview of each package. For more detailed information, see the READMEs in each package's directory.

Conversation Package

The conversation package provides a Conversation struct with relevant methods/functions to create and manipulate conversations.

Message Package

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.

License

This module is licensed under the MIT License. See LICENSE for more information.

About

Simplify OpenAI chat conversations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages