57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
#pragma once
|
|
|
|
// POST /decisions (classification and scoring questions about an input) and
|
|
// POST /content_provenance_checks (does a file carry OpenAI provenance
|
|
// signals). Both are small single-call surfaces of the core API.
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "openai/core/service.h"
|
|
#include "openai/core/upload_file.h"
|
|
|
|
namespace molo::openai::core {
|
|
|
|
struct DecisionQuestion {
|
|
enum class Kind { kPredicate, kChoice, kScore };
|
|
Kind kind = Kind::kPredicate;
|
|
std::string name;
|
|
std::string instructions;
|
|
std::vector<std::string> choices; // kChoice: values
|
|
std::vector<std::string> levels; // kScore: labels, lowest first
|
|
|
|
static DecisionQuestion predicate(std::string name, std::string instructions);
|
|
static DecisionQuestion choice(std::string name, std::string instructions,
|
|
std::vector<std::string> choices);
|
|
static DecisionQuestion score(std::string name, std::string instructions,
|
|
std::vector<std::string> levels);
|
|
clients::body::Json to_json() const;
|
|
};
|
|
|
|
struct DecisionRequest {
|
|
std::string model;
|
|
std::string input_text;
|
|
std::vector<DecisionQuestion> questions; // at least one
|
|
std::string safety_identifier;
|
|
std::string prompt_cache_key;
|
|
clients::body::Json extra;
|
|
|
|
void validate() const;
|
|
clients::body::Json to_json() const;
|
|
};
|
|
|
|
struct ProvenanceRequest {
|
|
UploadFile file; // image or audio
|
|
void validate() const;
|
|
clients::body::MultipartBody to_multipart() const;
|
|
};
|
|
|
|
class DecisionsService : public OpenaiService {
|
|
public:
|
|
using OpenaiService::OpenaiService;
|
|
clients::body::Json decide(const DecisionRequest& request);
|
|
clients::body::Json check_provenance(const ProvenanceRequest& request);
|
|
};
|
|
|
|
} // namespace molo::openai::core
|