DF-0
DF-0: Data processing Framework with Zero-overhead
Loading...
Searching...
No Matches
embed.h
1/**************************************************************************/
2/* */
3/* DF-0: Data processing Framework with Zero-overhead */
4/* */
5/* Copyright (c) DF-0 Team https://github.com/df0-io/df0 */
6/* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-DF0-Commercial */
7/* */
8/**************************************************************************/
9
10#ifndef DF0_OPENAI_EMBED_H
11#define DF0_OPENAI_EMBED_H
12
13#include "pipeline/element_base.hpp"
14#include "openai_export.h"
15#include "message.h"
16#include "pimpl.h"
17#include "audit/auditor_ref.hpp"
18#include "audit/with_auditor.hpp"
19#include <concepts>
20#include <string>
21
22namespace df0
23{
24namespace openai
25{
26
27enum class embed_model
28{
30 text_embedding_3_small,
32 text_embedding_3_large,
34 text_embedding_ada_002,
35};
36
37template<typename auditor_type = audit::null_auditor>
38class DF0_OPENAI_EXPORT embed
39 : public pipeline::transformer_element<embed<auditor_type>>,
40 public with_pimpl<embed<auditor_type>>,
41 private audit::with_auditor<auditor_type>
42{
43public:
52 template<audit::stateless_auditor stateless_auditor_type = auditor_type>
54 const std::string& api_key,
55 embed_model model = embed_model::text_embedding_3_small)
56 : embed(api_key, model, audit::auditor_ref<stateless_auditor_type>{})
57 {}
58
59 explicit embed(
60 const std::string& api_key,
61 embed_model model,
62 audit::auditor_ref<auditor_type> auditor);
63
70 continuation operator()(message_ptr msg, const message_callbacks& emit_message);
71
72protected:
73 using audit::with_auditor<auditor_type>::auditor;
74
75private:
76 using with_pimpl<embed<auditor_type>>::impl;
77};
78
79// Deduction guide for CTAD
80embed(const std::string&, embed_model) -> embed<audit::null_auditor>;
81
82} // namespace openai
83} // namespace df0
84
85#endif //DF0_OPENAI_EMBED_H
continuation operator()(message_ptr msg, const message_callbacks &emit_message)
Executes transform operation for given node data.
embed(const std::string &api_key, embed_model model=embed_model::text_embedding_3_small)
Constructs the component with the default stateless auditing policy.
Definition embed.h:53
Callback bundle used by pipeline elements to emit messages.
Definition message.h:90