liboai
liboai copied to clipboard
v4.0.0 Update
v4.0.0 focuses mainly on the new OpenAI functions capability for their Chat endpoint. You can read about it here.
Basic additions/changes:
- Replaces each class' move and copy constructors, assignment operators with a more concise set of macros:
NON_MOVABLE.NON_COPYABLE.
- Created two type aliases for
streamparameters that can equal:ChatStreamCallbackwhich expands tostd::function<std::string, intptr_t, Conversation&>,- and
StreamCallbackwhich expands tostd::function<std::string, intptr_t>.- As implied by their names,
ChatStreamCallbackapplies toConversation-related streamable methods, andStreamCallbackapplies to all other streamable methods.
- As implied by their names,
- Adds a new parameter to
ChatCompletions::createandcreate_async:function_call, an optional parameter that tells the model whichfunctionto use in their response, if any. Should be eithernone,auto(default), or the name of a previously setfunctionthe response should use. Afunctionshould be set in theConversationpassed to this method prior to calling it.
New classes, methods:
- Class
Functions:- This class holds any functions that will be used during any conversation with a chat model.
- This includes the function's name, description, and parameters--each a
Functions::FunctionParameter.
- This includes the function's name, description, and parameters--each a
- This class includes a structure,
FunctionParameter, which describes a single parameter of a set function in the classFunctions. - Methods:
bool AddFunction(...),bool AddFunctions(...),bool PopFunction(...),bool PopFunctions(...),bool SetDescription(...),bool PopDescription(...),bool SetRequired(...),bool PopRequired(...),bool AppendRequired(...),bool SetParameter(...),bool SetParameters(...),bool PopParameters(...),bool AppendParameter(...),bool AppendParameters(...),const nlohmann::json& GetJSON(...)
- Members:
struct FunctionParameter
- This class holds any functions that will be used during any conversation with a chat model.
- New
ConversationMethods:bool AddUserData(string_view data, string_view name),bool LastResponseIsFunctionCall(...),std::string GetLastFunctionCallName(...),std::string GetLastFunctionCallArguments(...),std::string Export(...),bool Import(...),bool AppendStreamData(...),bool SetFunctions(...),bool PopFunctions(...),std::string GetRawFunctions(...),const nlohmann::json& GetFunctionsJSON(...)