haiku-dumber/Conversation.h

61 lines
No EOL
1.6 KiB
C++

// Conversation.h
#pragma once
#include <Handler.h>
#include <String.h>
#include <memory.h>
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
//NEED THIS IN MAKE FILE TO USE PRIVATE HEADERS
//CXXFLAGS = -std=c++17 -Wall -I/boot/system/develop/headers/private
//Build works but Genio doesn't see class definitions unless I use full path ?
#include "/boot/system/develop/headers/private/netservices2/NetServicesDefs.h"
#include "/boot/system/develop/headers/private/netservices2/HttpSession.h"
#include "/boot/system/develop/headers/private/netservices2/HttpRequest.h"
#include "/boot/system/develop/headers/private/netservices2/HttpResult.h"
#include "/boot/system/develop/headers/private/netservices2/HttpFields.h"
#include "/boot/system/develop/headers/private/netservices2/ErrorsExt.h"
//From private headers !
//#include <NetServicesDefs.h>
//#include <HttpSession.h>
//#include <HttpSession.h>
//#include <HttpRequest.h>
//#include <HttpResult.h>
//#include <ErrorsExt.h>
static const uint32 kSendReply = 'krpl';
#include "include/json.hpp"
using json = nlohmann::json;
using namespace BPrivate::Network;
using namespace BPrivate::Network;
class Conversation : public BHandler {
public:
Conversation(BHandler* replyTo);
virtual ~Conversation() ;
virtual void ask(const std::string& prompt);
virtual void MessageReceived(BMessage *msg);
private:
BHandler* replyTarget;
BString ReadOpenAIKey();
BString _apiKey;
BHttpSession _sharedSession = BHttpSession ();
std::optional<BHttpResult> _lastResult;
};