Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaks #30

Open
olebol opened this issue Dec 5, 2024 · 0 comments
Open

Leaks #30

olebol opened this issue Dec 5, 2024 · 0 comments

Comments

@olebol
Copy link

olebol commented Dec 5, 2024

The whole library (maybe the json library) leaks. Might be related to the use of the libcurl library. Specifically, the leaks are occurring in the curl_slist_append function.

Tested as follows on linux:

try {
        openai::start();
        
        auto chat = openai::chat().create({
	        {"model", "gpt-4o-mini"},
	        {"messages",
		        {
			        {
				        {"role", "system"},
				        {"content", SYSTEM_PROMPT},
			        },
			        {
				        {"role", "user"},
				        {"content", query},
				        {"max_tokens", MAX_TOKENS},
			        },
		        }},
        });
        
        response = chat["choices"][0]["message"]["content"];
} catch (const exception &e) {
        cerr << "Error: " << e.what() << '\n';
        response = "I'm sorry, I'm having trouble processing your request.";
}
	
cout << response << endl;

But I've tried it with the example instead and it leaks as well.

Noticed through compiling with -g --fsanitize=true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant