OpenAnima 0.2.0
Middleware for conversational NPCs that interact with the player, the world and each other
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
OpenAnima::Provider::IProvider Class Referenceabstract

#include <IProvider.h>

Inheritance diagram for OpenAnima::Provider::IProvider:
OpenAnima::Provider::RestProvider

Public Member Functions

 IProvider (const IProvider &)=delete
 Providers are used through a pointer, so copying and moving are not offered.
 
IProvider & operator= (const IProvider &)=delete
 
 IProvider (IProvider &&)=delete
 
IProvider & operator= (IProvider &&)=delete
 
virtual OpenAnima::Core::Completion complete (const std::vector< OpenAnima::Core::ChatMessage > &messages, const Call &call)=0
 
OpenAnima::Core::Completion complete (const std::vector< OpenAnima::Core::ChatMessage > &messages, const DeltaSink &onDelta)
 
OpenAnima::Core::Completion complete (const std::vector< OpenAnima::Core::ChatMessage > &messages)
 

Protected Member Functions

 IProvider ()=default
 Only derived classes build a provider.
 

Detailed Description

An interchangeable inference backend. The rest of the library talks to this interface, so replacing a hosted API with a local model is a configuration change rather than a code change.

Member Function Documentation

◆ complete() [1/3]

OpenAnima::Core::Completion OpenAnima::Provider::IProvider::complete ( const std::vector< OpenAnima::Core::ChatMessage > &  messages)
inline

Sends a whole conversation and waits for the answer.

Parameters
messagesConversation in chronological order; the last entry is the current turn.
Returns
The assistant answer, its metadata, and why generation stopped.
Exceptions
OpenAnimaErrorsubclasses when the call cannot be completed.

A class that implements the virtual form keeps both conveniences reachable through its own type: the provider here brings them in, and anything else can either do the same with using IProvider::complete; or forward to them.

References complete().

◆ complete() [2/3]

virtual OpenAnima::Core::Completion OpenAnima::Provider::IProvider::complete ( const std::vector< OpenAnima::Core::ChatMessage > &  messages,
const Call &  call 
)
pure virtual

Sends a whole conversation and returns the answer.

Parameters
messagesConversation in chronological order; the last entry is the current turn.
callWhere the pieces go, and how the call can be abandoned.
Returns
The assistant answer, its metadata, and why generation stopped.
Exceptions
OpenAnimaErrorsubclasses when the call cannot be completed.

Implemented in OpenAnima::Provider::RestProvider.

Referenced by complete(), OpenAnima::Provider::RestProvider::complete(), complete(), and OpenAnima::Provider::RestProvider::complete().

◆ complete() [3/3]

OpenAnima::Core::Completion OpenAnima::Provider::IProvider::complete ( const std::vector< OpenAnima::Core::ChatMessage > &  messages,
const DeltaSink &  onDelta 
)
inline

Sends a whole conversation and reports the answer while it is produced.

Parameters
messagesConversation in chronological order; the last entry is the current turn.
onDeltaCalled with every piece of the answer as it arrives, in order.
Returns
The assembled answer, its metadata, and why generation stopped.
Exceptions
OpenAnimaErrorsubclasses when the call cannot be completed.

References complete().


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