-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOpenAI.h
More file actions
40 lines (32 loc) · 1022 Bytes
/
OpenAI.h
File metadata and controls
40 lines (32 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/**
* @file OpenAI.h
* @brief OpenAI provider built using the same pattern as AzureOpenAI.
*/
#pragma once
#include "IProvider.h"
#include "Option.h"
namespace TUI::ApiProvider
{
class OpenAI : public IProvider
{
public:
OpenAI() = default;
~OpenAI() override = default;
nlohmann::json GetParams() const override;
void Initialize(const nlohmann::json& params) override;
Network::Http::RequestData FormatRequest(const Schema::IServer::LinearHistory& history, bool stream) const override;
Schema::IServer::MessageContent ParseResponse(const std::string& response) const override;
std::optional<Schema::IServer::MessageContent> ParseStreamResponse(const Network::Http::StreamResponse::Event& event) const override;
private:
struct Params
{
std::string url{"https://api.openai.com/v1/responses"};
std::string apiKey;
std::string model;
double temperature{0.5};
std::string reasoningEffort{""};
};
static Option::OptionList<Params> ParamsDefinition;
Params _params;
};
}