Coder Social home page Coder Social logo

d7ead / liboai Goto Github PK

View Code? Open in Web Editor NEW
335.0 335.0 57.0 906 KB

A C++17 library to access the entire OpenAI API.

Home Page: https://openai.com/api/

License: MIT License

C++ 99.56% CMake 0.44%
ai api artificial-intelligence chatgpt chatgpt-api chatgpt3 dall-e generator gpt interface library machine-learning ml neural-network openai openai-api

liboai's Introduction

Contact me on:

Statistics



Dread's Activity Graph

Recent/Upcoming Projects

  • unnamed:
    • a privacy-oriented, secure message distribution network. More to come.
  • liboai (released):
    • a C++17 static and dynamic library to access the entire OpenAI API.
  • Hash++ (released):
    • a header-file only library that allows a user to retrieve multiple types of hashes from data, files, and files in nested directories--all through a simple, lightweight interface!
  • Everything else in the back of my head...

liboai's People

Contributors

d7ead avatar huckdirks avatar jmgr avatar khei4 avatar lodenrogue avatar pkeir avatar pkusunjy avatar sasmaster avatar seanchann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

liboai's Issues

error LNK2019: unresolved external symbol with brand new project

Describe the bug

I just created an empty hello world project and included liboai, nlohmann-json and cURL to it.

When I try to compile it now, I get the following errors:

1>Blade.obj : error LNK2019: unresolved external symbol "public: virtual __cdecl liboai::netimpl::Session::~Session(void)" (??1Session@netimpl@liboai@@UEAA@XZ) referenced in function "class liboai::Response __cdecl liboai::netimpl::Delete<class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&>(class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&)" (??$Delete@$$QEAVUrl@components@netimpl@liboai@@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@netimpl@liboai@@YA?AVResponse@1@$$QEAVUrl@components@01@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z)
1>Blade.obj : error LNK2019: unresolved external symbol "public: class liboai::Response __cdecl liboai::netimpl::Session::Get(void)" (?Get@Session@netimpl@liboai@@QEAA?AVResponse@3@XZ) referenced in function "class liboai::Response __cdecl liboai::netimpl::Get<class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&>(class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&)" (??$Get@$$QEAVUrl@components@netimpl@liboai@@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@netimpl@liboai@@YA?AVResponse@1@$$QEAVUrl@components@01@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z)
1>Blade.obj : error LNK2019: unresolved external symbol "public: class liboai::Response __cdecl liboai::netimpl::Session::Post(void)" (?Post@Session@netimpl@liboai@@QEAA?AVResponse@3@XZ) referenced in function "class liboai::Response __cdecl liboai::netimpl::Post<class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&>(class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&)" (??$Post@$$QEAVUrl@components@netimpl@liboai@@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@netimpl@liboai@@YA?AVResponse@1@$$QEAVUrl@components@01@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z)
1>Blade.obj : error LNK2019: unresolved external symbol "public: class liboai::Response __cdecl liboai::netimpl::Session::Delete(void)" (?Delete@Session@netimpl@liboai@@QEAA?AVResponse@3@XZ) referenced in function "class liboai::Response __cdecl liboai::netimpl::Delete<class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&>(class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&)" (??$Delete@$$QEAVUrl@components@netimpl@liboai@@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@netimpl@liboai@@YA?AVResponse@1@$$QEAVUrl@components@01@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z)
1>Blade.obj : error LNK2019: unresolved external symbol "private: void __cdecl liboai::netimpl::Session::SetOption(class liboai::netimpl::components::Url const &)" (?SetOption@Session@netimpl@liboai@@AEAAXAEBVUrl@components@23@@Z) referenced in function "void __cdecl liboai::netimpl::set_options<class liboai::netimpl::components::Url,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > >(class liboai::netimpl::Session &,class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&)" (??$set_options@VUrl@components@netimpl@liboai@@V?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@netimpl@liboai@@YAXAEAVSession@01@$$QEAVUrl@components@01@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z)
1>Blade.obj : error LNK2019: unresolved external symbol "private: void __cdecl liboai::netimpl::Session::SetOption(class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > const &)" (?SetOption@Session@netimpl@liboai@@AEAAXAEBV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z) referenced in function "void __cdecl liboai::netimpl::set_options<class liboai::netimpl::components::Url,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > >(class liboai::netimpl::Session &,class liboai::netimpl::components::Url &&,class std::map<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,struct liboai::netimpl::components::CaseInsensitiveCompare,class std::allocator<struct std::pair<class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const ,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > > > > &&)" (??$set_options@VUrl@components@netimpl@liboai@@V?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@netimpl@liboai@@YAXAEAVSession@01@$$QEAVUrl@components@01@$$QEAV?$map@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@UCaseInsensitiveCompare@components@netimpl@liboai@@V?$allocator@U?$pair@$$CBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@V12@@std@@@2@@std@@@Z)

I must add that this is actually my first C++ project, so the error might be entirely on my side.

To Reproduce

  1. Create a new Visual studio C++ console command project
  2. Include the liboai, nlohmann-json and cURL librairies
  3. Attempt to compile

Code snippets

#include <iostream>
#include "liboai.h"

using namespace liboai;

int main()
{
    std::cout << "Hello World!\n";
}

OS

Windows 10

Library version

liboai 3.0.2

Raw_json is null when providing a stream parameter to ChatCompletion->create_async

Describe the bug

When adding a stream callback to the simple async conversation example, the raw_json is null, and an exception happens upon calling GetLastResponse()

To Reproduce

  1. Create a new project
  2. Use the example code for Chat completion
  3. Add a stream function to the call
  4. Attempt to output the last response

Code snippets

#include <iostream>

#include "include/liboai.h"

using namespace liboai;

bool streamResponse(std::string output, intptr_t context)
{
	std::cout << output << std::endl;
	return true;
}

int main()
{
    OpenAI oai;
    Conversation convo;

    convo.AddUserData("Hello, how are you?");

    if (oai.auth.SetKeyEnv("OPENAI_API_KEY")) {
        
        std::optional<std::function<bool(std::string, intptr_t)>> stream = streamResponse;

        FutureResponse fut = oai.ChatCompletion->create_async(
	        "gpt-3.5-turbo",
	        convo,
	        std::nullopt,
	        std::nullopt,
	        std::nullopt,
	        stream
        );
        
        fut.wait();
        Response response = fut.get();
        
        std::cout << "Raw Response: " << response.raw_json << std::endl;
        
        convo.Update(response);
        
        std::cout << convo.GetLastResponse();
    }
}

OS

Windows 10

Library version

liboai 3.0.2

Question about stream .

Describe the feature or improvement you're requesting

As you know, OpenAI's response is generally in the stream format. If JSON format is used, the response will become very slow. Such a long wait can make everyone lose interest in the software.

  1. How can we add the stream parameter to the request to make OpenAI return data in the stream format? Should the stream parameter be added to the body or headers?

  2. How will liboai handle the data returned by OpenAI in the stream format? How to implement printing output word by word?

Additional context

No response

SSL certification error

Describe the bug

Hello guys,
First of all I would like to say thank you for this work and providing to the community this c++ Library 👍.
I was on OpenAI API website looking for a C++ option and I came across your library. I was able to easily build it and integrate it into our project without any issue (Android & iOS). Our code is C++ based - obviously 😊.
To make the learning curve simple, I just took your “conversasion” example and used it without any modification. Just to make sure that everything is working fine. Unfortunatunatly the “ChatCompletion” call is failling. This is the error/exception message that I have:
liboai::netimpl::Session::Perform(): Peer certificate cannot be authenticated with given CA certificates (E_CURLERROR:0x06)

Based on your examples/tutorials I’m not seeing anywhere where you need to:
1) provide a certificate file. If this is needed and it omitted in the example could please tell which Api call to use. 

2) or the need to turn of the SSL verification - to do something like this:
	curl_ = curl_easy_init();
	curl_easy_setopt(curl_, CURLOPT_SSL_VERIFYPEER, 0L);


Would you know how to fix this issue?

Thank you,
Stay safe

To Reproduce

  1. Build current version for your iOS or Android project. There is nothing special if your have Curl & Json
  2. Use the conversation code/example to test

Code snippets

liboai::OpenAI oai;
        
        // create a conversation
        liboai::Conversation convo;

        // add a message to the conversation
        convo.AddUserData("Hello, how are you?");

        if (oai.auth.SetKey(m_openaiApiKey))
        {
            try
            {
                liboai::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;
            }
        }

OS

iOS

Library version

liboai v3.2.1

static bool _flag = false;

Describe the feature or improvement you're requesting

_ Flag is only used in the construction of the CurlHolder class. Why not include it in the CurlHolder class to avoid many warnings

Additional context

No response

chat component missing function name

Describe the bug

when using the function feature with chat. if the "function_call" in response from the OpenAI, but the GetLastFunctionCallName function does not return any function name.

To Reproduce

  1. when using chat components: create a function call.
  2. if the response data has a function_call field
  3. call convo.Update(response);
  4. call convo.GetLastFunctionCallName(). the function name is empty

Code snippets

No response

OS

linux

Library version

liboai 4.0.1

Can't forward declare Conversation class

C++ doesn't allow forward declaration of nested classes.
Nesting of classes such as Conversation makes the API less flexible by forcing user to expose the API declaration in app headers just for the sake of defining member variables as pointers.

DLL building error in VS 2019

Describe the bug

When I try to build a dll or a lib from the source code, I get errors. The errors are at chat.cpp line 666 and at response.cpp line 64
image

To Reproduce

  1. Create new C++ empty Project in Visual Studio 19
  2. Import all of the liboai .h and .cpp files
  3. Set it to build .dll with C++17
  4. Try to build the project

Code snippets

std::ostream& liboai::operator<<(std::ostream& os, const Conversation& conv) {
	os << conv.GetRawConversation() << std::endl << (conv.HasFunctions() ? conv.GetRawFunctions() : "");

	return os;
}
std::ostream& liboai::operator<<(std::ostream& os, const Response& r) {
	!r.raw_json.empty() ? os << r.raw_json.dump(4) : os << "null";
	return os;
}


### OS

Windows

### Library version

all

Documenting the rest of arguments for create_async

Describe the feature or improvement you're requesting

Hi.
I am trying to learn how to use async methods. I see some optional arguments in create_async,which I don't completely understand.
Could please elaborate on these:

std::optional<std::function<bool(std::string, intptr_t)>> stream, //Is it a callback function? what is the purpose of its arguments?
std::optional<std::vector<std::string>> stop,  // what does this do?
std::optional<uint16_t> max_tokens, // what does this do?
std::optional<float> presence_penalty,// what does this do?
std::optional<float> frequency_penalty,// what does this do?
std::optional<std::unordered_map<std::string, int8_t>> logit_bias,// what does this do?
std::optional<std::string> user// what does this do?

I haven't found documentation regarding these.

Thanks.

Additional context

No response

Unclear Error Thrown on Invalid Filepath Provided

Describe the bug

When a non-existent or invalid file is provided for any function expecting a std::filesystem::path argument, an error is thrown within CheckResponse that states a network error occurred. This is obviously not the case, and each function that can take a filepath should check its validity manually as cpr::File doesn't seem to check it in its constructor.

To Reproduce

Provide an invalid filepath to a function such as liboai::Audio::transcribe. Throws 0x04.

Code snippets

No response

OS

Windows

Library version

v2.2.0

cmake: find_package(CURL CONFIG REQUIRED) can't find curl on Ubuntu

Describe the bug

$ dpkg -L libcurl4-openssl-dev
/.
/usr
/usr/bin
/usr/bin/curl-config
/usr/include
/usr/include/x86_64-linux-gnu
/usr/include/x86_64-linux-gnu/curl
/usr/include/x86_64-linux-gnu/curl/curl.h
...(omitted)
/usr/share/doc/libcurl4-openssl-dev/changelog.Debian.gz

$ cd liboai && cmake -Bbuild .
CMake Error at CMakeLists.txt:6 (find_package):
  Could not find a package configuration file provided by "CURL" with any of
  the following names:

    CURLConfig.cmake
    curl-config.cmake

  Add the installation prefix of "CURL" to CMAKE_PREFIX_PATH or set
  "CURL_DIR" to a directory containing one of the above files.  If "CURL"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

Just installing by apt like this doesn't work.
I think this is because find_package(CURL CONFIG REQUIRED) on CMakeLists.txt expect vcpkg use.

Replacing find_package(CURL CONFIG REQUIRED) and target_link_libraries(oai PRIVATE CURL::libcurl)
with target_link_libraries(oai PRIVATE curl) works well.

I'd be very happy if this works on Ubuntu 22.04. :)

To Reproduce

$ sudo apt update && sudo apt upgrade && sudo apt install curl && sudo apt-get install curl libcurl4-openssl-dev
$ cd liboai && cmake -Bbuild .

Code snippets

No response

OS

ubuntu 22.04

Library version

f0f2b45

Memory access violation on "A connection error occurred" exception

Describe the bug

This simple example leads to a crash with some memory access violation in xmemory.h ( I am on windows)

#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;
    }
    
    ...
  }
}

The lib crashes somewhere after

throw liboai::exception::OpenAIException(
  		"A connection error occurred",
  		liboai::exception::EType::E_CONNECTIONERROR,
  		"liboai::Response::CheckResponse()"
  	);

is called. I can't see the exact error location on the library side in call stack, but eventually it leads to a crash in xmemory.h.

MSVS spits this:

Exception thrown at 0x00007FF8D13ECD29 in TestApp.exe: Microsoft C++ exception: liboai::exception::OpenAIException at memory location 0x00000046F09DBFC0.
Exception thrown at 0x00007FF7DD1C82C5 in TestApp.exe: 0xC0000005: Access violation reading location 0xFFFFFFFFFFFFFFFF.

In my case I have no credits left in OpenAI API. Have you ever tested that case?

To Reproduce

Run the code I provided below. But maybe it is also a special case related to the fact the account has no credits left.

Code snippets

int main()
{
    OpenAI oai;
    if (oai.auth.SetKey("my key goes here"))
    {
        try {

           /* Response res = oai.Image->create(
                "A snake in the grass!",
                1,
                "256x256"
            );*/

            Response response = oai.Image->create(
                "a siamese cat!"
            );

            std::cout << response["data"][0]["url"] << std::endl;
        }
        catch (std::exception& e)
        {
            std::cout << e.what() << std::endl;
            std::quick_exit(EXIT_FAILURE);
        }
   }

    std::cout << "Hello World!\n";
    return 0;
}

OS

Windows

Library version

3.0.0

can't get stream response since no examples.

Describe the feature or improvement you're requesting

I download the dev branch. and I built project from below example:
https://github.com/D7EAD/liboai/blob/main/documentation/chat/examples/create_chat_completion.cpp

one problem is I don't know how to call "AppendStreamData".
another problem is I don't know how to add "stream" parameter into request: oai.ChatCompletion->create

so, I can't get response as stream.

Waiting for update. thanks!

Additional context

No response

audio transcription with buffer not work

Describe the bug

In Audio components, the transcribe API if you use the following code:

netimpl::components::Multipart form = { {"file", netimpl::components::Buffer{buffer.begin(), buffer.end(), "test.wav"}}, {"model", model}};

then in curl post a request to OpenAI server that not work. the error is a request body, not a file.

To Reproduce

  1. use transcribe API. but with a buffer part.
  2. call function send a HTTP request

Code snippets

in void liboai::netimpl::Session::SetMultipart(components::Multipart&& multipart):

`
			else if (part.is_buffer) {
				mimedata.push_back(curl_mime_addpart(this->mime));
				e[1] = curl_mime_name(mimedata.back(), part.name.c_str());
				e[2] = curl_mime_data(mimedata.back(), reinterpret_cast<const char*>(part.data), part.datalen);
			}
`

not apppend `curl_mime_filename(mimedata.back(),
                                     part.value.c_str());`  caused problems

OS

linux

Library version

liboai 4.0.1

Proxy issue

Describe the bug

"e[1] = curl_easy_setopt(this->curl_, CURLOPT_PROXY, proxies_[protocol]);"

should be

“e[1] = curl_easy_setopt(this->curl_, CURLOPT_PROXY, proxies_[protocol].c_str());”

To Reproduce

Bug in the "netimpl.cpp" file

Code snippets

No response

OS

windows10

Library version

nope

Add Installation Documentation

Describe the feature or improvement you're requesting

Add documentation that outlines the ways one can incorporate the library into their existing projects.

For instance, write documentation that covers the following options for integrating liboai into projects:

  • How to incorporate liboai into a project via its source code.
  • How to incorporate liboai into a project as a static/dynamic library.

This will help beginner programmers more easily make use of the library without hassle.

Additional context

N/A

Error from cURL: Failed writing received data to disk/application

Describe the bug

I am trying to test run the example for generating completions within a code base just to get up and running with a project I'm trying to make: documentation/completions/examples/generate_completion.cpp

I am running Alpine Linux Edge which currently has curl at version 8.7.1 and might be the issue.

To Reproduce

Run the mentioned code example documentation/completions/examples/generate_completion.cpp with one difference being that I use SetKey instead of SetKeyEnv.

Code passes through the authentication fine and I can see that the request is received by OpenAI because my "Last Used" metric on the website has updated (began as "Never Used" - this started on a fresh API key).

Result is this error: liboai::netimpl::Session::Perform(): Failed writing received data to disk/application (E_CURLERROR:0x06)

Code snippets

OpenAI oai;
if (oai.auth.SetKey(apiKey)) {
	try {
		Response response = oai.Completion->create(
				"text-davinci-003",
				"Say this is a test",
				std::nullopt,
				7
				);
		std::cout << response["choices"][0]["text"].get<std::string>() << std::endl;
	}
	catch (std::exception& e) {
		std::cout << e.what() << std::endl;
	}
}

OS

Alpine Linux Edge (at post date)

Library version

liboai: main branch at issue post date, curl: 8.7.1, nlohmann-json: 3.11.3

error: use of deleted function

Describe the feature or improvement you're requesting

/usr/include/c++/9/bits/unique_ptr.h:857:30: error: use of deleted function ‘liboai::ChatCompletion::ChatCompletion()’
857 | { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }

Additional context

No response

The AppendStreamData() function may lose some data.

Describe the bug

The AppendStreamData() function may lose some of the data returned by the streaming request. This happens because the response string may contain either one or multiple JSON objects, ending with data: [DONE]. Consequently, there is a possibility that the last data returned by the streaming request might look like this:

data: {"id":"xxx","object":"chat.completion.chunk",...}\ndata: [DONE]

In this scenario, locating data: [DONE] provides a valid position (not std::string::npos), but the preceding response is ignored, resulting in data loss.

To Reproduce

Fetch tag v4.0.1

Code snippets

bool liboai::Conversation::AppendStreamData(std::string data) & noexcept(false) {
    if (!data.empty()) {
        if (data.find("data: [DONE]") == std::string::npos) { // <-- here find in raw string
        }
        else {
            // the response is complete, erase the "pending" flag
            return true; // last message received
        }
    }
    return false; // data is empty
}

OS

macOS

Library version

liboai v4.0.1

How do I use cmake to import a compiled library

Describe the bug

sorry, i am fresh, i git clone this repo, and build it in my centos server, then i use CMakeLists.txt to link it

include_directories(src/liboai/include)
link_directories(/usr/local/lib)
target_link_libraries(${_target}
            liboai.a) // target_link_libraries(${_target} oai) 

it does not work, and error.

====================[ Build | greeter_async_server | Debug ]====================
/root/.cache/JetBrains/RemoteDev/dist/1466a3f304df6_CLion-231.8109.141/bin/cmake/linux/x64/bin/cmake --build /grpc/grpc-gpt/cmake-build-debug --target greeter_async_server -j 14
[1/2] Building CXX object CMakeFiles/greeter_async_server.dir/src/server/greeter_async_server.cc.o
FAILED: CMakeFiles/greeter_async_server.dir/src/server/greeter_async_server.cc.o 
/usr/bin/c++ -DCARES_STATICLIB -I/grpc/grpc-gpt/cmake-build-debug -I/grpc/grpc-gpt/src/liboai/include -isystem /root/.local/include -g -fdiagnostics-color=always -std=gnu++2a -MD -MT CMakeFiles/greeter_async_server.dir/src/server/greeter_async_server.cc.o -MF CMakeFiles/greeter_async_server.dir/src/server/greeter_async_server.cc.o.d -o CMakeFiles/greeter_async_server.dir/src/server/greeter_async_server.cc.o -c /grpc/grpc-gpt/src/server/greeter_async_server.cc
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::Audio; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::Audio>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:57:75:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::Audio::Audio()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:31,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/audio.h:20:4: note: ‘liboai::Audio::Audio()’ is implicitly deleted because the default definition would be ill-formed:
    Audio() = default;
    ^~~~~
/grpc/grpc-gpt/src/liboai/include/components/audio.h:20:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /grpc/grpc-gpt/src/liboai/include/components/../core/authorization.h:19,
                 from /grpc/grpc-gpt/src/liboai/include/components/audio.h:14,
                 from /grpc/grpc-gpt/src/liboai/include/liboai.h:31,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/../core/network.h:23:4: note: ‘constexpr liboai::Network::Network() noexcept’ is implicitly deleted because its exception-specification does not match the implicit exception-specification ‘noexcept (false)’
    Network() noexcept = default;
    ^~~~~~~
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::Azure; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::Azure>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:63:75:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::Azure::Azure()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:32,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/azure.h:18:4: note: ‘liboai::Azure::Azure()’ is implicitly deleted because the default definition would be ill-formed:
    Azure() = default;
    ^~~~~
/grpc/grpc-gpt/src/liboai/include/components/azure.h:18:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::ChatCompletion; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::ChatCompletion>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:69:102:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::ChatCompletion::ChatCompletion()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/components/azure.h:13,
                 from /grpc/grpc-gpt/src/liboai/include/liboai.h:32,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/chat.h:165:4: note: ‘liboai::ChatCompletion::ChatCompletion()’ is implicitly deleted because the default definition would be ill-formed:
    ChatCompletion() = default;
    ^~~~~~~~~~~~~~
/grpc/grpc-gpt/src/liboai/include/components/chat.h:165:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::Completions; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::Completions>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:75:92:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::Completions::Completions()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:34,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/completions.h:20:4: note: ‘liboai::Completions::Completions()’ is implicitly deleted because the default definition would be ill-formed:
    Completions() = default;
    ^~~~~~~~~~~
/grpc/grpc-gpt/src/liboai/include/components/completions.h:20:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::Edits; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::Edits>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:81:74:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::Edits::Edits()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:35,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/edits.h:20:4: note: ‘liboai::Edits::Edits()’ is implicitly deleted because the default definition would be ill-formed:
    Edits() = default;
    ^~~~~
/grpc/grpc-gpt/src/liboai/include/components/edits.h:20:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::Embeddings; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::Embeddings>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:87:89:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::Embeddings::Embeddings()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:36,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/embeddings.h:20:4: note: ‘liboai::Embeddings::Embeddings()’ is implicitly deleted because the default definition would be ill-formed:
    Embeddings() = default;
    ^~~~~~~~~~
/grpc/grpc-gpt/src/liboai/include/components/embeddings.h:20:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::Files; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::Files>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:93:74:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::Files::Files()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:37,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/files.h:20:4: note: ‘liboai::Files::Files()’ is implicitly deleted because the default definition would be ill-formed:
    Files() = default;
    ^~~~~
/grpc/grpc-gpt/src/liboai/include/components/files.h:20:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::FineTunes; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::FineTunes>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:99:86:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::FineTunes::FineTunes()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:38,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/fine_tunes.h:20:4: note: ‘liboai::FineTunes::FineTunes()’ is implicitly deleted because the default definition would be ill-formed:
    FineTunes() = default;
    ^~~~~~~~~
/grpc/grpc-gpt/src/liboai/include/components/fine_tunes.h:20:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::Images; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::Images>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:105:77:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::Images::Images()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:39,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/images.h:20:4: note: ‘liboai::Images::Images()’ is implicitly deleted because the default definition would be ill-formed:
    Images() = default;
    ^~~~~~
/grpc/grpc-gpt/src/liboai/include/components/images.h:20:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::Models; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::Models>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:111:77:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::Models::Models()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:40,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/models.h:20:4: note: ‘liboai::Models::Models()’ is implicitly deleted because the default definition would be ill-formed:
    Models() = default;
    ^~~~~~
/grpc/grpc-gpt/src/liboai/include/components/models.h:20:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
In file included from /usr/include/c++/8/memory:80,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:19:
/usr/include/c++/8/bits/unique_ptr.h: In instantiation of ‘typename std::_MakeUniq<_Tp>::__single_object std::make_unique(_Args&& ...) [with _Tp = liboai::Moderations; _Args = {}; typename std::_MakeUniq<_Tp>::__single_object = std::unique_ptr<liboai::Moderations>]’:
/grpc/grpc-gpt/src/liboai/include/liboai.h:117:92:   required from here
/usr/include/c++/8/bits/unique_ptr.h:835:30: error: use of deleted function ‘liboai::Moderations::Moderations()’
     { return unique_ptr<_Tp>(new _Tp(std::forward<_Args>(__args)...)); }
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /grpc/grpc-gpt/src/liboai/include/liboai.h:41,
                 from /grpc/grpc-gpt/src/server/greeter_async_server.cc:28:
/grpc/grpc-gpt/src/liboai/include/components/moderations.h:20:4: note: ‘liboai::Moderations::Moderations()’ is implicitly deleted because the default definition would be ill-formed:
    Moderations() = default;
    ^~~~~~~~~~~
/grpc/grpc-gpt/src/liboai/include/components/moderations.h:20:4: error: use of deleted function ‘constexpr liboai::Network::Network()’
ninja: build stopped: subcommand failed.

To Reproduce

ll /usr/local/lib
total 24444
-rw-r--r-- 1 root root 25025096 Jun 17 17:24 liboai.a
drwxr-xr-x 3 root root     4096 Nov  2  2020 python3.6

Code snippets

No response

OS

centos8

Library version

liboai v3

Cannot Download images

Describe the bug

Hi guys,
I’m having an issue downloading an image that ChatGPT generated for me in a conversation and it is providing me the link via the conversation. Once I get the link from the AI, I will try to download that image, but I’m getting an error. Not sure what I need to do, or what I’m missing here.

A) This is response from ChatGPT with link:

Statistical Measures

  • Mean: 3
  • Median: 3
  • Variance: 2 (indicating the spread of scores is significant)

Notable Trends

  1. High Satisfaction: Positive feedback consistently highlights the helpful and responsive nature of the staff and the quality of services provided.
  2. Neutral Responses: Many customers found the service acceptable but not remarkable.
  3. Dissatisfaction: Common issues include lengthy waiting times, poor quality of products, and unresponsive customer support.
    ![Score Distribution](https://www.chartgo.com/chart?fontsize=13&charttitle=Score+Distribution&charttype=bar&is3d=no&xlabels=Scores&marker=no&titlefont=3&values=5%3B4%3B3%3B2%3B1%3B&datavalues=20&legend=&valuelabels=yes)

B) When I get the response from ChatGPT in point 1) I will use the url provided to try to download the image with this call:

  • “url” is the image url provide by ChatGPT.

  • “m_oai” is the openai interface object. It's used to acces all openai functionalities. It’s a data member: liboai::OpenAI m_oai;

    try
    {
        std::string imageName = m_strWritableFilePath + std::string("reportImg.png");
        auto result = liboai::Network::Download(imageName,                    // to
                                                url, // from
                                                m_oai.auth.GetAuthorizationHeaders());
    }
    catch (std::exception& e)
    {
        std::cout << "download image error: " << e.what() << std::endl;
    }
    

I will always get this error:
liboai::Response::CheckResponse(): 404 (E_BADREQUEST:0x01)

So my questions are:
1) Is my call to download the image is correct. Basically I hope I’m not making a wrong call to the API.
2) Perhaps I need to tell the API to keep the image available so I can download it, not sure.

Some help will be appreciated.
Thank you,
Stay safe

To Reproduce

  1. Start a conversation with ChatGPT.
  2. Give it some numerical values (like a bar chart or pie chart or any data you may have)
  3. Ask it to Generate a graph based on the data you give it and provide you the url of the image for you download it.
  4. Try to download the image.

Code snippets

This is call I use to try to download the image:

      try
      {
          std::string imageName = m_strWritableFilePath + std::string("reportImg.png");
          auto result = liboai::Network::Download(imageName,                    // to
                                                  url, // from
                                                  m_oai.auth.GetAuthorizationHeaders());
      }
      catch (std::exception& e)
      {
          std::cout << "download image error: " << e.what() << std::endl;
      }

OS

macOS & iOS

Library version

liboai v4.0.1

Remove final from class OpenAI

Describe the feature or improvement you're requesting

In some scenarios, you need to extend this class without directly modifying the source code.

Additional context

No response

Azure endpoint

Describe the feature or improvement you're requesting

Microsoft azure provides a REST API very similar to the one employed by OpenAI for the same service. Would this be of any interest for the project?

Additional context

For example, for chat completion api, Azure looks like

curl $AZURE_OPENAI_ENDPOINT/openai/deployments/gpt-35-turbo/chat/completions?api-version=2023-05-15 \
  -H "Content-Type: application/json" \
  -H "api-key: $AZURE_OPENAI_KEY" \
  -d '{"messages":[{"role": "system", "content": "You are a helpful assistant."},{"role": "user", "content": "Does Azure OpenAI support customer managed keys?"},{"role": "assistant", "content": "Yes, customer managed keys are supported by Azure OpenAI."},{"role": "user", "content": "Do other Azure Cognitive Services support this too?"}]}'

While openAI is

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
     "model": "gpt-3.5-turbo",
     "messages": [{"role": "user", "content": "Say this is a test!"}],
     "temperature": 0.7
   }'

Move liboai.h into includes directory for easier integration of the library

Describe the feature or improvement you're requesting

Hi. Just a suggestion for more convenient includes hierarchy. Header liboai.h is not under includes dir which requires adding top dir into includes of MSVC to get this one in. Isn't it more natural to have all the includes under the same roof? If you accept PRs I can refactor it.
Best,
Mike.

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.