Skip to content

Commit e930507

Browse files
committed
feat: added a main header with a single entry point
1 parent 880f2f7 commit e930507

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

include/perplexity.h

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#ifndef PERPLEXITY_CPP_PERPLEXITY_H
2+
#define PERPLEXITY_CPP_PERPLEXITY_H
3+
#pragma once
4+
5+
/**
6+
* @file perplexity.h
7+
* @brief The main header file of the Perplexity C++ library
8+
*
9+
* Includes all the necessary components to work with the Perplexity API.
10+
* This is the only file that needs to be attached to use the library.
11+
*
12+
* @example Easy to use:
13+
* @code
14+
* #include <perplexity/perplexity.hpp>
15+
*
16+
* int main() {
17+
* perplexity::Client client("your-api-key");
18+
*
19+
* auto request = perplexity::ChatRequest("sonar-pro")
20+
* .add_message(perplexity::Message::user("Hello, world!"));
21+
*
22+
* auto response = client.chat(request);
23+
* std::cout << response.content << std::endl;
24+
*
25+
* return 0;
26+
* }
27+
* @endcode
28+
*
29+
* @version 1.0.0
30+
* @author Perplexity C++ Library
31+
* @license MIT
32+
*/
33+
34+
// Library version
35+
#define PERPLEXITY_CPP_VERSION_MAJOR 1
36+
#define PERPLEXITY_CPP_VERSION_MINOR 0
37+
#define PERPLEXITY_CPP_VERSION_PATCH 0
38+
39+
#define PERPLEXITY_CPP_VERSION \
40+
(PERPLEXITY_CPP_VERSION_MAJOR * 10000 + \
41+
PERPLEXITY_CPP_VERSION_MINOR * 100 + \
42+
PERPLEXITY_CPP_VERSION_PATCH)
43+
44+
// Main Library Components
45+
#include "exceptions.h"
46+
#include "config.h"
47+
#include "models.h"
48+
#include "HttpClient.h"
49+
#include "RateLimiter.h"
50+
#include "client.h"
51+
52+
/**
53+
* @namespace perplexity
54+
* @brief The main namespace of the Perplexity C++ library
55+
*
56+
* It contains all classes and functions for working with the Perplexity API.
57+
*/
58+
namespace perplexity {
59+
60+
/**
61+
* @brief Returns the library version as a string
62+
*/
63+
inline std::string get_version() {
64+
return std::to_string(PERPLEXITY_CPP_VERSION_MAJOR) + "." +
65+
std::to_string(PERPLEXITY_CPP_VERSION_MINOR) + "." +
66+
std::to_string(PERPLEXITY_CPP_VERSION_PATCH);
67+
}
68+
69+
using ChatClient = Client;
70+
71+
} // namespace perplexity
72+
#endif //PERPLEXITY_CPP_PERPLEXITY_H

0 commit comments

Comments
 (0)