OpenAnima 0.2.0
Middleware for conversational NPCs that interact with the player, the world and each other
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions
OpenAnima::Core Namespace Reference

The agent and the vocabulary of a conversation. More...

Classes

class  ActionCatalogue
 
struct  ActionSpec
 One action an NPC may ask the host application to take. More...
 
struct  ChatMessage
 A single message exchanged with a language-model provider. More...
 
struct  Completion
 
struct  Event
 
struct  NpcAction
 One thing an NPC asks the host application to do. More...
 
class  NPCBrain
 One NPC: its persona, its memory and the conversation it is having. More...
 
struct  NpcReply
 
struct  ResponseFormat
 
struct  TokenUsage
 Tokens billed for one exchange. More...
 

Typedefs

using RequestId = std::uint64_t
 Names a turn that was handed to a brain and not collected yet.
 

Enumerations

enum class  FinishReason : std::uint8_t {
  Unknown , Stop , Length , ToolCalls ,
  ContentFilter , Cancelled
}
 Why a provider stopped generating. More...
 
enum class  EventKind : std::uint8_t { Started , Delta , Finished , Failed }
 What an event reports, in the order the events of one turn arrive. More...
 
enum class  Role : std::uint8_t { System , User , Assistant , Tool }
 Identifies the author of a ChatMessage. More...
 

Functions

NpcReply readReply (const Completion &completion, const std::string &partialDialogue={})
 

Detailed Description

The agent and the vocabulary of a conversation.

Messages, roles, the answer a provider returns, the events a turn reports, and the brain that keeps the history and drives the exchange.

Enumeration Type Documentation

◆ EventKind

enum class OpenAnima::Core::EventKind : std::uint8_t
strong

What an event reports, in the order the events of one turn arrive.

Enumerator
Started 

The turn left the queue and the backend is working on it.

Delta 

A piece of the answer. The whole answer is not ready yet.

Finished 

The turn is over and completion holds the answer.

Failed 

The turn could not be made and error says why.

◆ FinishReason

enum class OpenAnima::Core::FinishReason : std::uint8_t
strong

Why a provider stopped generating.

Enumerator
Unknown 

Not reported, or a value this library does not model.

Stop 

Natural end, or a stop sequence was reached.

Length 

The token budget ran out before the answer finished.

ToolCalls 

The model asked for a tool instead of answering.

ContentFilter 

The provider withheld or trimmed the answer.

Cancelled 

The caller stopped the call; the text is what it had produced.

◆ Role

enum class OpenAnima::Core::Role : std::uint8_t
strong

Identifies the author of a ChatMessage.

Enumerator
System 

Instruction or persona injected by the client application.

User 

Input coming from a human or from the client system.

Assistant 

Text generated by the language model.

Tool 

Result returned by an external tool invocation.

Function Documentation

◆ readReply()

NpcReply OpenAnima::Core::readReply ( const Completion &  completion,
const std::string &  partialDialogue = {} 
)

Reads a reply out of an answer asked for with a reply schema.

Parameters
completionAnswer as the provider reported it.
partialDialogueDialogue read from the answer while it arrived, used when the turn was cancelled before the document was whole.
Returns
The reply, with the document and the provider metadata.
Exceptions
ParseErrorwhen the answer is not a reply, or a key is missing or has the wrong type. A cancelled turn is not an error: it returns what it had said.