OpenAnima 0.2.0
Middleware for conversational NPCs that interact with the player, the world and each other
Loading...
Searching...
No Matches
Public Types | Static Public Member Functions | Public Attributes | List of all members
OpenAnima::Core::ResponseFormat Struct Reference

#include <ResponseFormat.h>

Public Types

enum class  Kind : std::uint8_t { Text , JsonObject , JsonSchema }
 The shapes an answer can be asked for in. More...
 

Static Public Member Functions

static ResponseFormat text ()
 
static ResponseFormat jsonObject ()
 
static ResponseFormat jsonSchema (nlohmann::json schema)
 

Public Attributes

Kind kind {Kind::Text}
 Which of the three is being asked for.
 
nlohmann::json schema
 The schema, used when the kind is JsonSchema.
 

Detailed Description

What a caller expects the model to answer with.

The chat-completions contract spells this as response_format, and a server that does not know the field ignores it. What arrives is then checked here instead: as soon as a shape other than text is asked for, the answer is read as JSON, and an answer that is not JSON is a ParseError rather than something the caller has to discover.

Member Enumeration Documentation

◆ Kind

enum class OpenAnima::Core::ResponseFormat::Kind : std::uint8_t
strong

The shapes an answer can be asked for in.

Enumerator
Text 

Free text, which is what a caller that asks for nothing gets.

JsonObject 

A JSON object, with no contract on what it holds.

JsonSchema 

A JSON object that follows a schema, which is sent with the request.

Member Function Documentation

◆ jsonObject()

static ResponseFormat OpenAnima::Core::ResponseFormat::jsonObject ( )
inlinestatic
Returns
A JSON object, with no contract on what it holds.

References JsonObject.

◆ jsonSchema()

static ResponseFormat OpenAnima::Core::ResponseFormat::jsonSchema ( nlohmann::json  schema)
inlinestatic
Parameters
schemaJSON Schema the answer has to follow, sent as it is given.
Returns
An answer shaped by that schema.

References JsonSchema, and schema.

◆ text()

static ResponseFormat OpenAnima::Core::ResponseFormat::text ( )
inlinestatic
Returns
Free text, which is what a caller that asks for nothing gets.

The documentation for this struct was generated from the following file: