Junior — Middle
What major language models do you use in your work?
sobes.tech AI
Answer from AI
In the context of C/C++, large language models (LLMs) are usually not used directly, as they require significant resources and specialized libraries. However, you can use APIs from external services that provide access to LLMs, such as OpenAI GPT, via HTTP requests.
Example of using an HTTP request to an LLM API in C++ with the libcurl library:
#include <curl/curl.h>
#include <iostream>
int main() {
CURL *curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://api.openai.com/v1/chat/completions");
// Here you need to add headers and request body with API key and model parameters
// For simplicity, the example is incomplete
CURLcode res = curl_easy_perform(curl);
if(res != CURLE_OK)
std::cerr << "curl_easy_perform() failed: " << curl_easy_strerror(res) << std::endl;
curl_easy_cleanup(curl);
}
return 0;
}
Thus, in C/C++, LLMs are more often integrated through external services rather than run models locally.