separated request class
This commit is contained in:
parent
2dd76e787e
commit
c8523bc115
8 changed files with 336 additions and 209 deletions
61
Conversation.h
Normal file
61
Conversation.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
// 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;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue