Module cordyceps_api::chat
source · Expand description
Chat
The chat module contains the required data structures for OpenAi's Chat Completion
This can also be used as documentation for OpenAi’s streaming chat completions API that they
must have forgotten to document.
Response usage
The Response
is used to be Deserialized from JSON. Sometimes OpenAi doesn’t like
to follow the JSON spec so I recommend using the serde_jsonrc
crate for a more lenient JSON deserialization.
Structs
- I don’t know what OpenAi was on when they designed this, but the response content is stored in this struct. See
Choice
for why this is dumb. - Messages are used to prompt the chosen model. Used to assign content to the
Role
. - The payload contains all of the data needed to complete a chat. See
OpenAi's Completion Documentation
for more information on each field’s meaning It’s not recommended to construct this directly. SeePayloadBuilder
for intended usage. - Recommended contructor for payloads. The only required field is
messages
which have several methods for setting.
Enums
- When streaming, OpenAI will return the state of the stream in this enum. These are effectively useless as the response from the client can be iterated over.
- The models available to use for chat completions.
- Roles for chat completions.
Constants
- The API_URL is a public constant unique to each feature’s module.