Generated file

Copy as Markdown

Other Tools

/* THIS FILE IS AUTOGENERATED FROM TextGenerator.webidl BY Codegen.py - DO NOT EDIT */
#ifndef DOM_TEXTGENERATORBINDING_H_
#define DOM_TEXTGENERATORBINDING_H_
#include "js/CallAndConstruct.h"
#include "js/RootingAPI.h"
#include "js/TypeDecls.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/EnumTypeTraits.h"
#include "mozilla/Span.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/CallbackFunction.h"
#include "mozilla/dom/Nullable.h"
#include "mozilla/dom/PrototypeList.h"
#include "mozilla/dom/ToJSValue.h"
namespace mozilla {
namespace dom {
struct NativePropertyHooks;
class ProtoAndIfaceCache;
class TextGenerationDeltaCallback;
struct TextGenerationLogitBias;
struct TextGenerationLogitBiasAtoms;
struct TextGenerationMessage;
struct TextGenerationMessageAtoms;
struct TextGenerationRequestAtoms;
struct TextGenerationResourceSnapshot;
struct TextGenerationResourceSnapshotAtoms;
struct TextGenerationResources;
struct TextGenerationResourcesAtoms;
struct TextGenerationResultAtoms;
struct TextGenerationSampler;
struct TextGenerationSamplerAtoms;
struct TextGenerationTimings;
struct TextGenerationTimingsAtoms;
struct TextGenerationUsage;
struct TextGenerationUsageAtoms;
class TextGenerator;
struct TextGeneratorCreateOptionsAtoms;
} // namespace dom
} // namespace mozilla
namespace mozilla {
namespace dom {
enum class TextGenerationRole : uint8_t {
System,
User,
Assistant,
};
namespace binding_detail {
template <> struct EnumStrings<TextGenerationRole> {
static constexpr nsLiteralCString Values[3] {
"system"_ns,
"user"_ns,
"assistant"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, TextGenerationRole aArgument, JS::MutableHandle<JS::Value> aValue);
enum class TextGenerationSamplerType : uint8_t {
Logit_bias,
Top_k,
Top_p,
Temperature,
Dist,
};
namespace binding_detail {
template <> struct EnumStrings<TextGenerationSamplerType> {
static constexpr nsLiteralCString Values[5] {
"logit-bias"_ns,
"top-k"_ns,
"top-p"_ns,
"temperature"_ns,
"dist"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, TextGenerationSamplerType aArgument, JS::MutableHandle<JS::Value> aValue);
enum class TextGenerationFinishReason : uint8_t {
Eos,
Length,
Stop_token,
Cancelled,
};
namespace binding_detail {
template <> struct EnumStrings<TextGenerationFinishReason> {
static constexpr nsLiteralCString Values[4] {
"eos"_ns,
"length"_ns,
"stop-token"_ns,
"cancelled"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, TextGenerationFinishReason aArgument, JS::MutableHandle<JS::Value> aValue);
enum class TextGenerationKVCacheDtype : uint8_t {
F32,
F16,
Q8_0,
Q5_1,
Q5_0,
Q4_1,
Q4_0,
};
namespace binding_detail {
template <> struct EnumStrings<TextGenerationKVCacheDtype> {
static constexpr nsLiteralCString Values[7] {
"f32"_ns,
"f16"_ns,
"q8_0"_ns,
"q5_1"_ns,
"q5_0"_ns,
"q4_1"_ns,
"q4_0"_ns,
};
};
} // namespace binding_detail
bool
ToJSValue(JSContext* aCx, TextGenerationKVCacheDtype aArgument, JS::MutableHandle<JS::Value> aValue);
class MOZ_EMPTY_BASES TextGenerationDeltaCallback : public CallbackFunction
{
public:
explicit inline TextGenerationDeltaCallback(JSContext* aCx, JS::Handle<JSObject*> aCallback, JS::Handle<JSObject*> aCallbackGlobal, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCx, aCallback, aCallbackGlobal, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline TextGenerationDeltaCallback(JSObject* aCallback, JSObject* aCallbackGlobal, const FastCallbackConstructor& )
: CallbackFunction(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline TextGenerationDeltaCallback(JSObject* aCallback, JSObject* aCallbackGlobal, JSObject* aAsyncStack, nsIGlobalObject* aIncumbentGlobal)
: CallbackFunction(aCallback, aCallbackGlobal, aAsyncStack, aIncumbentGlobal)
{
MOZ_ASSERT(JS::IsCallable(mCallback));
}
explicit inline TextGenerationDeltaCallback(CallbackFunction* aOther)
: CallbackFunction(aOther)
{
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, const nsACString& text, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "TextGenerationDeltaCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
JS::Rooted<JS::Value> thisValJS(s.GetContext());
if (!ToJSValue(s.GetContext(), thisVal, &thisValJS)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}
return Call(s.GetCallContext(), thisValJS, text, aRv);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(const nsACString& text, ErrorResult& aRv, const char* aExecutionReason = nullptr, ExceptionHandling aExceptionHandling = eReportExceptions, JS::Realm* aRealm = nullptr)
{
MOZ_ASSERT(!aRv.Failed(), "Don't pass an already-failed ErrorResult to a callback!");
if (!aExecutionReason) {
aExecutionReason = "TextGenerationDeltaCallback";
}
CallSetup s(this, aRv, aExecutionReason, aExceptionHandling, aRealm);
if (!s.GetContext()) {
MOZ_ASSERT(aRv.Failed());
return;
}
return Call(s.GetCallContext(), JS::UndefinedHandleValue, text, aRv);
}
template <typename T>
MOZ_CAN_RUN_SCRIPT inline void
Call(const T& thisVal, const nsACString& text, const char* aExecutionReason = nullptr)
{
return Call(thisVal, text, IgnoreErrors(), aExecutionReason);
}
MOZ_CAN_RUN_SCRIPT inline void
Call(const nsACString& text, const char* aExecutionReason = nullptr)
{
return Call(text, IgnoreErrors(), aExecutionReason, eReportExceptions, nullptr);
}
inline bool
operator==(const TextGenerationDeltaCallback& aOther) const
{
return CallbackFunction::operator==(aOther);
}
private:
MOZ_CAN_RUN_SCRIPT void Call(BindingCallContext& cx, JS::Handle<JS::Value> aThisVal, const nsACString& text, ErrorResult& aRv);
};
namespace binding_detail {
class MOZ_EMPTY_BASES FastTextGenerationDeltaCallback : public TextGenerationDeltaCallback
{
public:
explicit inline FastTextGenerationDeltaCallback(JSObject* aCallback, JSObject* aCallbackGlobal)
: TextGenerationDeltaCallback(aCallback, aCallbackGlobal, FastCallbackConstructor())
{
}
inline void
Trace(JSTracer* aTracer)
{
TextGenerationDeltaCallback::Trace(aTracer);
}
inline void
FinishSlowJSInitIfMoreThanOneOwner(JSContext* aCx)
{
TextGenerationDeltaCallback::FinishSlowJSInitIfMoreThanOneOwner(aCx);
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGenerationLogitBias : public MaybeEmptyDictionaryBase
{
float mBias = {};
int32_t mToken = {};
TextGenerationLogitBias();
explicit inline TextGenerationLogitBias(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGenerationLogitBias(TextGenerationLogitBias&& aOther) = default;
explicit inline TextGenerationLogitBias(const TextGenerationLogitBias& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
TextGenerationLogitBias&
operator=(const TextGenerationLogitBias& aOther);
private:
static bool
InitIds(JSContext* cx, TextGenerationLogitBiasAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGenerationLogitBias : public TextGenerationLogitBias
{
inline FastTextGenerationLogitBias()
: TextGenerationLogitBias(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGenerationMessage : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR nsCString mContent;
TextGenerationRole mRole = {};
TextGenerationMessage();
explicit inline TextGenerationMessage(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGenerationMessage(TextGenerationMessage&& aOther) = default;
explicit inline TextGenerationMessage(const TextGenerationMessage& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
TextGenerationMessage&
operator=(const TextGenerationMessage& aOther);
private:
static bool
InitIds(JSContext* cx, TextGenerationMessageAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGenerationMessage : public TextGenerationMessage
{
inline FastTextGenerationMessage()
: TextGenerationMessage(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGenerationResourceSnapshot : public DictionaryBase
{
uint64_t mCpuTimeMs = {};
uint64_t mMemoryBytes = {};
TextGenerationResourceSnapshot();
explicit inline TextGenerationResourceSnapshot(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGenerationResourceSnapshot(TextGenerationResourceSnapshot&& aOther) = default;
explicit inline TextGenerationResourceSnapshot(const TextGenerationResourceSnapshot& aOther)
{
*this = aOther;
}
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
TextGenerationResourceSnapshot&
operator=(const TextGenerationResourceSnapshot& aOther);
private:
static bool
InitIds(JSContext* cx, TextGenerationResourceSnapshotAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGenerationResourceSnapshot : public TextGenerationResourceSnapshot
{
inline FastTextGenerationResourceSnapshot()
: TextGenerationResourceSnapshot(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGenerationTimings : public DictionaryBase
{
double mDecodeMs = {};
double mPrefillMs = {};
TextGenerationTimings();
explicit inline TextGenerationTimings(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGenerationTimings(TextGenerationTimings&& aOther) = default;
explicit inline TextGenerationTimings(const TextGenerationTimings& aOther)
{
*this = aOther;
}
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
TextGenerationTimings&
operator=(const TextGenerationTimings& aOther);
private:
static bool
InitIds(JSContext* cx, TextGenerationTimingsAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGenerationTimings : public TextGenerationTimings
{
inline FastTextGenerationTimings()
: TextGenerationTimings(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGeneratorCreateOptions : public MaybeEmptyDictionaryBase
{
uint32_t mBatchSize = 2048U;
uint32_t mContextSize = 1024U;
MOZ_INIT_OUTSIDE_CTOR nsCString mFeatureId;
bool mFlashAttn = false;
TextGenerationKVCacheDtype mKvCacheDtype = {};
uint32_t mNumThreads = 0U;
uint32_t mNumThreadsDecoding = 0U;
uint32_t mUbatchSize = 512U;
TextGeneratorCreateOptions();
explicit inline TextGeneratorCreateOptions(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGeneratorCreateOptions(TextGeneratorCreateOptions&& aOther) = default;
explicit inline TextGeneratorCreateOptions(const TextGeneratorCreateOptions& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
TextGeneratorCreateOptions&
operator=(const TextGeneratorCreateOptions& aOther);
private:
static bool
InitIds(JSContext* cx, TextGeneratorCreateOptionsAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGeneratorCreateOptions : public TextGeneratorCreateOptions
{
inline FastTextGeneratorCreateOptions()
: TextGeneratorCreateOptions(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGenerationResources : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR TextGenerationResourceSnapshot mAfter;
MOZ_INIT_OUTSIDE_CTOR TextGenerationResourceSnapshot mBefore;
TextGenerationResources();
explicit inline TextGenerationResources(const FastDictionaryInitializer& )
: mAfter(FastDictionaryInitializer()),
mBefore(FastDictionaryInitializer())
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGenerationResources(TextGenerationResources&& aOther) = default;
explicit inline TextGenerationResources(const TextGenerationResources& aOther)
: mAfter(FastDictionaryInitializer()),
mBefore(FastDictionaryInitializer())
{
*this = aOther;
}
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
TextGenerationResources&
operator=(const TextGenerationResources& aOther);
private:
static bool
InitIds(JSContext* cx, TextGenerationResourcesAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGenerationResources : public TextGenerationResources
{
inline FastTextGenerationResources()
: TextGenerationResources(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGenerationSampler : public MaybeEmptyDictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR Sequence<TextGenerationLogitBias> mLogitBias;
MOZ_INIT_OUTSIDE_CTOR Optional<uint32_t> mSeed;
float mTemp = 0.8F;
int32_t mTopK = 40;
float mTopP = 0.95F;
TextGenerationSamplerType mType = {};
TextGenerationSampler();
explicit inline TextGenerationSampler(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGenerationSampler(TextGenerationSampler&& aOther) = default;
explicit inline TextGenerationSampler(const TextGenerationSampler& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
TextGenerationSampler&
operator=(const TextGenerationSampler& aOther);
private:
static bool
InitIds(JSContext* cx, TextGenerationSamplerAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGenerationSampler : public TextGenerationSampler
{
inline FastTextGenerationSampler()
: TextGenerationSampler(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGenerationUsage : public DictionaryBase
{
uint32_t mGeneratedTokens = {};
uint32_t mPromptCharacters = {};
uint32_t mPromptTokens = {};
MOZ_INIT_OUTSIDE_CTOR TextGenerationTimings mTimings;
TextGenerationUsage();
explicit inline TextGenerationUsage(const FastDictionaryInitializer& )
: mTimings(FastDictionaryInitializer())
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGenerationUsage(TextGenerationUsage&& aOther) = default;
explicit inline TextGenerationUsage(const TextGenerationUsage& aOther)
: mTimings(FastDictionaryInitializer())
{
*this = aOther;
}
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
TextGenerationUsage&
operator=(const TextGenerationUsage& aOther);
private:
static bool
InitIds(JSContext* cx, TextGenerationUsageAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGenerationUsage : public TextGenerationUsage
{
inline FastTextGenerationUsage()
: TextGenerationUsage(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGenerationRequest : public MaybeEmptyDictionaryBase
{
uint32_t mBufferLength = 20U;
uint32_t mMaxTokens = 512U;
MOZ_INIT_OUTSIDE_CTOR Sequence<TextGenerationMessage> mMessages;
MOZ_INIT_OUTSIDE_CTOR Sequence<TextGenerationSampler> mSamplers;
bool mStopOnEndOfGenerationTokens = true;
MOZ_INIT_OUTSIDE_CTOR Sequence<int32_t> mStopTokens;
TextGenerationRequest();
explicit inline TextGenerationRequest(const FastDictionaryInitializer& )
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGenerationRequest(TextGenerationRequest&& aOther) = default;
explicit inline TextGenerationRequest(const TextGenerationRequest& aOther)
{
*this = aOther;
}
bool
Init(BindingCallContext& cx, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
Init(JSContext* cx_, JS::Handle<JS::Value> val, const char* sourceDescription = "Value", bool passedToJSImpl = false);
void
TraceDictionary(JSTracer* trc);
TextGenerationRequest&
operator=(const TextGenerationRequest& aOther);
private:
static bool
InitIds(JSContext* cx, TextGenerationRequestAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGenerationRequest : public TextGenerationRequest
{
inline FastTextGenerationRequest()
: TextGenerationRequest(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
struct MOZ_EMPTY_BASES TextGenerationResult : public DictionaryBase
{
MOZ_INIT_OUTSIDE_CTOR nsCString mContent;
TextGenerationFinishReason mReason = {};
MOZ_INIT_OUTSIDE_CTOR TextGenerationResources mResources;
MOZ_INIT_OUTSIDE_CTOR TextGenerationUsage mUsage;
TextGenerationResult();
explicit inline TextGenerationResult(const FastDictionaryInitializer& )
: mResources(FastDictionaryInitializer()),
mUsage(FastDictionaryInitializer())
{
// Do nothing here; this is used by our "Fast" subclass
}
TextGenerationResult(TextGenerationResult&& aOther) = default;
explicit inline TextGenerationResult(const TextGenerationResult& aOther)
: mResources(FastDictionaryInitializer()),
mUsage(FastDictionaryInitializer())
{
*this = aOther;
}
bool
Init(const char* sourceDescription = "Value", bool passedToJSImpl = false);
bool
ToObjectInternal(JSContext* cx, JS::MutableHandle<JS::Value> rval) const;
void
TraceDictionary(JSTracer* trc);
TextGenerationResult&
operator=(const TextGenerationResult& aOther);
private:
static bool
InitIds(JSContext* cx, TextGenerationResultAtoms* atomsCache);
};
namespace binding_detail {
struct MOZ_EMPTY_BASES FastTextGenerationResult : public TextGenerationResult
{
inline FastTextGenerationResult()
: TextGenerationResult(FastDictionaryInitializer())
{
// Doesn't matter what int we pass to the parent constructor
}
};
} // namespace binding_detail
namespace TextGenerator_Binding {
typedef mozilla::dom::TextGenerator NativeType;
bool
ConstructorEnabled(JSContext* aCx, JS::Handle<JSObject*> aObj);
bool
Wrap(JSContext* aCx, mozilla::dom::TextGenerator* aObject, nsWrapperCache* aCache, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
template <class T>
inline JSObject* Wrap(JSContext* aCx, T* aObject, JS::Handle<JSObject*> aGivenProto)
{
JS::Rooted<JSObject*> reflector(aCx);
return Wrap(aCx, aObject, aObject, aGivenProto, &reflector) ? reflector.get() : nullptr;
}
void
CreateInterfaceObjects(JSContext* aCx, JS::Handle<JSObject*> aGlobal, ProtoAndIfaceCache& aProtoAndIfaceCache, DefineInterfaceProperty aDefineOnGlobal);
JS::Handle<JSObject*>
GetConstructorObjectHandle(JSContext* aCx);
inline bool CreateAndDefineOnGlobal(JSContext* aCx)
{
// Get the interface or namespace object for this class. This will
// create the object as needed and always define the properties for
// it on the global. The caller should make sure the interface or
// namespace is exposed on the global before calling this.
return GetPerInterfaceObjectHandle(aCx, constructors::id::TextGenerator,
&CreateInterfaceObjects,
DefineInterfaceProperty::Always);
}
} // namespace TextGenerator_Binding
} // namespace dom
template <>
struct MaxContiguousEnumValue<dom::TextGenerationRole>
{
static constexpr dom::TextGenerationRole value = dom::TextGenerationRole::Assistant;
static_assert(static_cast<uint8_t>(dom::TextGenerationRole::System) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::TextGenerationRole>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
template <>
struct MaxContiguousEnumValue<dom::TextGenerationSamplerType>
{
static constexpr dom::TextGenerationSamplerType value = dom::TextGenerationSamplerType::Dist;
static_assert(static_cast<uint8_t>(dom::TextGenerationSamplerType::Logit_bias) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::TextGenerationSamplerType>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
template <>
struct MaxContiguousEnumValue<dom::TextGenerationFinishReason>
{
static constexpr dom::TextGenerationFinishReason value = dom::TextGenerationFinishReason::Cancelled;
static_assert(static_cast<uint8_t>(dom::TextGenerationFinishReason::Eos) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::TextGenerationFinishReason>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
template <>
struct MaxContiguousEnumValue<dom::TextGenerationKVCacheDtype>
{
static constexpr dom::TextGenerationKVCacheDtype value = dom::TextGenerationKVCacheDtype::Q4_0;
static_assert(static_cast<uint8_t>(dom::TextGenerationKVCacheDtype::F32) == 0,
"We rely on this in ContiguousEnumValues");
static_assert(std::size(dom::binding_detail::EnumStrings<dom::TextGenerationKVCacheDtype>::Values) - 1 == UnderlyingValue(value),
"Mismatch between enum strings and enum count");
};
} // namespace mozilla
#endif // DOM_TEXTGENERATORBINDING_H_