@aristech-org/nlp-client
Version:
A Node.js client library for the Aristech NLP Service
1,441 lines (1,440 loc) • 63.3 kB
JavaScript
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.11.8
// protoc v6.33.1
// source: intents.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import { FallbackMessage } from "./projects.js";
export const protobufPackage = "aristech.nlp";
export var OutputMessage_Channel;
(function (OutputMessage_Channel) {
OutputMessage_Channel[OutputMessage_Channel["CHAT"] = 0] = "CHAT";
OutputMessage_Channel[OutputMessage_Channel["VOICE"] = 1] = "VOICE";
OutputMessage_Channel[OutputMessage_Channel["EMAIL"] = 2] = "EMAIL";
OutputMessage_Channel[OutputMessage_Channel["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
})(OutputMessage_Channel || (OutputMessage_Channel = {}));
export function outputMessage_ChannelFromJSON(object) {
switch (object) {
case 0:
case "CHAT":
return OutputMessage_Channel.CHAT;
case 1:
case "VOICE":
return OutputMessage_Channel.VOICE;
case 2:
case "EMAIL":
return OutputMessage_Channel.EMAIL;
case -1:
case "UNRECOGNIZED":
default:
return OutputMessage_Channel.UNRECOGNIZED;
}
}
export function outputMessage_ChannelToJSON(object) {
switch (object) {
case OutputMessage_Channel.CHAT:
return "CHAT";
case OutputMessage_Channel.VOICE:
return "VOICE";
case OutputMessage_Channel.EMAIL:
return "EMAIL";
case OutputMessage_Channel.UNRECOGNIZED:
default:
return "UNRECOGNIZED";
}
}
function createBaseOutputMessage() {
return { channel: 0, data: {} };
}
export const OutputMessage = {
encode(message, writer = new BinaryWriter()) {
if (message.channel !== 0) {
writer.uint32(8).int32(message.channel);
}
globalThis.Object.entries(message.data).forEach(([key, value]) => {
OutputMessage_DataEntry.encode({ key: key, value }, writer.uint32(18).fork()).join();
});
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseOutputMessage();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 8) {
break;
}
message.channel = reader.int32();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
const entry2 = OutputMessage_DataEntry.decode(reader, reader.uint32());
if (entry2.value !== undefined) {
message.data[entry2.key] = entry2.value;
}
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
channel: isSet(object.channel) ? outputMessage_ChannelFromJSON(object.channel) : 0,
data: isObject(object.data)
? globalThis.Object.entries(object.data).reduce((acc, [key, value]) => {
acc[key] = globalThis.String(value);
return acc;
}, {})
: {},
};
},
toJSON(message) {
const obj = {};
if (message.channel !== 0) {
obj.channel = outputMessage_ChannelToJSON(message.channel);
}
if (message.data) {
const entries = globalThis.Object.entries(message.data);
if (entries.length > 0) {
obj.data = {};
entries.forEach(([k, v]) => {
obj.data[k] = v;
});
}
}
return obj;
},
create(base) {
return OutputMessage.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseOutputMessage();
message.channel = object.channel ?? 0;
message.data = globalThis.Object.entries(object.data ?? {}).reduce((acc, [key, value]) => {
if (value !== undefined) {
acc[key] = globalThis.String(value);
}
return acc;
}, {});
return message;
},
};
function createBaseOutputMessage_DataEntry() {
return { key: "", value: "" };
}
export const OutputMessage_DataEntry = {
encode(message, writer = new BinaryWriter()) {
if (message.key !== "") {
writer.uint32(10).string(message.key);
}
if (message.value !== "") {
writer.uint32(18).string(message.value);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseOutputMessage_DataEntry();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.key = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.value = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
key: isSet(object.key) ? globalThis.String(object.key) : "",
value: isSet(object.value) ? globalThis.String(object.value) : "",
};
},
toJSON(message) {
const obj = {};
if (message.key !== "") {
obj.key = message.key;
}
if (message.value !== "") {
obj.value = message.value;
}
return obj;
},
create(base) {
return OutputMessage_DataEntry.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseOutputMessage_DataEntry();
message.key = object.key ?? "";
message.value = object.value ?? "";
return message;
},
};
function createBaseIntent() {
return {
id: "",
projectId: "",
locale: "",
topic: "",
inputs: [],
outputChat: [],
outputVoice: [],
outputEmail: [],
outputs: [],
relatedTo: [],
published: false,
excludeOutputFromSearch: false,
keywords: [],
creatorId: "",
documentId: "",
};
}
export const Intent = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (message.projectId !== "") {
writer.uint32(18).string(message.projectId);
}
if (message.locale !== "") {
writer.uint32(26).string(message.locale);
}
if (message.topic !== "") {
writer.uint32(34).string(message.topic);
}
for (const v of message.inputs) {
IntentInput.encode(v, writer.uint32(42).fork()).join();
}
for (const v of message.outputChat) {
writer.uint32(50).string(v);
}
for (const v of message.outputVoice) {
writer.uint32(58).string(v);
}
for (const v of message.outputEmail) {
writer.uint32(66).string(v);
}
for (const v of message.outputs) {
OutputMessage.encode(v, writer.uint32(122).fork()).join();
}
for (const v of message.relatedTo) {
Relation.encode(v, writer.uint32(74).fork()).join();
}
if (message.published !== false) {
writer.uint32(80).bool(message.published);
}
if (message.excludeOutputFromSearch !== false) {
writer.uint32(96).bool(message.excludeOutputFromSearch);
}
for (const v of message.keywords) {
Keyword.encode(v, writer.uint32(106).fork()).join();
}
if (message.creatorId !== "") {
writer.uint32(114).string(message.creatorId);
}
if (message.documentId !== "") {
writer.uint32(130).string(message.documentId);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseIntent();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.id = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.projectId = reader.string();
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.locale = reader.string();
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.topic = reader.string();
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.inputs.push(IntentInput.decode(reader, reader.uint32()));
continue;
}
case 6: {
if (tag !== 50) {
break;
}
message.outputChat.push(reader.string());
continue;
}
case 7: {
if (tag !== 58) {
break;
}
message.outputVoice.push(reader.string());
continue;
}
case 8: {
if (tag !== 66) {
break;
}
message.outputEmail.push(reader.string());
continue;
}
case 15: {
if (tag !== 122) {
break;
}
message.outputs.push(OutputMessage.decode(reader, reader.uint32()));
continue;
}
case 9: {
if (tag !== 74) {
break;
}
message.relatedTo.push(Relation.decode(reader, reader.uint32()));
continue;
}
case 10: {
if (tag !== 80) {
break;
}
message.published = reader.bool();
continue;
}
case 12: {
if (tag !== 96) {
break;
}
message.excludeOutputFromSearch = reader.bool();
continue;
}
case 13: {
if (tag !== 106) {
break;
}
message.keywords.push(Keyword.decode(reader, reader.uint32()));
continue;
}
case 14: {
if (tag !== 114) {
break;
}
message.creatorId = reader.string();
continue;
}
case 16: {
if (tag !== 130) {
break;
}
message.documentId = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: isSet(object.id) ? globalThis.String(object.id) : "",
projectId: isSet(object.projectId)
? globalThis.String(object.projectId)
: isSet(object.project_id)
? globalThis.String(object.project_id)
: "",
locale: isSet(object.locale) ? globalThis.String(object.locale) : "",
topic: isSet(object.topic) ? globalThis.String(object.topic) : "",
inputs: globalThis.Array.isArray(object?.inputs) ? object.inputs.map((e) => IntentInput.fromJSON(e)) : [],
outputChat: globalThis.Array.isArray(object?.outputChat)
? object.outputChat.map((e) => globalThis.String(e))
: globalThis.Array.isArray(object?.output_chat)
? object.output_chat.map((e) => globalThis.String(e))
: [],
outputVoice: globalThis.Array.isArray(object?.outputVoice)
? object.outputVoice.map((e) => globalThis.String(e))
: globalThis.Array.isArray(object?.output_voice)
? object.output_voice.map((e) => globalThis.String(e))
: [],
outputEmail: globalThis.Array.isArray(object?.outputEmail)
? object.outputEmail.map((e) => globalThis.String(e))
: globalThis.Array.isArray(object?.output_email)
? object.output_email.map((e) => globalThis.String(e))
: [],
outputs: globalThis.Array.isArray(object?.outputs)
? object.outputs.map((e) => OutputMessage.fromJSON(e))
: [],
relatedTo: globalThis.Array.isArray(object?.relatedTo)
? object.relatedTo.map((e) => Relation.fromJSON(e))
: globalThis.Array.isArray(object?.related_to)
? object.related_to.map((e) => Relation.fromJSON(e))
: [],
published: isSet(object.published) ? globalThis.Boolean(object.published) : false,
excludeOutputFromSearch: isSet(object.excludeOutputFromSearch)
? globalThis.Boolean(object.excludeOutputFromSearch)
: isSet(object.exclude_output_from_search)
? globalThis.Boolean(object.exclude_output_from_search)
: false,
keywords: globalThis.Array.isArray(object?.keywords) ? object.keywords.map((e) => Keyword.fromJSON(e)) : [],
creatorId: isSet(object.creatorId)
? globalThis.String(object.creatorId)
: isSet(object.creator_id)
? globalThis.String(object.creator_id)
: "",
documentId: isSet(object.documentId)
? globalThis.String(object.documentId)
: isSet(object.document_id)
? globalThis.String(object.document_id)
: "",
};
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.projectId !== "") {
obj.projectId = message.projectId;
}
if (message.locale !== "") {
obj.locale = message.locale;
}
if (message.topic !== "") {
obj.topic = message.topic;
}
if (message.inputs?.length) {
obj.inputs = message.inputs.map((e) => IntentInput.toJSON(e));
}
if (message.outputChat?.length) {
obj.outputChat = message.outputChat;
}
if (message.outputVoice?.length) {
obj.outputVoice = message.outputVoice;
}
if (message.outputEmail?.length) {
obj.outputEmail = message.outputEmail;
}
if (message.outputs?.length) {
obj.outputs = message.outputs.map((e) => OutputMessage.toJSON(e));
}
if (message.relatedTo?.length) {
obj.relatedTo = message.relatedTo.map((e) => Relation.toJSON(e));
}
if (message.published !== false) {
obj.published = message.published;
}
if (message.excludeOutputFromSearch !== false) {
obj.excludeOutputFromSearch = message.excludeOutputFromSearch;
}
if (message.keywords?.length) {
obj.keywords = message.keywords.map((e) => Keyword.toJSON(e));
}
if (message.creatorId !== "") {
obj.creatorId = message.creatorId;
}
if (message.documentId !== "") {
obj.documentId = message.documentId;
}
return obj;
},
create(base) {
return Intent.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseIntent();
message.id = object.id ?? "";
message.projectId = object.projectId ?? "";
message.locale = object.locale ?? "";
message.topic = object.topic ?? "";
message.inputs = object.inputs?.map((e) => IntentInput.fromPartial(e)) || [];
message.outputChat = object.outputChat?.map((e) => e) || [];
message.outputVoice = object.outputVoice?.map((e) => e) || [];
message.outputEmail = object.outputEmail?.map((e) => e) || [];
message.outputs = object.outputs?.map((e) => OutputMessage.fromPartial(e)) || [];
message.relatedTo = object.relatedTo?.map((e) => Relation.fromPartial(e)) || [];
message.published = object.published ?? false;
message.excludeOutputFromSearch = object.excludeOutputFromSearch ?? false;
message.keywords = object.keywords?.map((e) => Keyword.fromPartial(e)) || [];
message.creatorId = object.creatorId ?? "";
message.documentId = object.documentId ?? "";
return message;
},
};
function createBaseIntentInput() {
return { uuid: "", input: "" };
}
export const IntentInput = {
encode(message, writer = new BinaryWriter()) {
if (message.uuid !== "") {
writer.uint32(10).string(message.uuid);
}
if (message.input !== "") {
writer.uint32(18).string(message.input);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseIntentInput();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.uuid = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.input = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
uuid: isSet(object.uuid) ? globalThis.String(object.uuid) : "",
input: isSet(object.input) ? globalThis.String(object.input) : "",
};
},
toJSON(message) {
const obj = {};
if (message.uuid !== "") {
obj.uuid = message.uuid;
}
if (message.input !== "") {
obj.input = message.input;
}
return obj;
},
create(base) {
return IntentInput.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseIntentInput();
message.uuid = object.uuid ?? "";
message.input = object.input ?? "";
return message;
},
};
function createBaseRelation() {
return { parents: [], children: [], peers: [] };
}
export const Relation = {
encode(message, writer = new BinaryWriter()) {
for (const v of message.parents) {
writer.uint32(10).string(v);
}
for (const v of message.children) {
writer.uint32(18).string(v);
}
for (const v of message.peers) {
writer.uint32(26).string(v);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRelation();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.parents.push(reader.string());
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.children.push(reader.string());
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.peers.push(reader.string());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
parents: globalThis.Array.isArray(object?.parents) ? object.parents.map((e) => globalThis.String(e)) : [],
children: globalThis.Array.isArray(object?.children) ? object.children.map((e) => globalThis.String(e)) : [],
peers: globalThis.Array.isArray(object?.peers) ? object.peers.map((e) => globalThis.String(e)) : [],
};
},
toJSON(message) {
const obj = {};
if (message.parents?.length) {
obj.parents = message.parents;
}
if (message.children?.length) {
obj.children = message.children;
}
if (message.peers?.length) {
obj.peers = message.peers;
}
return obj;
},
create(base) {
return Relation.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseRelation();
message.parents = object.parents?.map((e) => e) || [];
message.children = object.children?.map((e) => e) || [];
message.peers = object.peers?.map((e) => e) || [];
return message;
},
};
function createBaseKeyword() {
return { keyword: "", priority: 0 };
}
export const Keyword = {
encode(message, writer = new BinaryWriter()) {
if (message.keyword !== "") {
writer.uint32(10).string(message.keyword);
}
if (message.priority !== 0) {
writer.uint32(16).int32(message.priority);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseKeyword();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.keyword = reader.string();
continue;
}
case 2: {
if (tag !== 16) {
break;
}
message.priority = reader.int32();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
keyword: isSet(object.keyword) ? globalThis.String(object.keyword) : "",
priority: isSet(object.priority) ? globalThis.Number(object.priority) : 0,
};
},
toJSON(message) {
const obj = {};
if (message.keyword !== "") {
obj.keyword = message.keyword;
}
if (message.priority !== 0) {
obj.priority = Math.round(message.priority);
}
return obj;
},
create(base) {
return Keyword.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseKeyword();
message.keyword = object.keyword ?? "";
message.priority = object.priority ?? 0;
return message;
},
};
function createBaseUpdateContentRequest() {
return { intents: [] };
}
export const UpdateContentRequest = {
encode(message, writer = new BinaryWriter()) {
for (const v of message.intents) {
Intent.encode(v, writer.uint32(10).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseUpdateContentRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.intents.push(Intent.decode(reader, reader.uint32()));
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
intents: globalThis.Array.isArray(object?.intents) ? object.intents.map((e) => Intent.fromJSON(e)) : [],
};
},
toJSON(message) {
const obj = {};
if (message.intents?.length) {
obj.intents = message.intents.map((e) => Intent.toJSON(e));
}
return obj;
},
create(base) {
return UpdateContentRequest.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseUpdateContentRequest();
message.intents = object.intents?.map((e) => Intent.fromPartial(e)) || [];
return message;
},
};
function createBaseUpdateContentResponse() {
return { intentIds: [] };
}
export const UpdateContentResponse = {
encode(message, writer = new BinaryWriter()) {
for (const v of message.intentIds) {
writer.uint32(10).string(v);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseUpdateContentResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.intentIds.push(reader.string());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
intentIds: globalThis.Array.isArray(object?.intentIds)
? object.intentIds.map((e) => globalThis.String(e))
: globalThis.Array.isArray(object?.intent_ids)
? object.intent_ids.map((e) => globalThis.String(e))
: [],
};
},
toJSON(message) {
const obj = {};
if (message.intentIds?.length) {
obj.intentIds = message.intentIds;
}
return obj;
},
create(base) {
return UpdateContentResponse.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseUpdateContentResponse();
message.intentIds = object.intentIds?.map((e) => e) || [];
return message;
},
};
function createBaseRemoveContentRequest() {
return { id: [], projectId: "" };
}
export const RemoveContentRequest = {
encode(message, writer = new BinaryWriter()) {
for (const v of message.id) {
writer.uint32(10).string(v);
}
if (message.projectId !== "") {
writer.uint32(18).string(message.projectId);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRemoveContentRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.id.push(reader.string());
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.projectId = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: globalThis.Array.isArray(object?.id) ? object.id.map((e) => globalThis.String(e)) : [],
projectId: isSet(object.projectId)
? globalThis.String(object.projectId)
: isSet(object.project_id)
? globalThis.String(object.project_id)
: "",
};
},
toJSON(message) {
const obj = {};
if (message.id?.length) {
obj.id = message.id;
}
if (message.projectId !== "") {
obj.projectId = message.projectId;
}
return obj;
},
create(base) {
return RemoveContentRequest.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseRemoveContentRequest();
message.id = object.id?.map((e) => e) || [];
message.projectId = object.projectId ?? "";
return message;
},
};
function createBaseRemoveContentResponse() {
return {};
}
export const RemoveContentResponse = {
encode(_, writer = new BinaryWriter()) {
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseRemoveContentResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(_) {
return {};
},
toJSON(_) {
const obj = {};
return obj;
},
create(base) {
return RemoveContentResponse.fromPartial(base ?? {});
},
fromPartial(_) {
const message = createBaseRemoveContentResponse();
return message;
},
};
function createBaseGetContentRequest() {
return {
prompt: "",
projectId: "",
numResults: 0,
threshold: undefined,
filters: [],
chatId: "",
includeUnpublishedIntents: false,
};
}
export const GetContentRequest = {
encode(message, writer = new BinaryWriter()) {
if (message.prompt !== "") {
writer.uint32(10).string(message.prompt);
}
if (message.projectId !== "") {
writer.uint32(18).string(message.projectId);
}
if (message.numResults !== 0) {
writer.uint32(24).int32(message.numResults);
}
if (message.threshold !== undefined) {
writer.uint32(37).float(message.threshold);
}
for (const v of message.filters) {
ContentFilter.encode(v, writer.uint32(42).fork()).join();
}
if (message.chatId !== "") {
writer.uint32(58).string(message.chatId);
}
if (message.includeUnpublishedIntents !== false) {
writer.uint32(64).bool(message.includeUnpublishedIntents);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGetContentRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.prompt = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.projectId = reader.string();
continue;
}
case 3: {
if (tag !== 24) {
break;
}
message.numResults = reader.int32();
continue;
}
case 4: {
if (tag !== 37) {
break;
}
message.threshold = reader.float();
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.filters.push(ContentFilter.decode(reader, reader.uint32()));
continue;
}
case 7: {
if (tag !== 58) {
break;
}
message.chatId = reader.string();
continue;
}
case 8: {
if (tag !== 64) {
break;
}
message.includeUnpublishedIntents = reader.bool();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
prompt: isSet(object.prompt) ? globalThis.String(object.prompt) : "",
projectId: isSet(object.projectId)
? globalThis.String(object.projectId)
: isSet(object.project_id)
? globalThis.String(object.project_id)
: "",
numResults: isSet(object.numResults)
? globalThis.Number(object.numResults)
: isSet(object.num_results)
? globalThis.Number(object.num_results)
: 0,
threshold: isSet(object.threshold) ? globalThis.Number(object.threshold) : undefined,
filters: globalThis.Array.isArray(object?.filters)
? object.filters.map((e) => ContentFilter.fromJSON(e))
: [],
chatId: isSet(object.chatId)
? globalThis.String(object.chatId)
: isSet(object.chat_id)
? globalThis.String(object.chat_id)
: "",
includeUnpublishedIntents: isSet(object.includeUnpublishedIntents)
? globalThis.Boolean(object.includeUnpublishedIntents)
: isSet(object.include_unpublished_intents)
? globalThis.Boolean(object.include_unpublished_intents)
: false,
};
},
toJSON(message) {
const obj = {};
if (message.prompt !== "") {
obj.prompt = message.prompt;
}
if (message.projectId !== "") {
obj.projectId = message.projectId;
}
if (message.numResults !== 0) {
obj.numResults = Math.round(message.numResults);
}
if (message.threshold !== undefined) {
obj.threshold = message.threshold;
}
if (message.filters?.length) {
obj.filters = message.filters.map((e) => ContentFilter.toJSON(e));
}
if (message.chatId !== "") {
obj.chatId = message.chatId;
}
if (message.includeUnpublishedIntents !== false) {
obj.includeUnpublishedIntents = message.includeUnpublishedIntents;
}
return obj;
},
create(base) {
return GetContentRequest.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseGetContentRequest();
message.prompt = object.prompt ?? "";
message.projectId = object.projectId ?? "";
message.numResults = object.numResults ?? 0;
message.threshold = object.threshold ?? undefined;
message.filters = object.filters?.map((e) => ContentFilter.fromPartial(e)) || [];
message.chatId = object.chatId ?? "";
message.includeUnpublishedIntents = object.includeUnpublishedIntents ?? false;
return message;
},
};
function createBaseGetContentResponse() {
return { items: [], chatId: "" };
}
export const GetContentResponse = {
encode(message, writer = new BinaryWriter()) {
for (const v of message.items) {
ContentResponseItem.encode(v, writer.uint32(10).fork()).join();
}
if (message.chatId !== "") {
writer.uint32(18).string(message.chatId);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGetContentResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.items.push(ContentResponseItem.decode(reader, reader.uint32()));
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.chatId = reader.string();
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
items: globalThis.Array.isArray(object?.items)
? object.items.map((e) => ContentResponseItem.fromJSON(e))
: [],
chatId: isSet(object.chatId)
? globalThis.String(object.chatId)
: isSet(object.chat_id)
? globalThis.String(object.chat_id)
: "",
};
},
toJSON(message) {
const obj = {};
if (message.items?.length) {
obj.items = message.items.map((e) => ContentResponseItem.toJSON(e));
}
if (message.chatId !== "") {
obj.chatId = message.chatId;
}
return obj;
},
create(base) {
return GetContentResponse.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseGetContentResponse();
message.items = object.items?.map((e) => ContentResponseItem.fromPartial(e)) || [];
message.chatId = object.chatId ?? "";
return message;
},
};
function createBaseContentFilter() {
return { field: "", value: "", operator: "", label: [] };
}
export const ContentFilter = {
encode(message, writer = new BinaryWriter()) {
if (message.field !== "") {
writer.uint32(10).string(message.field);
}
if (message.value !== "") {
writer.uint32(18).string(message.value);
}
if (message.operator !== "") {
writer.uint32(26).string(message.operator);
}
for (const v of message.label) {
writer.uint32(34).string(v);
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseContentFilter();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.field = reader.string();
continue;
}
case 2: {
if (tag !== 18) {
break;
}
message.value = reader.string();
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.operator = reader.string();
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.label.push(reader.string());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
field: isSet(object.field) ? globalThis.String(object.field) : "",
value: isSet(object.value) ? globalThis.String(object.value) : "",
operator: isSet(object.operator) ? globalThis.String(object.operator) : "",
label: globalThis.Array.isArray(object?.label) ? object.label.map((e) => globalThis.String(e)) : [],
};
},
toJSON(message) {
const obj = {};
if (message.field !== "") {
obj.field = message.field;
}
if (message.value !== "") {
obj.value = message.value;
}
if (message.operator !== "") {
obj.operator = message.operator;
}
if (message.label?.length) {
obj.label = message.label;
}
return obj;
},
create(base) {
return ContentFilter.fromPartial(base ?? {});
},
fromPartial(object) {
const message = createBaseContentFilter();
message.field = object.field ?? "";
message.value = object.value ?? "";
message.operator = object.operator ?? "";
message.label = object.label?.map((e) => e) || [];
return message;
},
};
function createBaseContentResponseItem() {
return {
id: "",
score: 0,
intent: undefined,
fallbackMessage: "",
fallbackMessages: [],
matchedInputs: 0,
matchedKeyword: undefined,
};
}
export const ContentResponseItem = {
encode(message, writer = new BinaryWriter()) {
if (message.id !== "") {
writer.uint32(10).string(message.id);
}
if (message.score !== 0) {
writer.uint32(21).float(message.score);
}
if (message.intent !== undefined) {
Intent.encode(message.intent, writer.uint32(26).fork()).join();
}
if (message.fallbackMessage !== "") {
writer.uint32(34).string(message.fallbackMessage);
}
for (const v of message.fallbackMessages) {
FallbackMessage.encode(v, writer.uint32(42).fork()).join();
}
if (message.matchedInputs !== 0) {
writer.uint32(48).int32(message.matchedInputs);
}
if (message.matchedKeyword !== undefined) {
Keyword.encode(message.matchedKeyword, writer.uint32(58).fork()).join();
}
return writer;
},
decode(input, length) {
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
const end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseContentResponseItem();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1: {
if (tag !== 10) {
break;
}
message.id = reader.string();
continue;
}
case 2: {
if (tag !== 21) {
break;
}
message.score = reader.float();
continue;
}
case 3: {
if (tag !== 26) {
break;
}
message.intent = Intent.decode(reader, reader.uint32());
continue;
}
case 4: {
if (tag !== 34) {
break;
}
message.fallbackMessage = reader.string();
continue;
}
case 5: {
if (tag !== 42) {
break;
}
message.fallbackMessages.push(FallbackMessage.decode(reader, reader.uint32()));
continue;
}
case 6: {
if (tag !== 48) {
break;
}
message.matchedInputs = reader.int32();
continue;
}
case 7: {
if (tag !== 58) {
break;
}
message.matchedKeyword = Keyword.decode(reader, reader.uint32());
continue;
}
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skip(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: isSet(object.id) ? globalThis.String(object.id) : "",
score: isSet(object.score) ? globalThis.Number(object.score) : 0,
intent: isSet(object.intent) ? Intent.fromJSON(object.intent) : undefined,
fallbackMessage: isSet(object.fallbackMessage)
? globalThis.String(object.fallbackMessage)
: isSet(object.fallback_message)
? globalThis.String(object.fallback_message)
: "",
fallbackMessages: globalThis.Array.isArray(object?.fallbackMessages)
? object.fallbackMessages.map((e) => FallbackMessage.fromJSON(e))
: globalThis.Array.isArray(object?.fallback_messages)
? object.fallback_messages.map((e) => FallbackMessage.fromJSON(e))
: [],
matchedInputs: isSet(object.matchedInputs)
? globalThis.Number(object.matchedInputs)
: isSet(object.matched_inputs)
? globalThis.Number(object.matched_inputs)
: 0,
matchedKeyword: isSet(object.matchedKeyword)
? Keyword.fromJSON(object.matchedKeyword)
: isSet(object.matched_keyword)
? Keyword.fromJSON(object.matched_keyword)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.id !== "") {
obj.id = message.id;
}
if (message.score !== 0) {
obj.score = message.score;
}
if (message.intent !== undefined) {
obj.intent = Intent.toJSON(message.intent);
}
if (message.fallbackMessage !== "") {
obj.fallbackMessage = message.fallbackMessage;
}
if (message.fallbackMessages?.length) {
obj.fallbackMessages = message.fallbackMessages.map((e) => FallbackMessage.toJSON(e));
}
if (message.matchedInputs !== 0) {
obj.matchedInputs = Math.round(message.matchedInputs);
}