diff --git a/packages/kbot/cpp/CMakeLists.txt b/packages/kbot/cpp/CMakeLists.txt
index 330728fe..3c5a47f4 100644
--- a/packages/kbot/cpp/CMakeLists.txt
+++ b/packages/kbot/cpp/CMakeLists.txt
@@ -62,10 +62,26 @@ FetchContent_Declare(
GIT_SHALLOW TRUE
)
+FetchContent_Declare(
+ nlohmann_json
+ GIT_REPOSITORY https://github.com/nlohmann/json.git
+ GIT_TAG v3.11.3
+ GIT_SHALLOW TRUE
+)
+
+FetchContent_Declare(
+ liboai
+ GIT_REPOSITORY https://github.com/jasonduncan/liboai.git
+ GIT_TAG main
+ GIT_SHALLOW TRUE
+ SOURCE_SUBDIR liboai
+)
+
set(TF_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(TF_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
-FetchContent_MakeAvailable(cli11 tomlplusplus Catch2 asio concurrentqueue taskflow)
+set(JSON_BuildTests OFF CACHE BOOL "" FORCE)
+FetchContent_MakeAvailable(cli11 tomlplusplus Catch2 asio concurrentqueue taskflow nlohmann_json)
# ── Packages ─────────────────────────────────────────────────────────────────
add_subdirectory(packages/logger)
add_subdirectory(packages/html)
@@ -79,6 +95,9 @@ add_subdirectory(packages/gadm_reader)
add_subdirectory(packages/grid)
add_subdirectory(packages/search)
add_subdirectory(packages/enrichers)
+
+add_subdirectory(packages/liboai/liboai)
+
add_subdirectory(packages/kbot)
# ── Sources ──────────────────────────────────────────────────────────────────
@@ -102,6 +121,11 @@ target_include_directories(${PROJECT_NAME} PRIVATE
)
# Define standalone ASIO (since it's not boost)
+if(WIN32)
+ # Enable math constants like M_PI
+ add_compile_definitions(_USE_MATH_DEFINES)
+ add_compile_definitions(NOMINMAX)
+endif()
target_compile_definitions(${PROJECT_NAME} PRIVATE ASIO_STANDALONE=1 ASIO_NO_DEPRECATED=1)
diff --git a/packages/kbot/cpp/build_out.txt b/packages/kbot/cpp/build_out.txt
new file mode 100644
index 00000000..2189004b
Binary files /dev/null and b/packages/kbot/cpp/build_out.txt differ
diff --git a/packages/kbot/cpp/build_out.utf8.txt b/packages/kbot/cpp/build_out.utf8.txt
new file mode 100644
index 00000000..85bef50c
--- /dev/null
+++ b/packages/kbot/cpp/build_out.utf8.txt
@@ -0,0 +1,58 @@
+MSBuild version 18.4.0+6e61e96ac for .NET Framework
+
+ libcurl_object.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\curl-build\lib\libcurl_object.dir\Debug\libcurl_object.lib
+ Catch2.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\catch2-build\src\Debug\Catch2d.lib
+ Catch2WithMain.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\catch2-build\src\Debug\Catch2Maind.lib
+ lexbor_static.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\lexbor-build\Debug\lexbor_static.lib
+ html.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\html\Debug\html.lib
+ libcurl_static.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\curl-build\lib\Debug\libcurl-d.lib
+ http.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\http\Debug\http.lib
+ json.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\json\Debug\json.lib
+ spdlog.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\spdlog-build\Debug\spdlogd.lib
+ logger.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\logger\Debug\logger.lib
+ enrichers.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\enrichers\Debug\enrichers.lib
+ geo.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\geo\Debug\geo.lib
+ gadm_reader.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\gadm_reader\Debug\gadm_reader.lib
+ grid.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\grid\Debug\grid.lib
+ ipc.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\ipc\Debug\ipc.lib
+ azure.cpp
+C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-src\liboai\include\components\chat.h(836,60): warning C4003: not enough arguments for function-like macro invocation 'max' [C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-build\oai.vcxproj]
+ (compiling source file '../liboai-src/liboai/components/azure.cpp')
+
+C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-src\liboai\include\components\chat.h(836,60): error C2589: '(': illegal token on right side of '::' [C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-build\oai.vcxproj]
+ (compiling source file '../liboai-src/liboai/components/azure.cpp')
+
+C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-src\liboai\include\components\chat.h(836,60): error C2059: syntax error: ')' [C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-build\oai.vcxproj]
+ (compiling source file '../liboai-src/liboai/components/azure.cpp')
+
+ chat.cpp
+C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-src\liboai\include\components\chat.h(836,60): warning C4003: not enough arguments for function-like macro invocation 'max' [C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-build\oai.vcxproj]
+ (compiling source file '../liboai-src/liboai/components/chat.cpp')
+
+C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-src\liboai\include\components\chat.h(836,60): error C2589: '(': illegal token on right side of '::' [C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-build\oai.vcxproj]
+ (compiling source file '../liboai-src/liboai/components/chat.cpp')
+
+C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-src\liboai\include\components\chat.h(836,60): error C2059: syntax error: ')' [C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\_deps\liboai-build\oai.vcxproj]
+ (compiling source file '../liboai-src/liboai/components/chat.cpp')
+
+ Generating Code...
+ postgres.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\postgres\Debug\postgres.lib
+ polymech.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\polymech\Debug\polymech.lib
+ search.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\build\release\packages\search\Debug\search.lib
+ test_enrichers.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_enrichers.exe
+ test_functional.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_functional.exe
+ test_gadm_reader.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_gadm_reader.exe
+ test_geo.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_geo.exe
+ test_grid.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_grid.exe
+ test_gridsearch_ipc.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_gridsearch_ipc.exe
+ test_html.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_html.exe
+ test_http.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_http.exe
+ test_ipc.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_ipc.exe
+ test_json.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_json.exe
+ test_logger.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_logger.exe
+ test_polymech.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_polymech.exe
+ test_polymech_e2e.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_polymech_e2e.exe
+ test_postgres.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_postgres.exe
+ test_postgres_live.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_postgres_live.exe
+ test_search.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_search.exe
+ test_supabase.vcxproj -> C:\Users\zx\Desktop\polymech\polymech-mono\packages\kbot\cpp\dist\test_supabase.exe
diff --git a/packages/kbot/cpp/cli_build.txt b/packages/kbot/cpp/cli_build.txt
new file mode 100644
index 00000000..daccda51
Binary files /dev/null and b/packages/kbot/cpp/cli_build.txt differ
diff --git a/packages/kbot/cpp/cli_build.utf8.txt b/packages/kbot/cpp/cli_build.utf8.txt
new file mode 100644
index 00000000..e15047e7
--- /dev/null
+++ b/packages/kbot/cpp/cli_build.utf8.txt
@@ -0,0 +1,152 @@
+CMake is re-running because C:/Users/zx/Desktop/polymech/polymech-mono/packages/kbot/cpp/build/release/CMakeFiles/generate.stamp is out-of-date.
+ the file 'C:/Users/zx/Desktop/polymech/polymech-mono/packages/kbot/cpp/CMakeLists.txt'
+ is newer than 'C:/Users/zx/Desktop/polymech/polymech-mono/packages/kbot/cpp/build/release/CMakeFiles/generate.stamp.depend'
+ result='-1'
+-- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.18363.
+cmake : CMake Deprecation Warning at
+build/release/_deps/cli11-src/CMakeLists.txt:1 (cmake_minimum_required):
+At line:1 char:1
++ cmake --build build/release --target polymech-cli > cli_build.txt 2>& ...
++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ + CategoryInfo : NotSpecified: (CMake Deprecati...imum_required)
+ ::String) [], RemoteException
+ + FullyQualifiedErrorId : NativeCommandError
+
+ Compatibility with CMake < 3.10 will be removed from a future version of
+ CMake.
+
+ Update the VERSION argument
+
+
+Introduction
+liboai is a simple, unofficial C++17 library for the OpenAI API. It allows developers to access OpenAI endpoints through a simple collection of methods and classes. The library can most effectively be thought of as a spiritual port of OpenAI's Python library, simply called openai, due to its similar structure - with few exceptions.
+
+Features
+
+- [x] [ChatGPT](https://github.com/D7EAD/liboai/tree/main/documentation/chat)
+- [x] [Responses API](https://platform.openai.com/docs/api-reference/responses/create)
+- [X] [Audio](https://github.com/D7EAD/liboai/tree/main/documentation/audio)
+- [X] [Azure](https://github.com/D7EAD/liboai/tree/main/documentation/azure)
+- [X] [Functions](https://platform.openai.com/docs/api-reference/chat/create)
+- [x] [Image DALL·E](https://github.com/D7EAD/liboai/tree/main/documentation/images)
+- [x] [Models](https://github.com/D7EAD/liboai/tree/main/documentation/models)
+- [x] [Completions](https://github.com/D7EAD/liboai/tree/main/documentation/completions)
+- [x] [Edit](https://github.com/D7EAD/liboai/tree/main/documentation/edits)
+- [x] [Embeddings](https://github.com/D7EAD/liboai/tree/main/documentation/embeddings)
+- [x] [Files](https://github.com/D7EAD/liboai/tree/main/documentation/files)
+- [x] [Fine-tunes](https://github.com/D7EAD/liboai/tree/main/documentation/fine-tunes)
+- [x] [Moderation](https://github.com/D7EAD/liboai/tree/main/documentation/moderations)
+- [X] Asynchronous Support
+
+Usage
+See below for just how similar in style liboai and its Python alternative are when generating an image using DALL-E.
Running the above will print out the URL to the resulting generated image, which may or may not look similar to the one found below.
+| Example Image | +
+
+
+
+ |
+
+
|---|
Keep in mind the above C++ example is a minimal example and is not an exception-safe snippet. Please see the documentation for more detailed and exception-safe code snippets.
+ +For the library to work the way it does, it relies on two major dependencies. These dependencies can be found listed below.
+ +- nlohmann-json +- cURL + +*If building the library using the provided solution, it is recommended to install these dependencies using vcpkg.* + +
For detailed documentation and additional code examples, see the library's documentation here. + +
Artificial intelligence is an exciting and quickly-changing field. + +If you'd like to partake in further placing the power of AI in the hands of everyday people, please consider contributing by submitting new code and features via a **Pull Request**. If you have any issues using the library, or just want to suggest new features, feel free to contact me directly using the info on my profile or open an **Issue**. diff --git a/packages/kbot/cpp/packages/liboai/ROADMAP.md b/packages/kbot/cpp/packages/liboai/ROADMAP.md new file mode 100644 index 00000000..b694a6ed --- /dev/null +++ b/packages/kbot/cpp/packages/liboai/ROADMAP.md @@ -0,0 +1,25 @@ +# liboai Roadmap + +This is a living backlog of improvements and ideas as we deepen our use of the library. It is intentionally lightweight and updated as we discover new needs. + +## Now +- Responses API support (GPT-5.2, gpt-5.2-pro) +- Keep all existing APIs stable and intact + +## Next +- Responses streaming helpers and SSE parsing +- ResponseInput helper to build Responses `input` items +- `output_text` convenience helper for Responses outputs +- Structured outputs helpers for `text.format` +- Tool definition builders for Responses (`tools`, `tool_choice`) + +## Later +- More robust testing coverage (unit + integration samples) +- Improved error messaging with request context (safe, no secrets) +- Expanded docs and cookbook-style examples +- Performance pass on JSON construction and streaming + +## Observations +- The Conversation class is useful for Chat Completions; Responses lacks an equivalent. +- The library is stable but needs modernization for new OpenAI primitives. +- Maintaining compatibility is critical for existing users. diff --git a/packages/kbot/cpp/packages/liboai/documentation/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/CMakeLists.txt new file mode 100644 index 00000000..0840c592 --- /dev/null +++ b/packages/kbot/cpp/packages/liboai/documentation/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.13) + +project(documentation) + +macro(add_example target_name source_name) + add_executable(${target_name} "${source_name}") + target_link_libraries(${target_name} oai) + set_target_properties(${target_name} PROPERTIES FOLDER "examples/${PROJECT_NAME}") +endmacro() + +macro(add_basic_example source_base_name) + add_example(${source_base_name} "${source_base_name}.cpp") +endmacro() + +add_subdirectory(audio/examples) +add_subdirectory(authorization/examples) +add_subdirectory(azure/examples) +add_subdirectory(chat/examples) +add_subdirectory(chat/conversation/examples) +add_subdirectory(completions/examples) +add_subdirectory(edits/examples) +add_subdirectory(embeddings/examples) +add_subdirectory(files/examples) +add_subdirectory(fine-tunes/examples) +add_subdirectory(images/examples) +add_subdirectory(models/examples) +add_subdirectory(moderations/examples) +add_subdirectory(responses/examples) diff --git a/packages/kbot/cpp/packages/liboai/documentation/README.md b/packages/kbot/cpp/packages/liboai/documentation/README.md new file mode 100644 index 00000000..7499979f --- /dev/null +++ b/packages/kbot/cpp/packages/liboai/documentation/README.md @@ -0,0 +1,217 @@ +
Both above and below, you can find resources and documentation for each component of the library.
+ +In order to understand how to use each component of the library, it would be ideal to first understand the basic structure of the library as a whole. When using liboai in a project, you should only include one header file, liboai.h. This header provides an interface to all other components of the library such as Images, Completions, etc.
+
+See below for both a correct and incorrect example.
| Correct | +Incorrect | +
|---|---|
| + +```cpp +#include "liboai.h" + +int main() { + ... +} +``` + + | ++ +```cpp +#include "fine_tunes.h" +#include "models.h" +// etc... + +int main() { + ... +} +``` + + | +
Once we have properly included the necessary header file to use the library--and assuming symbols are linked properly--we can make use of the class in liboai.h to get started. At some point in our source code, we will have to choose when to define a liboai::OpenAI object to access component interfaces. Each component interface stored in this object offers methods associated with it, so, for instance, interface Image will have a method create(...) to generate an image from text. Each non-async method returns a liboai::Response containing response information whereas async methods return a liboai::FutureResponse. However, before we start using these methods, we must first set our authorization information--otherwise it will not work!
+
+liboai::OpenAI also houses another important member, the authorization member, which is used to set authorization information (such as the API key and organization IDs) before we call the API methods. For more information on additional members found in liboai::Authorization, refer to the authorization folder above.
+
+See below for both a correct and incorrect control flow when generating an image.
| Correct | +Incorrect | +
|---|---|
| + +```cpp +#include "liboai.h" + +using namespace liboai; + +int main() { + OpenAI oai; + + // Set our API key using an environment variable. + // This is recommended as hard-coding API keys is + // insecure. + if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) { + Response response = oai.Image->create( + "a siamese cat!" + ); + } + + ... +} +``` + + | ++ +```cpp +#include "liboai.h" + +using namespace liboai; + +int main() { + OpenAI oai; + + // Failure to set authorization info! + // Will fail, exception will be thrown! + Response response = oai.Image->create( + "a siamese cat!" + ); + + ... +} +``` + + | +
As you can see above, authentication-set related functions return booleans to indicate success and failure, whereas component methods will throw an exception, OpenAIException or OpenAIRateLimited, to indicate their success or failure; these should be checked for accordingly. Below you can find an exception-safe version of the above correct snippet.
| Correct, exception-safe | +
|---|
| + +```cpp +#include "liboai.h" + +using namespace liboai; + +int main() { + OpenAI oai; + if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) { + try { + Response response = oai.Image->create( + "a siamese cat!" + ); + } + catch (std::exception& e) { + std::cout << e.what() << std::endl; + } + + ... + } +} +``` + + | +
Now, once we have made a call using a component interface, we most certainly want to get the information out of it. To do this, using our knowledge of the format of the API responses, we can extract the information, such as the resulting image's URL, using JSON indexing on the liboai::Response object. See below for an example where we print the generated image's URL.
| Accessing JSON Response Data | +
|---|
|
+
+```cpp
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.Image->create(
+ "a siamese cat!"
+ );
+ std::cout << response["data"][0]["url"].get |
+
What if we want to do more than just print the URL of the image? Why not download it right when it's done? Thankfully, liboai has a convenient function for that, Network::Download(...) (and Network::DownloadAsync(...)). See below for an example of downloading a freshly generated image.
+
| Downloading a Generated Image | +
+
+```cpp
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.Image->create(
+ "a siamese cat!"
+ );
+ Network::Download(
+ "C:/some/folder/file.png", // to
+ response["data"][0]["url"].get |
+
+
|---|
After a successful run of the above snippet, the file found at the URL returned from the component call will be download to the path C:/some/folder/file.png.
+
+
+
Each component interface found within liboai::OpenAI follows the same pattern found above. Whether you want to generate images, completions, or fine-tune models, the control flow should follow--or remain similar to--the above examples.
+
+For detailed examples regarding individual component interfaces, refer to the appropriate folder listed above.
Maintainers can find PR workflow notes in documentation/maintenance.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/audio/README.md b/packages/kbot/cpp/packages/liboai/documentation/audio/README.md new file mode 100644 index 00000000..96ed24f0 --- /dev/null +++ b/packages/kbot/cpp/packages/liboai/documentation/audio/README.md @@ -0,0 +1,96 @@ +The Audio class is defined in audio.h at liboai::Audio, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Audio endpoint of the OpenAI API; this endpoint's functionality can be found below.
This document covers the method(s) located in audio.h. You can find their function signature(s) below.
Transcribes audio into the input language. Returns a liboai::Response containing response data.
Asynchronously transcribes audio into the input language. Returns a liboai::FutureResponse containing future response data.
Translates audio into English. Returns a liboai::Response containing response data.
Asynchronously translates audio into English. Returns a liboai::FutureResponse containing future response data.
Turn text into lifelike spoken audio. Returns a liboai::Response containing response data. The audio data is in the content field of the liboai::Response
Asynchronously turn text into lifelike spoken audio. Returns a liboai::FutureResponse containing response data. The audio data is in the content field of the liboai::Response
All function parameters marked optional are not required and are resolved on OpenAI's end if not supplied.
For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/audio/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/audio/examples/CMakeLists.txt
new file mode 100644
index 00000000..c476f4b5
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/audio/examples/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(audio)
+
+add_basic_example(create_speech)
+add_basic_example(create_speech_async)
+add_basic_example(create_transcription)
+add_basic_example(create_transcription_async)
+add_basic_example(create_translation)
+add_basic_example(create_translation_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/audio/examples/create_speech.cpp b/packages/kbot/cpp/packages/liboai/documentation/audio/examples/create_speech.cpp
new file mode 100644
index 00000000..306bf9fb
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/audio/examples/create_speech.cpp
@@ -0,0 +1,24 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response res = oai.Audio->speech(
+ "tts-1",
+ "alloy",
+ "Today is a wonderful day to build something people love!"
+ );
+ std::ofstream ocout("demo.mp3", std::ios::binary);
+ ocout << res.content;
+ ocout.close();
+ std::cout << res.content.size() << std::endl;
+ }
+ catch (const std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/audio/examples/create_speech_async.cpp b/packages/kbot/cpp/packages/liboai/documentation/audio/examples/create_speech_async.cpp
new file mode 100644
index 00000000..cd404cbf
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/audio/examples/create_speech_async.cpp
@@ -0,0 +1,31 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ auto fut = oai.Audio->speech_async(
+ "tts-1",
+ "alloy",
+ "Today is a wonderful day to build something people love!"
+ );
+ // do other work...
+
+ // check if the future is ready
+ fut.wait();
+
+ // get the contained response
+ auto res = fut.get();
+ std::ofstream ocout("demo.mp3", std::ios::binary);
+ ocout << res.content;
+ ocout.close();
+ std::cout << res.content.size() << std::endl;
+ }
+ catch (const std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/audio/examples/create_transcription.cpp b/packages/kbot/cpp/packages/liboai/documentation/audio/examples/create_transcription.cpp
new file mode 100644
index 00000000..a766bb07
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/audio/examples/create_transcription.cpp
@@ -0,0 +1,20 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response res = oai.Audio->transcribe(
+ "C:/some/folder/audio.mp3",
+ "whisper-1"
+ );
+ std::cout << res["text"].get The This document covers the method(s) located in Returns a reference to the Sets the API key to use in subsequent component calls. Sets the Azure API key to use in subsequent component calls. Sets the Active Directory Azure API key to use in subsequent component calls. Sets the API key to use in subsequent component calls from data found in file at path. Sets the Azure API key to use in subsequent component calls from data found in file at path. Sets the Active Directory Azure API key to use in subsequent component calls from data found in file at path. Sets the API key to use in subsequent component calls from an environment variable. Sets the Azure API key to use in subsequent component calls from an environment variable. Sets the Active Directory Azure API key to use in subsequent component calls from an environment variable. Sets the organization ID to send in subsequent component calls. Sets the organization ID to send in subsequent component calls from data found in file at path. Sets the organization ID to send in subsequent component calls from an environment variable. Sets the proxy, or proxies, to use in subsequent component calls. Sets the username and password to use when using a certain proxy protocol. Sets the timeout in milliseconds for the library to use in component calls. Returns the currently set API key. Returns the currently set organization ID. Returns the currently set proxies. Returns the currently set proxy authentication information. Returns the currently set timeout. Returns the currently set authorization headers based on set information. Returns the currently set Azure authorization headers based on set information. For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/CMakeLists.txt
new file mode 100644
index 00000000..1fa3fd49
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(authorization)
+
+add_basic_example(set_azure_key)
+add_basic_example(set_azure_key_env)
+add_basic_example(set_azure_key_file)
+add_basic_example(set_key)
+add_basic_example(set_key_env_var)
+add_basic_example(set_key_file)
+add_basic_example(set_organization)
+add_basic_example(set_organization_env_var)
+add_basic_example(set_organization_file)
+add_basic_example(set_proxies)
+add_basic_example(set_proxy_auth)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_azure_key.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_azure_key.cpp
new file mode 100644
index 00000000..a4f065ce
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_azure_key.cpp
@@ -0,0 +1,10 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetAzureKey("hard-coded-key")) { // NOT recommended
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_azure_key_env.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_azure_key_env.cpp
new file mode 100644
index 00000000..a5797bf3
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_azure_key_env.cpp
@@ -0,0 +1,10 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetAzureKeyEnv("AZURE_API_KEY")) {
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_azure_key_file.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_azure_key_file.cpp
new file mode 100644
index 00000000..dee52cab
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_azure_key_file.cpp
@@ -0,0 +1,10 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetAzureKeyFile("C:/some/folder/key.dat")) {
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_key.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_key.cpp
new file mode 100644
index 00000000..599e3b4c
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_key.cpp
@@ -0,0 +1,10 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKey("hard-coded-key")) { // NOT recommended
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_key_env_var.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_key_env_var.cpp
new file mode 100644
index 00000000..58c3d61b
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_key_env_var.cpp
@@ -0,0 +1,10 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_key_file.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_key_file.cpp
new file mode 100644
index 00000000..e76415b6
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_key_file.cpp
@@ -0,0 +1,10 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyFile("C:/some/folder/key.dat")) {
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_organization.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_organization.cpp
new file mode 100644
index 00000000..9686880f
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_organization.cpp
@@ -0,0 +1,10 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY") && oai.auth.SetOrganization("org-123")) {
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_organization_env_var.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_organization_env_var.cpp
new file mode 100644
index 00000000..0e3926a9
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_organization_env_var.cpp
@@ -0,0 +1,10 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+ int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY") && oai.auth.SetOrganizationEnv("OPENAI_ORG_ID")) {
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_organization_file.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_organization_file.cpp
new file mode 100644
index 00000000..55b1ce0c
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_organization_file.cpp
@@ -0,0 +1,10 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY") && oai.auth.SetOrganizationFile("C:/some/folder/org.dat")) {
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_proxies.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_proxies.cpp
new file mode 100644
index 00000000..d11aad30
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_proxies.cpp
@@ -0,0 +1,21 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+
+ /*
+ Set some proxies:
+ when we go to an http site, use fakeproxy1
+ when we go to an https site, use fakeproxy2
+ */
+ oai.auth.SetProxies({
+ { "http", "http://www.fakeproxy1.com" },
+ { "https", "https://www.fakeproxy2.com" }
+ });
+
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ // ...
+ }
+}
\ No newline at end of file
diff --git a/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_proxy_auth.cpp b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_proxy_auth.cpp
new file mode 100644
index 00000000..4ef28bae
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/authorization/examples/set_proxy_auth.cpp
@@ -0,0 +1,31 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+
+ /*
+ Set some proxies:
+ when we go to an http site, use fakeproxy1
+ when we go to an https site, use fakeproxy2
+ */
+ oai.auth.SetProxies({
+ { "http", "http://www.fakeproxy1.com" },
+ { "https", "https://www.fakeproxy2.com" }
+ });
+
+ /*
+ Set the per-protocol proxy auth info:
+ when we go to an http site, use fakeuser1 and fakepass1
+ when we go to an https site, use fakeuser2 and fakepass2
+ */
+ oai.auth.SetProxyAuth({
+ {"http", {"fakeuser1", "fakepass1"}},
+ {"https", {"fakeuser2", "fakepass2"}},
+ });
+
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ // ...
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/azure/README.md b/packages/kbot/cpp/packages/liboai/documentation/azure/README.md
new file mode 100644
index 00000000..d979761a
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/azure/README.md
@@ -0,0 +1,204 @@
+ The This document covers the method(s) located in Given a prompt, the model will return one or more predicted completions. Returns a Given a prompt, the model will asynchronously return one or more predicted completions. Returns a Creates an embedding vector representing the input text. Returns a Asynchronously creates an embedding vector representing the input text. Returns a Creates a completion for the chat message. Returns a Asynchronously creates a completion for the chat message. Returns a Generate a batch of images from a text caption. Returns a Asynchronously generate a batch of images from a text caption. Returns a Retrieve the results (URL) of a previously called image generation operation. Returns a Asynchronously retrieve the results (URL) of a previously called image generation operation. Returns a Deletes the corresponding image from the Azure server. Returns a Asynchronously deletes the corresponding image from the Azure server. Returns a All function parameters marked For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/azure/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/azure/examples/CMakeLists.txt
new file mode 100644
index 00000000..22760b45
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/azure/examples/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(azure)
+
+add_example(create_chat_completion_azure "create_chat_completion.cpp")
+add_example(create_chat_completion_async_azure "create_chat_completion_async.cpp")
+add_basic_example(create_completion)
+add_basic_example(create_completion_async)
+add_example(create_embedding_azure "create_embedding.cpp")
+add_example(create_embedding_async_azure "create_embedding_async.cpp")
+add_basic_example(delete_generated_image)
+add_basic_example(delete_generated_image_async)
+add_basic_example(get_generated_image)
+add_basic_example(get_generated_image_async)
+add_basic_example(request_image_generation)
+add_basic_example(request_image_generation_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/azure/examples/create_chat_completion.cpp b/packages/kbot/cpp/packages/liboai/documentation/azure/examples/create_chat_completion.cpp
new file mode 100644
index 00000000..d9b1c87e
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/azure/examples/create_chat_completion.cpp
@@ -0,0 +1,28 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+
+ Conversation convo;
+ convo.AddUserData("Hi, how are you?");
+
+ if (oai.auth.SetAzureKeyEnv("AZURE_API_KEY")) {
+ try {
+ Response res = oai.Azure->create_chat_completion(
+ "resource", "deploymentID", "api_version",
+ convo
+ );
+
+ // update the conversation with the response
+ convo.Update(res);
+
+ // print the response from the API
+ std::cout << convo.GetLastResponse() << std::endl;
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/azure/examples/create_chat_completion_async.cpp b/packages/kbot/cpp/packages/liboai/documentation/azure/examples/create_chat_completion_async.cpp
new file mode 100644
index 00000000..06d64c09
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/azure/examples/create_chat_completion_async.cpp
@@ -0,0 +1,37 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+
+ Conversation convo;
+ convo.AddUserData("Hi, how are you?");
+
+ if (oai.auth.SetAzureKeyEnv("AZURE_API_KEY")) {
+ try {
+ // call async method; returns a future
+ auto fut = oai.Azure->create_chat_completion_async(
+ "resource", "deploymentID", "api_version",
+ convo
+ );
+
+ // do other work...
+
+ // check if the future is ready
+ fut.wait();
+
+ // get the contained response
+ auto res = fut.get();
+
+ // update the conversation with the response
+ convo.Update(res);
+
+ // print the response from the API
+ std::cout << convo.GetLastResponse() << std::endl;
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/azure/examples/create_completion.cpp b/packages/kbot/cpp/packages/liboai/documentation/azure/examples/create_completion.cpp
new file mode 100644
index 00000000..0f14f282
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/azure/examples/create_completion.cpp
@@ -0,0 +1,21 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+
+ if (oai.auth.SetAzureKeyEnv("AZURE_API_KEY")) {
+ try {
+ Response res = oai.Azure->create_completion(
+ "resource", "deploymentID", "api_version",
+ "Write a short poem about a snowman."
+ );
+
+ std::cout << res["choices"][0]["text"].get The This document covers the method(s) located in Creates a completion for the ongoing conversation. Returns a Asynchronously creates a completion for the ongoing conversation. Returns a All function parameters marked For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/chat/conversation/README.md b/packages/kbot/cpp/packages/liboai/documentation/chat/conversation/README.md
new file mode 100644
index 00000000..8c706e71
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/chat/conversation/README.md
@@ -0,0 +1,409 @@
+ You can jump to any content found on this page using the links below.
+ Constructors available to construct a Operator overloads for assignment. Sets the system parameter in the conversation that can be used to influence how the model may respond to input. This should always be called before setting user data, if used. Returns a Removes (pops) the set system data. Returns a Adds user input to the conversation, such as a command or question to pose to a model. Returns a Removes (pops) the most recently added user input to the conversation as long as it is the tail of the conversation. Returns a Retrieves the last response from the conversation if one exists. This can be called when the last item in the conversation is an answer from a chat model, such as after the conversation is updated with a successful response from Removes (pops) the last response from a chat model within the conversation if the tail of the conversation is a response. This can be called to remove a chat model response from the conversation after updating the conversation with said response. Returns a Returns whether the most recent response, following a call to Returns the name of the function_call in the most recent response. This should only be called if Returns the arguments of the function_call in the most recent response in their raw JSON form. This should only be called if Updates the conversation given a Response object. This method updates the conversation given a Response object. This method should only be used if Exports the entire conversation to a JSON string. This method exports the conversation to a JSON string. The JSON string can be used to save the conversation to a file. The exported string contains both the conversation and included functions, if any. Returns the JSON string representing the conversation. Imports a conversation from a JSON string. This method imports a conversation from a JSON string. The JSON string should be the JSON string returned from a call to Appends stream data (SSEs) from streamed methods. This method updates the conversation given a token from a streamed method. This method should be used when using streamed methods such as Sets the functions to be used for the conversation. This method sets the functions to be used for the conversation. Returns a boolean indicating success. Pops any previously set functions. Retrieves the raw JSON of the conversation; the same functionality can be achieved using the Returns the raw JSON dump of the internal functions object in string format - if one exists. Returns the JSON object of the set functions. Retrieves a For example usage of the above function(s), please refer to the examples folder here and in the previous directory. The This document covers the method(s) located in Creates a completion for the provided prompt and parameters. Returns a Asynchronously creates a completion for the provided prompt and parameters. Returns a All function parameters marked For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/completions/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/completions/examples/CMakeLists.txt
new file mode 100644
index 00000000..fdb88b29
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/completions/examples/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(completions)
+
+add_basic_example(generate_completion)
+add_basic_example(generate_completion_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/completions/examples/generate_completion.cpp b/packages/kbot/cpp/packages/liboai/documentation/completions/examples/generate_completion.cpp
new file mode 100644
index 00000000..c287dc72
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/completions/examples/generate_completion.cpp
@@ -0,0 +1,21 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.Completion->create(
+ "text-davinci-003",
+ "Say this is a test",
+ std::nullopt,
+ 7
+ );
+ std::cout << response["choices"][0]["text"].get The This document covers the method(s) located in Creates a new edit for the provided input, instruction, and parameters. Returns a Asynchronously creates a new edit for the provided input, instruction, and parameters. Returns a All function parameters marked For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/edits/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/edits/examples/CMakeLists.txt
new file mode 100644
index 00000000..8c9a6c9f
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/edits/examples/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(edits)
+
+add_basic_example(create_edit)
+add_basic_example(create_edit_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/edits/examples/create_edit.cpp b/packages/kbot/cpp/packages/liboai/documentation/edits/examples/create_edit.cpp
new file mode 100644
index 00000000..4fb47baf
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/edits/examples/create_edit.cpp
@@ -0,0 +1,20 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.Edit->create(
+ "text-davinci-edit-001",
+ "What day of the wek is it?",
+ "Fix the spelling mistakes"
+ );
+ std::cout << response["choices"][0]["text"].get The This document covers the method(s) located in Creates an embedding vector representing the input text. Returns a Asynchronously creates an embedding vector representing the input text. Returns a All function parameters marked For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/embeddings/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/embeddings/examples/CMakeLists.txt
new file mode 100644
index 00000000..1cac2481
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/embeddings/examples/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(embeddings)
+
+add_basic_example(create_embedding)
+add_basic_example(create_embedding_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/embeddings/examples/create_embedding.cpp b/packages/kbot/cpp/packages/liboai/documentation/embeddings/examples/create_embedding.cpp
new file mode 100644
index 00000000..f1c65c50
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/embeddings/examples/create_embedding.cpp
@@ -0,0 +1,19 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.Embedding->create(
+ "text-embedding-ada-002",
+ "The food was delicious and the waiter..."
+ );
+ std::cout << response["data"][0]["embedding"] << std::endl;
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/embeddings/examples/create_embedding_async.cpp b/packages/kbot/cpp/packages/liboai/documentation/embeddings/examples/create_embedding_async.cpp
new file mode 100644
index 00000000..10c59e30
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/embeddings/examples/create_embedding_async.cpp
@@ -0,0 +1,30 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ // call async method; returns a future
+ auto fut = oai.Embedding->create_async(
+ "text-embedding-ada-002",
+ "The food was delicious and the waiter..."
+ );
+
+ // do other work...
+
+ // check if the future is ready
+ fut.wait();
+
+ // get the contained response
+ auto response = fut.get();
+
+ // print some response data
+ std::cout << response["data"][0]["embedding"] << std::endl;
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/files/README.md b/packages/kbot/cpp/packages/liboai/documentation/files/README.md
new file mode 100644
index 00000000..a4810240
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/files/README.md
@@ -0,0 +1,103 @@
+ The This document covers the method(s) located in Gets a list of files that belong to the user's organization. Returns a Asynchronously gets a list of files that belong to the user's organization. Returns a Upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Returns a Asynchronously upload a file that contains document(s) to be used across various endpoints/features. Currently, the size of all the files uploaded by one organization can be up to 1 GB. Returns a Deletes a file. Returns a Asynchronously deletes a file. Returns a Returns information about a specific file. Returns a Asynchronously returns information about a specific file. Returns a Returns the contents of the specified file and downloads it to the provided path. Returns a Asynchronously returns the contents of the specified file and downloads it to the provided path. Returns a future For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/files/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/files/examples/CMakeLists.txt
new file mode 100644
index 00000000..527dc0f9
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/files/examples/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(files)
+
+add_basic_example(delete_file)
+add_basic_example(delete_file_async)
+add_basic_example(download_uploaded_file)
+add_basic_example(download_uploaded_file_async)
+add_basic_example(list_files)
+add_basic_example(list_files_async)
+add_basic_example(retrieve_file)
+add_basic_example(retrieve_file_async)
+add_basic_example(upload_file)
+add_basic_example(upload_file_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/files/examples/delete_file.cpp b/packages/kbot/cpp/packages/liboai/documentation/files/examples/delete_file.cpp
new file mode 100644
index 00000000..f555b37f
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/files/examples/delete_file.cpp
@@ -0,0 +1,18 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.File->remove(
+ "file-XjGxS3KTG0uNmNOK362iJua3"
+ );
+ std::cout << response["deleted"].get The This document covers the method(s) located in Creates a job that fine-tunes a specified model from a given dataset. Returns a Asynchronously creates a job that fine-tunes a specified model from a given dataset. Returns a List your organization's fine-tuning jobs. Returns a Asynchronously list your organization's fine-tuning jobs. Returns a Gets info about the fine-tune job. Returns a Asynchronously gets info about the fine-tune job. Returns a Immediately cancel a fine-tune job. Returns a Asynchronously and immediately cancel a fine-tune job. Returns a Get fine-grained status updates for a fine-tune job. Returns a Asynchronously get fine-grained status updates for a fine-tune job. Returns a Delete a fine-tuned model. You must have the Owner role in your organization. Returns a Asynchronously delete a fine-tuned model. You must have the Owner role in your organization. Returns a All function parameters marked For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/fine-tunes/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/fine-tunes/examples/CMakeLists.txt
new file mode 100644
index 00000000..96044028
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/fine-tunes/examples/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(fine-tunes)
+
+add_basic_example(cancel_fine_tune)
+add_basic_example(cancel_fine_tune_async)
+add_basic_example(create_fine_tune)
+add_basic_example(create_fine_tune_async)
+add_basic_example(delete_fine_tune_model)
+add_basic_example(delete_fine_tune_model_async)
+add_basic_example(list_fine_tune_events)
+add_basic_example(list_fine_tune_events_async)
+add_basic_example(list_fine_tunes)
+add_basic_example(list_fine_tunes_async)
+add_basic_example(retrieve_fine_tune)
+add_basic_example(retrieve_fine_tune_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/fine-tunes/examples/cancel_fine_tune.cpp b/packages/kbot/cpp/packages/liboai/documentation/fine-tunes/examples/cancel_fine_tune.cpp
new file mode 100644
index 00000000..aa49aa24
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/fine-tunes/examples/cancel_fine_tune.cpp
@@ -0,0 +1,18 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.FineTune->cancel(
+ "ft-AF1WoRqd3aJAHsqc9NY7iL8F"
+ );
+ std::cout << response["status"].get The This document covers the method(s) located in Creates an image given a prompt. Returns a Asynchronously creates an image given a prompt. Returns a Creates an edited or extended image given an original image and a prompt. Returns a Asynchronously creates an edited or extended image given an original image and a prompt. Returns a Creates a variation of a given image. Returns a Asynchronously creates a variation of a given image. Returns a All function parameters marked For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/images/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/images/examples/CMakeLists.txt
new file mode 100644
index 00000000..776e0dad
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/images/examples/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(images)
+
+# compilation error
+add_basic_example(download_generated_image)
+add_basic_example(generate_edit)
+add_basic_example(generate_edit_async)
+add_basic_example(generate_image)
+add_basic_example(generate_image_async)
+add_basic_example(generate_variation)
+add_basic_example(generate_variation_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/images/examples/download_generated_image.cpp b/packages/kbot/cpp/packages/liboai/documentation/images/examples/download_generated_image.cpp
new file mode 100644
index 00000000..680f29a3
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/images/examples/download_generated_image.cpp
@@ -0,0 +1,22 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.Image->create(
+ "a siamese cat!"
+ );
+ Network::Download(
+ "C:/some/folder/file.png", // to
+ response["data"][0]["url"].get In order to integrate the power of artificial intelligence and As Assuming your existing codebase has the above in mind, you can safely add It's as easy as that! Another means of integrating Static and dynamic libraries take many forms: However, their underlying concepts remain the same. The process of compiling Now, in the project you'd like to integrate This doc summarizes where PRs live now and how to review them efficiently. Upstream PRs are read-only history but can be useful for reference: Expected remotes: The This document covers the method(s) located in Lists the currently available models, and provides basic information about each one such as the owner and availability. Returns a Asynchronously lists the currently available models, and provides basic information about each one such as the owner and availability. Returns a Retrieves a model instance, providing basic information about the model such as the owner and permissioning. Returns a Asynchronously retrieves a model instance, providing basic information about the model such as the owner and permissioning. Returns a For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/models/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/models/examples/CMakeLists.txt
new file mode 100644
index 00000000..7cbb7ef4
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/models/examples/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(models)
+
+add_basic_example(list_models)
+add_basic_example(list_models_async)
+add_basic_example(retrieve_model)
+add_basic_example(retrieve_model_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/models/examples/list_models.cpp b/packages/kbot/cpp/packages/liboai/documentation/models/examples/list_models.cpp
new file mode 100644
index 00000000..f50f9a27
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/models/examples/list_models.cpp
@@ -0,0 +1,16 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.Model->list();
+ std::cout << response["data"] << std::endl;
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/models/examples/list_models_async.cpp b/packages/kbot/cpp/packages/liboai/documentation/models/examples/list_models_async.cpp
new file mode 100644
index 00000000..d17561e7
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/models/examples/list_models_async.cpp
@@ -0,0 +1,27 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ // call async method; returns a future
+ auto fut = oai.Model->list_async();
+
+ // do other work...
+
+ // check if the future is ready
+ fut.wait();
+
+ // get the contained response
+ auto response = fut.get();
+
+ // print some response data
+ std::cout << response["data"] << std::endl;
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/models/examples/retrieve_model.cpp b/packages/kbot/cpp/packages/liboai/documentation/models/examples/retrieve_model.cpp
new file mode 100644
index 00000000..fd7b2de3
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/models/examples/retrieve_model.cpp
@@ -0,0 +1,18 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.Model->retrieve(
+ "text-davinci-003"
+ );
+ std::cout << response << std::endl;
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/models/examples/retrieve_model_async.cpp b/packages/kbot/cpp/packages/liboai/documentation/models/examples/retrieve_model_async.cpp
new file mode 100644
index 00000000..8ea13971
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/models/examples/retrieve_model_async.cpp
@@ -0,0 +1,29 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ // call async method; returns a future
+ auto fut = oai.Model->retrieve_async(
+ "text-davinci-003"
+ );
+
+ // do other work...
+
+ // check if the future is ready
+ fut.wait();
+
+ // get the contained response
+ auto response = fut.get();
+
+ // print some response data
+ std::cout << response << std::endl;
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
diff --git a/packages/kbot/cpp/packages/liboai/documentation/moderations/README.md b/packages/kbot/cpp/packages/liboai/documentation/moderations/README.md
new file mode 100644
index 00000000..f1380a7e
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/moderations/README.md
@@ -0,0 +1,35 @@
+ The This document covers the method(s) located in Classifies if text violates OpenAI's Content Policy. Returns a Asynchronously classifies if text violates OpenAI's Content Policy. Returns a All function parameters marked For example usage of the above function(s), please refer to the examples folder.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/moderations/examples/CMakeLists.txt b/packages/kbot/cpp/packages/liboai/documentation/moderations/examples/CMakeLists.txt
new file mode 100644
index 00000000..e89e2561
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/moderations/examples/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 3.13)
+
+project(moderations)
+
+add_basic_example(create_moderation)
+add_basic_example(create_moderation_async)
diff --git a/packages/kbot/cpp/packages/liboai/documentation/moderations/examples/create_moderation.cpp b/packages/kbot/cpp/packages/liboai/documentation/moderations/examples/create_moderation.cpp
new file mode 100644
index 00000000..e1b4c689
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/moderations/examples/create_moderation.cpp
@@ -0,0 +1,18 @@
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.Moderation->create(
+ "I want to kill them."
+ );
+ std::cout << response["results"][0]["flagged"].get The This class provides access to the Responses API. It offers a typed This document covers the method(s) located in Builds a Responses API request payload from typed parameters. Creates a response from typed parameters. Returns a Authorization
+Authorization class is defined in authorization.h at liboai::Authorization. This class is responsible for sharing all set authorization information with all component classes in liboai.
+
+All authorization information should be set prior to the calling of any component methods such as Images, Embeddings, and so on. Failure to do so will result in a liboai::OpenAIException due to authorization failure on OpenAI's end.
+Methods
+authorization.h. You can find their function signature(s) below.Get Authorizer
+liboai::Authorization singleton shared among all components.Set API Key
+Set Azure API Key
+Set Active Directory Azure API Key
+Set API Key (File)
+Set Azure API Key (File)
+Set Active Directory Azure API Key (File)
+Set API Key (Environment Variable)
+Set Azure API Key (Environment Variable)
+Set Active Directory Azure API Key (Environment Variable)
+Set Organization ID
+Set Organization ID (File)
+Set Organization ID (Environment Variable)
+Set Proxies
+Set Proxy Authentication
+Set Timeout
+Get Key
+Get Organization ID
+Get Proxies
+Get Proxy Authentication
+Get Timeout
+Get Authorization Headers
+Get Azure Authorization Headers
+
+Example Usage
+Azure
+Azure class is defined in azure.h at liboai::Azure, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Azure OpenAI API components.
+
+
+Methods
+azure.h. You can find their function signature(s) below.Create a Completion
+liboai::Response containing response data.Create a Completion (async)
+liboai::FutureResponse containing future response data.Create an Embedding
+liboai::Response containing response data.Create an Embedding (async)
+liboai::FutureResponse containing future response data.Create a Chat Completion
+liboai::Response containing response data.Create a Chat Completion (async)
+liboai::FutureResponse containing future response data.Request an Image Generation
+liboai::Response containing response data.Request an Image Generation (async)
+liboai::FutureResponse containing future response data.Get a Previously Generated Image
+liboai::Response containing response data.Get a Previously Generated Image (async)
+liboai::FutureResponse containing future response data.Delete a Previously Generated Image
+liboai::Response containing response data.Delete a Previously Generated Image (async)
+liboai::FutureResponse containing future response data.optional are not required and are resolved on OpenAI's end if not supplied.
+Example Usage
+Chat
+ChatCompletion class is defined in chat.h at liboai::ChatCompletion, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Chat endpoint of the OpenAI API; this endpoint's functionality can be found below.Methods
+chat.h. You can find their function signature(s) below.Create a Chat Completion
+liboai::Response containing response data.Create a Chat Completion (async)
+liboai::FutureResponse containing future response data.optional are not required and are resolved on OpenAI's end if not supplied.
+Example Usage
+Conversation
+
+Contents
+
+
+
+The Conversation class is defined at liboai::Conversation.
+
+This class can most effectively be thought of as a container for any conversation(s) that one may wish to carry out with a given model using the ChatCompletion methods. It keeps track of the history of the conversation for subsequent calls to the methods, allows a developer to set system directions, retrieve the last response, add user input, and so on.
+
+Basic Use
+
+Each method found in ChatCompletion requires an existing object of class Conversation be provided. Before providing such an object to a method such as liboai::ChatCompletion::create, we must first populate it--perhaps with a question to ask the model we choose, like so:
+
+
+
+
+Once we add a message to our
+
+Creating a Conversation
+
+
+
+
+```cpp
+#include "liboai.h"
+
+using namespace liboai;
+
+int main() {
+ OpenAI oai;
+
+ // create a conversation
+ Conversation convo;
+
+ // add a message to the conversation
+ convo.AddUserData("Hello, how are you?");
+
+ ...
+}
+```
+
+
+Conversation, we can then supply it to a method such as liboai::ChatCompletion::create to begin our conversation starting with our user data, like so:
+
+
+
+Assuming that our request succeeded without throwing an exception, the response to our user data in our
+
+Starting the Conversation
+
+
+
+
+```cpp
+int main() {
+ OpenAI oai;
+
+ // create a conversation
+ Conversation convo;
+
+ // add a message to the conversation
+ convo.AddUserData("Hello, how are you?");
+
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.ChatCompletion->create(
+ "gpt-3.5-turbo", convo
+ );
+
+ ...
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
+```
+
+
+Conversation can be found in our Response object. We must now update our Conversation object with the response like so:
+
+
+
+After we update our
+
+Updating our Conversation
+
+
+
+
+```cpp
+int main() {
+ OpenAI oai;
+
+ // create a conversation
+ Conversation convo;
+
+ // add a message to the conversation
+ convo.AddUserData("Hello, how are you?");
+
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.ChatCompletion->create(
+ "gpt-3.5-turbo", convo
+ );
+
+ // update our conversation with the response
+ convo.Update(response);
+
+ ...
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
+```
+
+
+Conversation, it now contains the original question we asked the model, as well as the response from the model. Now we can extract the response like so:
+
+
+
+This may print something along the lines of the following:
+* "As an AI language model, I do not have emotions, but I am always responsive and ready to assist. How can I help you today?"
+
+
+
+Printing the Response
+
+
+
+
+```cpp
+int main() {
+ OpenAI oai;
+
+ // create a conversation
+ Conversation convo;
+
+ // add a message to the conversation
+ convo.AddUserData("Hello, how are you?");
+
+ if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
+ try {
+ Response response = oai.ChatCompletion->create(
+ "gpt-3.5-turbo", convo
+ );
+
+ // update our conversation with the response
+ convo.Update(response);
+
+ // print the response
+ std::cout << convo.GetLastResponse() << std::endl;
+ }
+ catch (std::exception& e) {
+ std::cout << e.what() << std::endl;
+ }
+ }
+}
+```
+
+
+Usage Pattern
+As you have hopefully noticed, there is a pattern that can be followed with Conversation. Generally, when we want to make use of the methods found within liboai::ChatCompletion, we should adhere to the following series of steps:
+
+
+
+Conversation object.ChatCompletion::create or a similar method.Conversation object with the response from the API.Conversation object.The Use of System
+Other than setting user data in our Conversation objects, we can also set an optional system parameter that instructs the model on how to respond. If we wish to make use of this system parameter, we can do so like so:
+
+
+
+Keep in mind that it is **highly** important to set the system data before user data. Furthermore, it is important to note that, according to OpenAI, some models (such as gpt-3.5-turbo-0301) do not always pay attention to this system data. As a result, it may be more efficient to set guiding data as user data like so:
+
+
+Setting System Data to Guide Models
+
+
+
+
+```cpp
+int main() {
+ OpenAI oai;
+
+ // create a conversation
+ Conversation convo;
+
+ // set the system message first - helps guide the model
+ convo.SetSystemData("You are a helpful bot that only answers questions about OpenAI.");
+
+ // add a message to the conversation
+ convo.AddUserData("Hello, how are you?");
+
+ ...
+}
+```
+
+
+
+
+
+
+
+Alternate Ways to Guide
+
+
+
+
+```cpp
+int main() {
+ OpenAI oai;
+
+ // create a conversation
+ Conversation convo;
+
+ // add guiding data and a message to the conversation
+ convo.AddUserData("You are a helpful bot that only answers questions about OpenAI: Hello, how are you?");
+
+ ...
+}
+```
+
+
+Synopsis
+With the use of Conversation objects, as we carry on a given conversation, our object will keep track of not only the history of the conversation we are having, but its contained context as well. That means that if we were to, at first, ask our model "When was last year's Super Bowl," and then subsequently ask it, "Who played in it," it would be aware of the context of the conversation for the second inquiry and answer accordingly.
+
+
+In general, objects of class liboai::Conversation allow us to more easily engage in conversation with existing and future conversational chat models via the use of liboai::ChatCompletion methods.
+
+Methods
+Below you can find the function signature(s) of the class methods found within liboai::Conversation.
+
+Constructors
+Conversation object.Assignment Operators
+Set System Data
+bool indicating success.Pop System Data
+bool indicating success.Add User Data
+bool indicating success.Pop User Data
+bool indicating success.Get Last Response
+liboai::ChatCompletion::create. Returns a non-empty std::string containing the response from the chat model if one exists, empty otherwise.Pop Last Response
+bool indicating success.Check if Last Response is Function Call
+Update or a complete AppendStreamData, contains a function_call or not. Returns a boolean indicating if the last response is a function call.Get the Name of the Last Response's Function Call
+LastResponseIsFunctionCall() returns true. Returns a std::string containing the name of the last response's function call, empty if non-existent.Get the Arguments of the Last Response's Function Call
+LastResponseIsFunctionCall() returns true. Returns a std::string containing the name of the last response's arguments in JSON form, empty if non-existent.Update Conversation
+AppendStreamData was NOT used immediately before it.
+
+For instance, if we made a call to create*(), and provided a callback function to stream and, within this callback, we used AppendStreamData to update the conversation per message, we would NOT want to use this method. In this scenario, the AppendStreamData method would have already updated the conversation, so this method would be a bad idea to call afterwards. Returns a bool indicating success.Export Conversation
+Import Conversation
+Export(). Returns a boolean indicating success.Append Stream Data
+ChatCompletion::create or create_async with a callback supplied. This function should be called from within the stream's callback function receiving the SSEs. Returns a boolean indicating data appending success.Set Function(s)
+Pop Function(s)
+Get Raw JSON Conversation
+operator<<(...) overload. Returns a std::string containing the JSON of the conversation.Get Raw JSON Functions
+Get Functions JSON Object
+Get Internal JSON
+const-ref of the internal JSON object containing the conversation. Returns a const nlohmann::json& object.
+Example Usage
+Completions
+Completions class is defined in completions.h at liboai::Completions, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Completions endpoint of the OpenAI API; this endpoint's functionality can be found below.
+Methods
+completions.h. You can find their function signature(s) below.Create a Completion
+liboai::Response containing response data.Create a Completion (async)
+liboai::FutureResponse containing future response data.optional are not required and are resolved on OpenAI's end if not supplied.
+Example Usage
+Edits
+Edits class is defined in edits.h at liboai::Edits, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Edits endpoint of the OpenAI API; this endpoint's functionality can be found below.
+Methods
+edits.h. You can find their function signature(s) below.Create an Edit
+liboai::Response containing response data.Create an Edit (async)
+liboai::FutureResponse containing future response data.optional are not required and are resolved on OpenAI's end if not supplied.
+Example Usage
+Embeddings
+Embeddings class is defined in embeddings.h at liboai::Embeddings, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Embeddings endpoint of the OpenAI API; this endpoint's functionality can be found below.
+Methods
+embeddings.h. You can find their function signature(s) below.Create an Embedding
+liboai::Response containing response data.Create an Embedding (async)
+liboai::FutureResponse containing future response data.optional are not required and are resolved on OpenAI's end if not supplied.
+Example Usage
+Files
+Files class is defined in files.h at liboai::Files, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Files endpoint of the OpenAI API; this endpoint's functionality can be found below.
+Methods
+files.h. You can find their function signature(s) below.List Files
+liboai::Response containing response data.List Files (async)
+liboai::FutureResponse containing future response data.Upload File
+liboai::Response containing response data.Upload File (async)
+liboai::FutureResponse containing future response data.Delete a File
+liboai::Response containing response data.Delete a File (async)
+liboai::FutureResponse containing future response data.Retrieve File
+liboai::Response containing response data.Retrieve File (async)
+liboai::FutureResponse containing future response data.Retrieve File Content (Download)
+bool indicating failure or success.Retrieve File Content (Download) (async)
+bool indicating failure or success.
+Example Usage
+Fine-Tunes
+FineTunes class is defined in fine_tunes.h at liboai::FineTunes, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Fine-tunes endpoint of the OpenAI API; this endpoint's functionality can be found below.
+Methods
+fine_tunes.h. You can find their function signature(s) below.Create a Fine-Tune
+liboai::Response containing response data.Create a Fine-Tune (async)
+liboai::FutureResponse containing future response data.List Fine-Tunes
+liboai::Response containing response data.List Fine-Tunes (async)
+liboai::FutureResponse containing future response data.Retrieve Fine-Tune
+liboai::Response containing response data.Retrieve Fine-Tune (async)
+liboai::FutureResponse containing future response data.Cancel Fine-Tune
+liboai::Response containing response data.Cancel Fine-Tune (async)
+liboai::FutureResponse containing future response data.List Fine-Tune Events
+liboai::Response containing response data.List Fine-Tune Events (async)
+liboai::FutureResponse containing future response data.Delete Fine-Tune Model
+liboai::Response containing response data.Delete Fine-Tune Model (async)
+liboai::FutureResponse containing future response data.optional are not required and are resolved on OpenAI's end if not supplied.
+Example Usage
+Images
+Images class is defined in images.h at liboai::Images, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Images endpoint of the OpenAI API; this endpoint's functionality can be found below.
+Methods
+images.h. You can find their function signature(s) below.Create an Image
+liboai::Response containing response data.Create an Image (async)
+liboai::FutureResponse containing future response data.Create Image Edit
+liboai::Response containing response data.Create Image Edit (async)
+liboai::FutureResponse containing future response data.Create Image Variation
+liboai::Response containing response data.Create Image Variation (async)
+liboai::FutureResponse containing future response data.optional are not required and are resolved on OpenAI's end if not supplied.
+Example Usage
+Making Use of
+liboailiboai into your codebase, you have a couple of options.Integrate via source code
+liboai implements a cURL wrapper internally and uses a pure C++ JSON solution, liboai's header and implementation files can be added to an existing C++17 project and compiled alongside it. However, in order to do so, the project must have the following elements:liboai's header and implementation files to your existing project and compile.Integrate via a static/dynamic library
+liboai into an existing C++17 project is as a static or dynamic library. This is slightly more complicated than simply including the source code of the library into your existing project, but can certainly be done in few steps.Turning
+liboai into a libraryliboai into a static or dynamic library is not as hard as it may seem. Simply, using your IDE of choice, perform the following:
+
+ 1. Ensure cURL and nlohmann-json are installed.
+ 2. Create a new C++ project.
+ 3. Import the liboai source code (.cpp and .h files).
+ 4. *Link your project to the cURL library.
+ 5. *Make sure you are targeting C++17.
+ 6. *Compile as a static or dynamic library.
+
+liboai into:
+
+ 1. Include the liboai header files (.h files).
+ 2. *Link to the output static or dynamic library you compiled in the above steps.
+
+*NOTE: how you do these steps depends on your choice of development environment. They can either be done in an IDE or a compiler on the command line.
diff --git a/packages/kbot/cpp/packages/liboai/documentation/maintenance/README.md b/packages/kbot/cpp/packages/liboai/documentation/maintenance/README.md
new file mode 100644
index 00000000..c97edff1
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/maintenance/README.md
@@ -0,0 +1,40 @@
+Maintainer Notes
+Repositories and PR numbering
+
+
+
+#1 in our repo is unrelated to PR #1 upstream.Common gh commands
+
+
+gh pr list --repo jasonduncan/liboai
+
+gh pr view 1 --repo jasonduncan/liboai
+
+gh pr diff 1 --repo jasonduncan/liboai
+
+gh pr checkout 1 --repo jasonduncan/liboai
+
+
+gh pr list --repo D7EAD/liboai
+Remotes
+
+git remote -v
+
+
+
+origin: jasonduncan/liboaiupstream: D7EAD/liboaiReview checklist (build / CMake changes)
+
+
diff --git a/packages/kbot/cpp/packages/liboai/documentation/models/README.md b/packages/kbot/cpp/packages/liboai/documentation/models/README.md
new file mode 100644
index 00000000..fd5d0f1e
--- /dev/null
+++ b/packages/kbot/cpp/packages/liboai/documentation/models/README.md
@@ -0,0 +1,45 @@
+find_package and vendored targets.add_subdirectory usage in a parent project.Models
+Models class is defined in models.h at liboai::Models, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Models endpoint of the OpenAI API; this endpoint's functionality can be found below.
+Methods
+models.h. You can find their function signature(s) below.List Models
+liboai::Response containing response data.List Models (async)
+liboai::FutureResponse containing future response data.Retrieve Model
+liboai::Response containing response data.Retrieve Model (async)
+liboai::FutureResponse containing future response data.
+Example Usage
+Moderations
+Moderations class is defined in moderations.h at liboai::Moderations, and its interface can ideally be accessed through a liboai::OpenAI object.
+
+This class and its associated liboai::OpenAI interface allow access to the Moderations endpoint of the OpenAI API; this endpoint's functionality can be found below.
+Methods
+moderations.h. You can find their function signature(s) below.Create a Moderation
+liboai::Response containing response data.Create a Moderation (async)
+liboai::FutureResponse containing future response data.optional are not required and are resolved on OpenAI's end if not supplied.
+Example Usage
+Responses
+Responses class is defined in responses.h at liboai::Responses, and its interface can be accessed through a liboai::OpenAI object.create overload for common fields and a raw JSON overload for full flexibility.Methods
+responses.h. You can find their function signature(s) below.Build a Request Payload
+Create a Response
+liboai::Response containing response data.