liboai icon indicating copy to clipboard operation
liboai copied to clipboard

v4.0.0 Update

Open D7EAD opened this issue 2 years ago • 0 comments

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 stream parameters that can equal:
    • ChatStreamCallback which expands to std::function<std::string, intptr_t, Conversation&>,
    • and StreamCallback which expands to std::function<std::string, intptr_t>.
      • As implied by their names, ChatStreamCallback applies to Conversation-related streamable methods, and StreamCallback applies to all other streamable methods.
  • Adds a new parameter to ChatCompletions::create and create_async:
    • function_call, an optional parameter that tells the model which function to use in their response, if any. Should be either none, auto (default), or the name of a previously set function the response should use. A function should be set in the Conversation passed 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 class includes a structure, FunctionParameter, which describes a single parameter of a set function in the class Functions.
    • 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
  • New Conversation Methods:
    • 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(...)

D7EAD avatar Jun 22 '23 22:06 D7EAD