- Linked Meta Response settings with components

- fixed bugs
This commit is contained in:
sherifButt 2024-03-26 09:35:19 +00:00
parent 5318b599b7
commit 26c311d6d3
20 changed files with 688 additions and 401 deletions

View File

@ -30,7 +30,10 @@ export default function Badge({
showClose = false,
bg = "bg-green-500",
animated = false,
active = false,
onClose = () => {}, // Callback for close icon
onSelect = () => {}, // Callback for badge click
onDoubleClick = () => {}, // Callback for badge double click
}) {
const {
text: textColor,
@ -64,7 +67,9 @@ export default function Badge({
lg: "shadow-lg",
xl: "shadow-xl",
}[shadow];
const backgroundClasses = `${bg} bg-opacity-10 hover:bg-opacity-20`;
const backgroundClasses = `${bg} ${
active ? "bg-opacity-20" : "bg-opacity-10"
} hover:bg-opacity-30`;
// SVG Icons
const DotIcon = () => (
@ -91,7 +96,9 @@ export default function Badge({
return (
<div
className={`flex flex-row gap-0.5 w-fit h-fit justify-center items-center group ${sizeClasses} ${backgroundClasses} ${roundedClasses} ${shadowClasses} ${ringClasses}`}
className={`flex flex-row gap-0.5 w-fit h-fit justify-center items-center cursor-pointer select-none group ${sizeClasses} ${backgroundClasses} ${roundedClasses} ${shadowClasses} ${ringClasses}`}
onDoubleClick={onDoubleClick}
onClick={onSelect}
>
{showDot && (
<div>
@ -103,10 +110,10 @@ export default function Badge({
</p>
{showClose && (
<div
className="flex flex-row justify-start items-start p-1 rounded-lg cursor-pointer"
className="flex flex-row justify-start items-start p-1 rounded-lg cursor-pointer z-10"
onClick={onClose}
>
<CloseIcon />
<CloseIcon className="p1" />
</div>
)}
</div>

View File

@ -15,6 +15,7 @@ export default function TextAreaBlock({
wrap,
code,
onSave,
value,
}) {
return (
<div>
@ -32,6 +33,7 @@ export default function TextAreaBlock({
</div>
<TextArea
defaultValue={defaultValue}
value={value}
required={required}
placeholder={placeholder}
onChange={onChange}

View File

@ -13,6 +13,7 @@ export default function ToggleBlock({
badgeLabel,
badgeAnimated,
badgeBg,
badgeShowDot,
border,
bg,
Icon,
@ -23,6 +24,7 @@ export default function ToggleBlock({
const borderStyle = border ? "border border-gray-600 rounded-2xl p-4" : "";
const backgroundStyle = bg ? "bg-black/10" : "";
return (
<div
className={`relative w-full max-h-full ${borderStyle} ${backgroundStyle}`}
@ -49,7 +51,7 @@ export default function ToggleBlock({
</label>
{badge && (
<Badge
showDot
showDot={badgeShowDot}
animated={badgeAnimated}
label={badgeLabel}
bg={badgeBg}

View File

@ -0,0 +1,27 @@
import React from "react";
export default function Button({
onClick,
disabled,
icon: Icon,
text,
className = "",
iconSize = 18,
iconColor = "#D3D4D4",
textClass = "",
}) {
return (
<button
onClick={onClick}
disabled={disabled}
className={`flex items-center gap-x-2 cursor-pointer px-[14px] py-[7px] -mr-[14px] rounded-lg hover:bg-[#222628]/60 transition-all duration-150 ease-in-out ${className}`}
>
{Icon && <Icon size={iconSize} weight="bold" color={iconColor} />}
<div
className={`text-[#D3D4D4] text-xs font-bold leading-[18px] ${textClass}`}
>
{text}
</div>
</button>
);
}

View File

@ -1,4 +1,4 @@
import { ArrowsIn, ArrowsOut, Check } from "@phosphor-icons/react";
import { ArrowsIn, ArrowsOut, Check, X } from "@phosphor-icons/react";
import React, { useState, useRef, useEffect } from "react";
export default function TextArea({
@ -14,19 +14,21 @@ export default function TextArea({
wrap = "soft",
code = false,
onSave,
value,
}) {
const [rows, setRows] = useState(initialRows);
const [isExpanded, setIsExpanded] = useState(false);
const [showExpandIcon, setShowExpandIcon] = useState(false);
const [content, setContent] = useState(defaultValue);
const [content, setContent] = useState(value || "");
const [showSaveButton, setShowSaveButton] = useState(false);
const textAreaRef = useRef(null);
useEffect(() => {
setContent(value);
adjustRowsToFitContent();
// Initial check to determine if the expand icon should be shown
checkForOverflow();
}, [defaultValue]);
}, [value]);
const toggleExpansion = () => {
setIsExpanded(!isExpanded);
@ -78,6 +80,12 @@ export default function TextArea({
}
};
// Handle cancel action
const handleCancel = () => {
setContent(value);
setShowSaveButton(false);
};
const textColorClass = disabled ? "text-white/40" : "text-white/60";
const codeClass = code ? "font-mono text-xs" : "text-sm";
@ -87,7 +95,8 @@ export default function TextArea({
ref={textAreaRef}
name={name}
rows={rows}
defaultValue={defaultValue}
// defaultValue={defaultValue}
value={content}
className={`resize-none bg-zinc-900 placeholder:text-white/20 ${codeClass} rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 mt-2 ${textColorClass} ${className}`}
placeholder={placeholder}
required={required}
@ -97,7 +106,7 @@ export default function TextArea({
disabled={disabled}
/>
{showSaveButton && (
<div className="flex flex-row justify-end px-8 sticky bottom-4 right-6">
<div className="flex flex-row justify-end px-8 sticky bottom-4 right-6 gap-4">
<button
onClick={handleSave}
className="flex items-center mt-4 gap-x-2 cursor-pointer px-[14px] py-[7px] -mr-[14px] rounded-lg hover:bg-[#222628]/60 transition-all duration-150 ease-in-out "
@ -105,25 +114,34 @@ export default function TextArea({
>
<Check size={18} weight="bold" color="#D3D4D4" />
<div className="text-[#D3D4D4] text-xs font-bold leading-[18px]">
Save Update
Save
</div>
</button>
<button
onClick={handleCancel}
className="flex items-center mt-4 gap-x-2 cursor-pointer px-[14px] py-[7px] -mr-[14px] rounded-lg hover:bg-[#222628]/60 transition-all duration-150 ease-in-out "
>
<X size={18} weight="bold" color="#D3D4D4" />
<div className="text-[#D3D4D4] text-xs font-bold leading-[18px]">
Cancel
</div>
</button>
</div>
)}
{showExpandIcon && !showSaveButton && (
{showExpandIcon && (
<button
type="button"
onClick={toggleExpansion}
className={`absolute bottom-2 right-2 text-lg ${
className={`absolute bottom-1 right-2 text-lg ${
isExpanded ? "text-2xl" : "text-xl"
} text-white/60 hover:text-white transition-all duration-150 ease-in-out`}
aria-label={isExpanded ? "Contract" : "Expand"}
disabled={disabled}
>
{isExpanded ? (
<ArrowsIn className="hover:scale-90" />
<span className="hover:scale-90">-</span>
) : (
<ArrowsOut className="hover:scale-110 active:scale-125 transition-all duration-150 ease-in-out" />
<span className="hover:scale-110 active:scale-125 transition-all duration-150 ease-in-out">+</span>
)}
</button>
)}

View File

@ -24,7 +24,7 @@ export default function ToggleButton({ initialChecked, onToggle, name, disabled
className="peer sr-only pointer-events-none"
disabled={disabled}
/>
<div className="pointer-events-none peer h-6 w-11 rounded-full bg-stone-400 after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:shadow-xl after:border after:border-gray-600 after:bg-white after:box-shadow-md after:transition-all after:content-[''] peer-checked:bg-sky-400 peer-checked:after:translate-x-full peer-checked:after:border-white peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-800"></div>
<div className="pointer-events-none peer h-6 w-11 rounded-full bg-stone-400 after:absolute after:left-[2px] after:top-[2px] after:h-5 after:w-5 after:rounded-full after:shadow-xl after:border after:border-gray-600 after:bg-white after:box-shadow-md after:transition-all after:content-[''] peer-checked:bg-lime-300 peer-checked:after:translate-x-full peer-checked:after:border-gray-400 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-800"></div>
</label>
);
}

View File

@ -1,7 +1,7 @@
import { PaperPlaneRight } from "@phosphor-icons/react";
import { useEffect, useState } from "react";
const OptionSelect = ({ data, settings, submit, message, setMessage }) => {
const OptionSelect = ({ data, settings, submit, message, setMessage ,workspace}) => {
const [selectedOptions, setSelectedOptions] = useState([]);
const [submitMessage, setSubmitMessage] = useState(false);
@ -12,6 +12,7 @@ const OptionSelect = ({ data, settings, submit, message, setMessage }) => {
}
}, [message]);
const handleSelection = (value) => {
const currentIndex = selectedOptions.indexOf(value);
const newSelectedOptions = [...selectedOptions];
@ -28,42 +29,11 @@ const OptionSelect = ({ data, settings, submit, message, setMessage }) => {
const handleSubmit = () => {
setSubmitMessage(true);
setSelectedOptions([])
};
// Grid of Buttons
if (settings.displayType === "buttons") {
return (
<div className=" mb-2 w-full p-4 backdrop-blur-sm rounded-t-xl overflow-hidden py-4 px-6 border-l border-t border-r border-[#2f3238]">
<Label label={data?.label} />
<div className=" pb-0 mt-2 grid grid-cols-1 md:grid-cols-2 gap-4 text-white/70 text-sm ">
{data.options.map((option, index) => (
<button
key={index}
className="group relative shadow-lg hover:shadow-sm transition-all duration-200 ease-in-out text-left p-2.5 border rounded-xl border-white/20 bg-sidebar hover:bg-sidebar/50 overflow-hidden "
onClick={() => {
{
handleSelection(option.value);
handleSubmit();
}
}}
>
<p className="truncate max-w-xl group-hover:max-w-xl group-hover:truncate-0">
<span className="text-white/50 mr-1">{index + 1}.</span>{" "}
{option.label}
</p>
<span className="absolute invisible group-hover:visible bg-black text-white text-sm rounded-lg p-2 left-0 bottom-full mb-2">
<span className="text-white/50 mr-1">{index + 1}.</span>{" "}
{option.label}
</span>
</button>
))}
</div>
</div>
);
}
// Normal List with Hyperlinks
if (settings.displayType === "list") {
if (settings.displayType.includes("list") && workspace?.metaResponseSettings?.inputs?.config?.components?.optionsList?.isEnabled) {
return (
<div className=" text-white/70 text-sm w-full backdrop-blur-sm rounded-t-xl overflow-hidden py-4 px-6 border-l border-t border-r border-[#2f3238]">
<Label {...data} />
@ -90,7 +60,7 @@ const OptionSelect = ({ data, settings, submit, message, setMessage }) => {
}
// Checkbox
if (settings.displayType === "checkbox") {
if (settings.displayType.includes("checkbox") && workspace?.metaResponseSettings?.inputs?.config?.components?.multiSelectCheckboxes?.isEnabled) {
return (
<div className="w-full p-4 backdrop-blur-sm rounded-t-xl overflow-hidden py-4 px-6 border-l border-t border-r border-[#2f3238]">
<Label label={data?.label} />
@ -126,10 +96,12 @@ const OptionSelect = ({ data, settings, submit, message, setMessage }) => {
}
// Dropdown Menu
return (
<div className="mt-5 mb-5 w-full backdrop-blur-sm rounded-t-xl py-4 px-6 border-l border-t border-r border-[#2f3238]">
<Label {...data} />
<select
if (settings.displayType.includes("dropdown") && workspace?.metaResponseSettings?.inputs?.config?.components?.dropDownMenu?.isEnabled) {
return (
<div className="mt-5 mb-5 w-full backdrop-blur-sm rounded-t-xl py-4 px-6 border-l border-t border-r border-[#2f3238]">
<Label {...data} />
<select
name="optionSelect"
id="optionSelect"
multiple={settings.allowMultiple}
@ -158,7 +130,39 @@ const OptionSelect = ({ data, settings, submit, message, setMessage }) => {
)}
</select>
</div>
);
)}
// Grid of Buttons fallback
return (
<div className=" mb-2 w-full p-4 backdrop-blur-sm rounded-t-xl overflow-hidden py-4 px-6 border-l border-t border-r border-[#2f3238]">
<Label label={data?.label} />
<div className=" pb-0 mt-2 grid grid-cols-1 md:grid-cols-2 gap-4 text-white/70 text-sm ">
{data.options.map((option, index) => (
<button
key={index}
className="group relative shadow-lg hover:shadow-sm transition-all duration-200 ease-in-out text-left p-2.5 border rounded-xl border-white/20 bg-sidebar hover:bg-sidebar/50 overflow-hidden "
onClick={() => {
{
handleSelection(option.value);
handleSubmit();
}
}}
>
<p className="truncate max-w-xl group-hover:max-w-xl group-hover:truncate-0">
<span className="text-white/50 mr-1">{index + 1}.</span>{" "}
{option.label}
</p>
<span className="absolute invisible group-hover:visible bg-black text-white text-sm rounded-lg p-2 left-0 bottom-full mb-2">
<span className="text-white/50 mr-1">{index + 1}.</span>{" "}
{option.label}
</span>
</button>
))}
</div>
</div>
);
};
const Label = ({ label, description }) => {

View File

@ -13,6 +13,10 @@ import PromptInput from "../PromptInput";
const inputComponents = {
text: PromptInput,
options: OptionSelect,
checkbox: OptionSelect,
list: OptionSelect,
buttons: OptionSelect,
dropdown: OptionSelect,
// range: RangeSlider,
// date: DatePicker,
// time: TimePicker,
@ -47,11 +51,14 @@ const MetaInputs = ({
// Condition to show the dynamic input or the forced text input
const shouldShowMetaInputs =
isMetaInputs && inputs !== undefined && !isForcedTextInput;
workspace?.metaResponse && inputs !== undefined && !isForcedTextInput
return (
<div className="w-full md:px-4 fixed md:absolute bottom-10 left-0 z-10 md:z-0 flex justify-center items-center">
<div className="w-[700px]">
{shouldShowMetaInputs ? (
<InputComponent
submit={submit}
@ -78,7 +85,7 @@ const MetaInputs = ({
sendCommand={sendCommand}
/>
)}
{isMetaInputs && inputs != undefined && (
{workspace?.metaResponse && inputs != undefined && (
<div className="w-full absolute -bottom-8 left-0 z-10 md:z-0 flex justify-center items-center">
<button
type="button"

View File

@ -109,7 +109,7 @@ export default function ChatContainer({
);
}
if (isMetaInputs) {
if (workspace?.metaResponse) {
const { remainingText, metaData } = extractMetaData(
_chatHistory[_chatHistory.length - 1].content
);
@ -131,11 +131,11 @@ export default function ChatContainer({
{isMobile && <SidebarMobileHeader />}
<div className="flex flex-col h-full w-full md:mt-0 mt-[40px]">
<ChatHistory
history={isMetaInputs ? finalizedChatHistory : chatHistory}
history={workspace?.metaResponse ? finalizedChatHistory : chatHistory}
workspace={workspace}
sendCommand={sendCommand}
/>
{isMetaInputs && currentInputMeta?.inputs?.type !== undefined ? (
{workspace?.metaResponse && currentInputMeta?.inputs?.type !== undefined ? (
<MetaInputs
inputs={currentInputMeta?.inputs}
isMetaInputs={isMetaInputs}

View File

@ -1,9 +1,5 @@
import { API_BASE } from "@/utils/constants";
import { baseHeaders } from "@/utils/request";
import { fetchEventSource } from "@microsoft/fetch-event-source";
import WorkspaceThread from "@/models/workspaceThread";
import { v4 } from "uuid";
import { ABORT_STREAM_EVENT } from "@/utils/chat";
const MetaResponse = {
toggle: async function (slug) {
@ -18,7 +14,6 @@ const MetaResponse = {
.catch(() => false);
return result;
},
update: async function (slug, data = {}) {
const { workspace, message } = await fetch(
`${API_BASE}/workspace/${slug}/update`,
@ -35,29 +30,6 @@ const MetaResponse = {
return { workspace, message };
},
delete: async function (slug) {
const result = await fetch(`${API_BASE}/workspace/${slug}`, {
method: "DELETE",
headers: baseHeaders(),
})
.then((res) => res.ok)
.catch(() => false);
return result;
},
uploadFile: async function (slug, formData) {
const response = await fetch(`${API_BASE}/workspace/${slug}/upload`, {
method: "POST",
body: formData,
headers: baseHeaders(),
});
const data = await response.json();
return { response, data };
},
getMetaResponseSettings: async function (slug) {
const settings = await fetch(
`${API_BASE}/workspace/${slug}/metaResponse/settings`,
@ -83,54 +55,6 @@ const MetaResponse = {
.catch(() => ({}));
return settings;
},
uploadPfp: async function (formData, slug) {
return await fetch(`${API_BASE}/workspace/${slug}/upload-pfp`, {
method: "POST",
body: formData,
headers: baseHeaders(),
})
.then((res) => {
if (!res.ok) throw new Error("Error uploading pfp.");
return { success: true, error: null };
})
.catch((e) => {
console.log(e);
return { success: false, error: e.message };
});
},
fetchPfp: async function (slug) {
return await fetch(`${API_BASE}/workspace/${slug}/pfp`, {
method: "GET",
cache: "no-cache",
headers: baseHeaders(),
})
.then((res) => {
if (res.ok && res.status !== 204) return res.blob();
throw new Error("Failed to fetch pfp.");
})
.then((blob) => (blob ? URL.createObjectURL(blob) : null))
.catch((e) => {
console.log(e);
return null;
});
},
removePfp: async function (slug) {
return await fetch(`${API_BASE}/workspace/${slug}/remove-pfp`, {
method: "DELETE",
headers: baseHeaders(),
})
.then((res) => {
if (res.ok) return { success: true, error: null };
throw new Error("Failed to remove pfp.");
})
.catch((e) => {
console.log(e);
return { success: false, error: e.message };
});
},
};
export default MetaResponse;

View File

@ -36,6 +36,7 @@ function ShowWorkspaceChat() {
setWorkspace({
..._workspace,
suggestedMessages,
metaResponseSettings: JSON.parse(_workspace.metaResponseSettings),
pfpUrl,
});
setLoading(false);
@ -46,7 +47,7 @@ function ShowWorkspaceChat() {
return (
<div className="w-screen h-screen overflow-hidden bg-sidebar flex">
{!isMobile && <Sidebar />}
<WorkspaceChatContainer loading={loading} workspace={workspace} />
<WorkspaceChatContainer loading={loading} workspace={workspace} />
</div>
);
}

View File

@ -10,13 +10,15 @@ export default function ChatEnableMetaResponse({ workspace, setHasChanges }) {
initialChecked={workspace?.metaResponse}
label={
workspace.metaResponse
? "Meta Response is Enabled"
? "Meta Response is (Enabled)"
: "Enable Meta Response"
}
onToggle={toggleMetaResponse}
name="metaResponse"
description="Turn on this feature to dynamically adjust the chat interface based on conversation context, using options like dropdowns, sliders, and suggestions for a tailored user experience."
badge
// badge
// badgeLabel="New"
// badgeAnimated
/>
</div>
);

View File

@ -1,11 +1,44 @@
import Button from "@/components/Generic/Buttons/Button";
import { chatPrompt } from "@/utils/chat";
import { useEffect, useState } from "react";
export default function ChatPromptSettings({ workspace, setHasChanges }) {
const [settings, setSettings] = useState(
JSON.parse(workspace.metaResponseSettings)
);
const [textareaSettings, setTextareaSettings] = useState({
isDisabled: false,
message: "",
disableClasses: "",
});
useEffect(() => {
console.log("ChatPromptSettings: ", settings);
if (
workspace.metaResponse &&
Object.keys(settings).length > 0 &&
Object.values(settings).some((feature) => feature.isEnabled)
) {
console.log("Prompt is managed by Meta Response");
setTextareaSettings({
...textareaSettings,
isDisabled: true,
message: "(Prompt is managed now by Meta Response)",
disableClasses: "cursor-not-allowed bg-zinc-900 text-white/40",
});
}
}, [settings]);
return (
<div>
<div className="relative">
<div className="flex flex-col">
<label htmlFor="name" className="block input-label">
Prompt
Prompt{" "}
{textareaSettings.isDisabled && (
<span className="text-xs text-red-500/80 text-right mt-1.5 ml-2">
{textareaSettings.message}
</span>
)}
</label>
<p className="text-white text-opacity-60 text-xs font-medium py-1.5">
The prompt that will be used on this workspace. Define the context and
@ -18,12 +51,17 @@ export default function ChatPromptSettings({ workspace, setHasChanges }) {
name="openAiPrompt"
rows={5}
defaultValue={chatPrompt(workspace)}
className="bg-zinc-900 placeholder:text-white/20 text-white text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 mt-2"
className={`${
textareaSettings.isDisabled
? textareaSettings.disableClasses
: " bg-zinc-900"
} text-white placeholder:text-white/20 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 mt-2`}
placeholder="Given the following conversation, relevant context, and a follow up question, reply with an answer to the current question the user is asking. Return only your response to the question given the above information following the users instructions as needed."
required={true}
wrap="soft"
autoComplete="off"
onChange={() => setHasChanges(true)}
disabled={textareaSettings.isDisabled}
/>
</div>
);

View File

@ -76,7 +76,6 @@ export default function ChatSettings({ workspace, setWorkspace }) {
/>
<ChatEnableMetaResponse
workspace={workspace}
setHasChanges={setHasChanges}
/>
{hasChanges && (

View File

@ -2,10 +2,16 @@ import ToggleBlock from "@/components/Generic/Blocks/ToggleBlock";
import showToast from "@/utils/toast";
import { useState } from "react";
export default function EnableSystemPrompt({ settings, onUpdateSettings }) {
export default function EnableSystemPrompt({
settings,
onUpdateSettings,
content,
}) {
const [isEnabled, setIsEnabled] = useState(
settings.config.systemPrompt.isEnabled
settings.config.systemPrompt.isEnabled ||
settings.config.systemPrompt.content !== ""
);
const toggleSystemPrompt = () => {
onUpdateSettings({
...settings,
@ -30,16 +36,17 @@ export default function EnableSystemPrompt({ settings, onUpdateSettings }) {
return (
<div className="relative w-full max-h-full ">
<ToggleBlock
initialChecked={settings.config.systemPrompt.isEnabled}
initialChecked={isEnabled}
label={
settings.config.systemPrompt.isEnabled
? "System Prompt (is now handled by Meta Response Inputs)"
isEnabled
? "System Prompt (Handled by Meta Response Inputs)"
: "Handle System Prompt - (optional)"
}
onToggle={toggleSystemPrompt}
name="systemPrompt"
description="Specify the context and instructions for the AI in this workspace. A well-defined prompt ensures the AI delivers relevant and precise responses."
inline
content={content}
/>
</div>
);

View File

@ -1,10 +1,11 @@
import Badge from "@/components/Generic/Badges/Badge";
import TextAreaBlock from "@/components/Generic/Blocks/TextAreaBlock";
import EnableSystemPrompt from "./EnableSystemPrompt";
import CheckBoxBlock from "@/components/Generic/Blocks/CheckBoxBlock";
import TitleBlock from "@/components/Generic/Blocks/TitleBlock";
import ToggleBlock from "@/components/Generic/Blocks/ToggleBlock";
import Button from "@/components/Generic/Buttons/Button";
import TextArea from "@/components/Generic/Inputs/TextArea";
import Badge from "@/components/Generic/Badges/Badge";
import showToast from "@/utils/toast";
import EnableSystemPrompt from "./EnableSystemPrompt";
export default function FeatureSettings({
workspace,
@ -19,15 +20,14 @@ export default function FeatureSettings({
settings={settings}
onUpdateSettings={onUpdateSettings}
/>
{settings.config.systemPrompt.isEnabled && (
{settings.config.systemPrompt.content !== "" ||
settings.config.systemPrompt.isEnabled ? (
<div className="flex flex-col gap-2">
<TextAreaBlock
workspace={workspace}
label="System Prompt"
description="Specify the context and instructions for the AI in this workspace. A well-defined prompt ensures the AI delivers relevant and precise responses."
name="systemPrompt"
defaultValue={settings.config.systemPrompt.content}
onSave={(newContent) =>
value={settings.config.systemPrompt.content}
onSave={(newContent) => {
onUpdateSettings({
...settings,
config: {
@ -37,63 +37,171 @@ export default function FeatureSettings({
content: newContent,
},
},
})
}
});
}}
code
initialRows={6}
/>
<CheckBoxBlock
workspace={workspace}
label="override workspace prompt"
inline
name="overrideSystemPrompt"
initialChecked={settings.config.systemPrompt.override}
onToggle={(override) =>
</div>
) : null}
</div>
<div>
<TitleBlock
label="Inputs Schema"
description="Define the schema context and instructions for the AI to generate a response. You should to provide a carefully crafted prompt so the AI can generate a relevant and accurate response."
/>
<div className=" flex gap-1 -mb-1 mt-4 flex-wrap items-center">
{settings.config.promptSchema.list.map((item, index) => (
<Badge
key={`schema_${index}`}
showClose
size="md"
rounded="md"
label={`${item?.title}`}
active={settings.config.promptSchema.active === index}
onSelect={
// fill promptSchema.active with index of selected item
(e) => {
e.stopPropagation();
console.log("selected item", item);
onUpdateSettings({
...settings,
config: {
...settings.config,
promptSchema: {
...settings.config.promptSchema,
active: index,
},
},
});
showToast(
`Schema ${item.title} has been selected`,
"success",
{ clear: true }
);
}
}
onDoubleClick={() => {
// rename item
console.log("renaming item", item);
const newSchemas = settings.config.promptSchema.list.map(
(s, i) => {
if (i === index) {
return {
...s,
title:
prompt("Enter new item title", s.title) || s.title,
};
}
return s;
}
);
console.log("New item", newSchemas);
onUpdateSettings({
...settings,
config: {
...settings.config,
systemPrompt: {
...settings.config.systemPrompt,
override,
promptSchema: {
...settings.config.promptSchema,
list: newSchemas,
},
},
})
}
/>
</div>
)}
</div>
<div>
<TitleBlock
label="Prompt-schema"
description="Define the schema context and instructions for the AI to generate a response. You should to provide a carefully crafted prompt so the AI can generate a relevant and accurate response."
/>
<div className=" flex gap-1 -mb-1 mt-4">
{settings.config.promptSchema.schemas.map((schema, index) => (
<Badge
key={`schema_${index}`}
size="md"
rounded="md"
label={`${schema.title}`}
});
}}
onClose={(e) => {
e.stopPropagation();
if (settings.config.promptSchema.list.length === 1) {
showToast("Cannot remove last schema", "error", {
clear: true,
});
return;
}
const newSchemas = settings.config.promptSchema.list.filter(
(_, i) => i !== index
);
const active = settings.config.promptSchema.active;
const newActive = active === index ? active - 1 : active;
onUpdateSettings({
...settings,
config: {
...settings.config,
promptSchema: {
...settings.config.promptSchema,
list: newSchemas,
active: newActive,
},
},
});
showToast(`Schema ${item.title} has been removed`, "success", {
clear: true,
});
}}
/>
))}
<Button
text="+"
onClick={() => {
const newSchema = {
title: prompt("Enter new item title"),
content: "",
};
// if cancel is clicked
if (!newSchema.title) return;
const newSchemas = [
...settings.config.promptSchema.list,
newSchema,
];
onUpdateSettings({
...settings,
config: {
...settings.config,
promptSchema: {
...settings.config.promptSchema,
list: newSchemas,
active: newSchemas.length - 1,
},
},
});
showToast(`Schema ${newSchema.title} has been added`, "success", {
clear: true,
});
}}
/>
</div>
<TextArea
name="openAiPrompt"
defaultValue={settings.config.promptSchema.content}
value={
// use value instead of defaultValue
settings.config.promptSchema.list[
settings.config.promptSchema.active
].content
}
placeholder="Given the following conversation, relevant context, and a follow up question, reply with an answer to the current question the user is asking. Return only your response to the question given the above information following the users instructions as needed."
onSave={(e) =>
onUpdateSettings({
...settings,
config: {
...settings.config,
promptSchema: {
...settings.config.promptSchema,
content: e,
onSave={
// fill promptSchema.list[active].content with new content
(newContent) => {
const newSchemas = settings.config.promptSchema.list.map(
(item, idx) => {
if (idx === settings.config.promptSchema.active) {
return {
...item,
content: newContent,
};
}
return item;
}
);
onUpdateSettings({
...settings,
config: {
...settings.config,
promptSchema: {
...settings.config.promptSchema,
list: newSchemas,
},
},
},
})
});
}
}
code
initialRows={6}
@ -151,6 +259,10 @@ export default function FeatureSettings({
settings.config.components[component].description
}
inline
disabled={settings.config.components[component].isDefault}
badge={settings.config.components[component].isDefault}
badgeLabel="Default"
badgeBg="bg-gray-500"
/>
</div>
);

View File

@ -1,12 +1,13 @@
import TitleBlock from "@/components/Generic/Blocks/TitleBlock";
import MetaResponse from "@/models/metaResponse";
import Workspace from "@/models/workspace";
import showToast from "@/utils/toast";
import { ChatText, Cube, Heart, UserCircle } from "@phosphor-icons/react";
import { useEffect, useState } from "react";
import EnableFeatures from "./EnableFeatures";
import FeatureSettings from "./FeatureSettings";
import TitleBlock from "@/components/Generic/Blocks/TitleBlock";
export default function MetaResponseSettings({ workspace }) {
export default function MetaResponseSettings({ workspace, setWorkspace }) {
const [settings, setSettings] = useState({});
useEffect(() => {
const fetchMetaResponseSettings = async () => {
@ -20,10 +21,47 @@ export default function MetaResponseSettings({ workspace }) {
}, []);
const handleToggleEnableFeatures = async (feature, enabled) => {
const updatedFeatureSettings = {
let updatedFeatureSettings = {
...settings[feature],
isEnabled: enabled,
};
// if enabling a feature, set the systemPrompt content to openAiPrompt and clear openAiPrompt
if (settings[feature].config.systemPrompt.openAiPrompt != "") {
console.log(
"settings[feature].config.systemPrompt.openAiPrompt: ",
settings[feature].config.systemPrompt.openAiPrompt
);
updatedFeatureSettings = {
...updatedFeatureSettings,
config: {
...settings[feature].config,
systemPrompt: {
...settings[feature].config.systemPrompt,
content: settings[feature].config.systemPrompt.openAiPrompt,
openAiPrompt: "",
},
},
};
// if disabling a feature, clear the systemPrompt.openAiPrompt for all other features
Object.keys(settings).map((f) => {
if (f !== feature) {
const featureSettings = settings[f];
if (featureSettings.config.systemPrompt.openAiPrompt !== "") {
const updatedFeatureSettings = {
...featureSettings,
config: {
...featureSettings.config,
systemPrompt: {
...featureSettings.config.systemPrompt,
openAiPrompt: "",
},
},
};
settings[f] = updatedFeatureSettings;
}
}
});
}
const updatedSettings = await MetaResponse.updateMetaResponseSettings(
workspace.slug,
@ -33,7 +71,7 @@ export default function MetaResponseSettings({ workspace }) {
}
);
console.log("updatedSettings: ", updatedSettings);
console.log("updatedSettings: - ", updatedSettings);
setSettings(updatedSettings);
showToast(
`${feature} has been ${enabled ? "enabled" : "disabled"}`,
@ -46,18 +84,65 @@ export default function MetaResponseSettings({ workspace }) {
feature,
updatedFeatureSettings
) => {
const updatedSettings = await MetaResponse.updateMetaResponseSettings(
workspace.slug,
{
...settings,
[feature]: updatedFeatureSettings,
}
);
console.log("updatedSettings: ", updatedSettings);
setSettings(updatedSettings);
try {
const updatedSettings = await MetaResponse.updateMetaResponseSettings(
workspace.slug,
{
...settings,
[feature]: updatedFeatureSettings,
}
);
setSettings(updatedSettings);
} catch (error) {
console.error(
" Error while updating feature settings in MetaResponseSettings: ",
error
);
showToast(`Error: ${error.message}`, "error", { clear: true });
}
};
const handleUpdateWorkspaceOpenAiPrompt = async () => {
const openAiPrompt = () => {
let openAiPrompt = "";
Object.keys(settings).map((feature) => {
const featureSettings = settings[feature];
if (featureSettings.isEnabled) {
openAiPrompt += featureSettings.config.systemPrompt.content;
openAiPrompt +=
featureSettings.config.promptSchema.list[
featureSettings.config.promptSchema.active
].content;
}
});
return openAiPrompt;
};
try {
const updatedSettings = await Workspace.update(workspace.slug, {
openAiPrompt: openAiPrompt(),
});
if (!updatedSettings) return;
setWorkspace(updatedSettings.workspace);
} catch (error) {
console.error(
" Error while updating workspace.openAiPrompt in MetaResponseSettings: ",
error
);
showToast(`Error: ${error.message}`, "error", { clear: true });
}
};
useEffect(() => {
if (
workspace.metaResponse &&
Object.keys(settings).length > 0 &&
Object.values(settings).some((feature) => feature.isEnabled)
) {
handleUpdateWorkspaceOpenAiPrompt();
}
}, [settings]);
const mapIcons = {
inputs: ChatText,
sentiments: Heart,
@ -66,8 +151,8 @@ export default function MetaResponseSettings({ workspace }) {
// const mapFeatures = {
// inputs: InputsFeature,
// sentiments: InputsFeature,
// avatars: InputsFeature,
// sentiments: SentimentsFeature,
// avatars: AvatarsFeature,
// };
return (
@ -75,7 +160,7 @@ export default function MetaResponseSettings({ workspace }) {
<div className="px-4">
<TitleBlock
label="Meta Response"
description="This feature lets you dictate app behavior through AI-generated responses, using a specific schema to structure data. It aligns with specially designed components that interpret this schema, enabling custom configurations for managing these components efficiently."
description="This feature lets you dictate app behavior through AI-generated responses, using a specific schema to structure data. It aligns with specially designed components that interpret this schema, enabling custom configurations for managing these components efficiently. runs better with OPENAI GPT-4 or nay advanced LLM model."
labelStyles="text-2xl font-semi-bold text-white"
Icon={Cube}
/>

View File

@ -44,18 +44,28 @@ function ShowWorkspaceChat() {
useEffect(() => {
async function getWorkspace() {
if (!slug) return;
const _workspace = await Workspace.bySlug(slug);
if (!_workspace) {
setLoading(false);
return;
}
try {
const _workspace = await Workspace.bySlug(slug);
if (!_workspace) {
setLoading(false);
return;
}
const suggestedMessages = await Workspace.getSuggestedMessages(slug);
setWorkspace({
..._workspace,
suggestedMessages,
});
setLoading(false);
// const metaResponseSettings =
// _workspace.metaResponseSettings &&
// JSON.parse(_workspace.metaResponseSettings);
const suggestedMessages = await Workspace.getSuggestedMessages(slug);
setWorkspace({
..._workspace,
suggestedMessages,
// metaResponseSettings,
});
setLoading(false);
} catch (error) {
console.error("Error getting suggested messages for workspace:", error);
}
}
getWorkspace();
}, [slug]);

View File

@ -28,6 +28,7 @@ const {
determineWorkspacePfpFilepath,
fetchPfp,
} = require("../utils/files/pfp");
const { WorkspaceMetaResponse } = require("../models/workspaceMetaResponse");
function workspaceEndpoints(app) {
if (!app) return;
@ -89,10 +90,16 @@ function workspaceEndpoints(app) {
}
if (
!currWorkspace.metaResponse &&
!currWorkspace.metaResponseSettings
!currWorkspace.metaResponseSettings &&
data.metaResponse
) {
metaResponseDefaultSettings.inputs.config.systemPrompt.openAiPrompt =
currWorkspace.openAiPrompt || "";
const metaResponseDefaultSettings = WorkspaceMetaResponse.defaultSettings;
console.log("currWorkspace.openAiPrompt", currWorkspace.openAiPrompt)
Object.keys(metaResponseDefaultSettings).map((feature) => {
metaResponseDefaultSettings[feature].config.systemPrompt.content =
data.openAiPrompt || currWorkspace.openAiPrompt ||
WorkspaceMetaResponse.defaultSystemPrompt;
});
data.metaResponseSettings = JSON.stringify(
metaResponseDefaultSettings
);
@ -583,173 +590,4 @@ function workspaceEndpoints(app) {
}
);
}
const metaResponseDefaultSettings = {
inputs: {
isEnabled: false,
config: {
systemPrompt: {
isEnabled: false,
content: "",
openAiPrompt: "",
overrideSystemPrompt: false,
suggestionsList: [
{
title: "",
content: "",
},
],
canEdit: ["admin", "manager"],
},
promptSchema: {
content: "## Prompt Guidelines\n- you are a helpful assistant, you will be provided a question to create a list of four elements\n- when requested to return structured data return them in a JSON object code block , don't introduce them or label them, just return them at the end of your response.\n- When presenting choices or detailed information, encapsulate the data in JSON format, aiming for a user-friendly interaction through:\n\t- type options: you will use this if options are a better way to seak users interaction, include displayTypess: buttons, list,checkbox, or dropdown based on the context.\n\t- type range: you will use this if the user is required to input a numeric between a certain range.\n\t- type rating: you will use this if the user should insert a rating, uswaly between one and five.\n\t- type date: you will use this if the user should insert a date.\n- if asked to return options return them as structured data, only when asked.\n- always return response as normal in markdown first then associate the data structure object below.\n- make your response rich in markdown.\n- if you find that your response at any time contain options follow the instructions above.\n---\n### Response Example\n#### Discover More\n**Fascinating Topic**\nExplore intriguing facts and details about your chosen subject, enhancing your understanding and curiosity.\n\n```json\n{\n \"inputs\": {\n \"type\": \"options\",\n \"data\": {\n \"options\": [\n {\n \"label\": \"Restart Router\",\n \"value\": \"restart router\"\n },\n {\n \"label\": \"Check Service Status\",\n \"value\": \"check service status\"\n },\n ... \n ],\n \"label\":\"Select Server \",\n \"description\":\"list of servers as described\"\n \n },\n \"settings\": {\n \"allowMultiple\": false,\n \"displayType\": \"chose one, buttons/list/dropdown\"\n }\n },\n \"sentiment\": \"happy\",\n \"style\": \"text\"\n}\n```\n\ninput types:\n```json\n{\n \"type\":\"options\",\n \"data\":{\n \"options\":[\n {\n \"label\":\"Restart Router\",\n \"value\":\"restart_router\"\n },\n {\n \"label\":\"Check Service Status\",\n \"value\":\"check_service_status\"\n },\n {\n \"label\":\"Contact Support\",\n \"value\":\"contact_support\"\n }\n ]\n },\n \"settings\":{\n \"allowMultiple\":false,\n \"displayType\":\"buttons\"\n }\n}\n```\n\n```json\n{\n \"type\":\"range\",\n \"data\":{\n \"min\":1,\n \"max\":10,\n \"step\":1\n },\n \"settings\":{\n \"showValue\":true\n }\n}\n```\n\n```json\n{\n \"type\":\"rating\",\n \"data\":{\n \"max\":5,\n \"defaultValue\":3,\n \"icon\":\"star\"\n }\n}\n```\n\n```json\n{\n \"type\":\"date\",\n \"settings\":{\n \"format\":\"YYYY-MM-DD\",\n \"minDate\":\"2021-01-01\",\n \"maxDate\":\"2023-12-31\"\n }\n}\n```",
schemas: [
{
title: "All Input Types",
content: "## Prompt Guidelines\n- you are a helpful assistant, you will be provided a question to create a list of four elements\n- when requested to return structured data return them in a JSON object code block , don't introduce them or label them, just return them at the end of your response.\n- When presenting choices or detailed information, encapsulate the data in JSON format, aiming for a user-friendly interaction through:\n\t- type options: you will use this if options are a better way to seak users interaction, include displayTypess: buttons, list,checkbox, or dropdown based on the context.\n\t- type range: you will use this if the user is required to input a numeric between a certain range.\n\t- type rating: you will use this if the user should insert a rating, uswaly between one and five.\n\t- type date: you will use this if the user should insert a date.\n- if asked to return options return them as structured data, only when asked.\n- always return response as normal in markdown first then associate the data structure object below.\n- make your response rich in markdown.\n- if you find that your response at any time contain options follow the instructions above.\n---\n### Response Example\n#### Discover More\n**Fascinating Topic**\nExplore intriguing facts and details about your chosen subject, enhancing your understanding and curiosity.\n\n```json\n{\n \"inputs\": {\n \"type\": \"options\",\n \"data\": {\n \"options\": [\n {\n \"label\": \"Restart Router\",\n \"value\": \"restart router\"\n },\n {\n \"label\": \"Check Service Status\",\n \"value\": \"check service status\"\n },\n ... \n ],\n \"label\":\"Select Server \",\n \"description\":\"list of servers as described\"\n \n },\n \"settings\": {\n \"allowMultiple\": false,\n \"displayType\": \"chose one, buttons/list/dropdown\"\n }\n },\n \"sentiment\": \"happy\",\n \"style\": \"text\"\n}\n```\n\ninput types:\n```json\n{\n \"type\":\"options\",\n \"data\":{\n \"options\":[\n {\n \"label\":\"Restart Router\",\n \"value\":\"restart_router\"\n },\n {\n \"label\":\"Check Service Status\",\n \"value\":\"check_service_status\"\n },\n {\n \"label\":\"Contact Support\",\n \"value\":\"contact_support\"\n }\n ]\n },\n \"settings\":{\n \"allowMultiple\":false,\n \"displayType\":\"buttons\"\n }\n}\n```\n\n```json\n{\n \"type\":\"range\",\n \"data\":{\n \"min\":1,\n \"max\":10,\n \"step\":1\n },\n \"settings\":{\n \"showValue\":true\n }\n}\n```\n\n```json\n{\n \"type\":\"rating\",\n \"data\":{\n \"max\":5,\n \"defaultValue\":3,\n \"icon\":\"star\"\n }\n}\n```\n\n```json\n{\n \"type\":\"date\",\n \"settings\":{\n \"format\":\"YYYY-MM-DD\",\n \"minDate\":\"2021-01-01\",\n \"maxDate\":\"2023-12-31\"\n }\n}\n```",
},
{
title: "Suggestions Buttons Type",
content: "## Prompt Guidelines\n- you are a helpful assistant, you will be provided a question to create a list of four elements\n- when requested to return structured data return them in a JSON object code block , don't introduce them or label them, just return them at the end of your response.\n- When presenting choices or detailed information, encapsulate the data in JSON format, aiming for a user-friendly interaction through:\n\t- type options: you will use this if options are a better way to seak users interaction, include displayTypess: buttons, list,checkbox, or dropdown based on the context.\n\t- type range: you will use this if the user is required to input a numeric between a certain range.\n\t- type rating: you will use this if the user should insert a rating, uswaly between one and five.\n\t- type date: you will use this if the user should insert a date.\n- if asked to return options return them as structured data, only when asked.\n- always return response as normal in markdown first then associate the data structure object below.\n- make your response rich in markdown.\n- if you find that your response at any time contain options follow the instructions above.\n---\n### Response Example\n#### Discover More\n**Fascinating Topic**\nExplore intriguing facts and details about your chosen subject, enhancing your understanding and curiosity.\n\n```json\n{\n \"inputs\": {\n \"type\": \"options\",\n \"data\": {\n \"options\": [\n {\n \"label\": \"Restart Router\",\n \"value\": \"restart router\"\n },\n {\n \"label\": \"Check Service Status\",\n \"value\": \"check service status\"\n },\n ... \n ],\n \"label\":\"Select Server \",\n \"description\":\"list of servers as described\"\n \n },\n \"settings\": {\n \"allowMultiple\": false,\n \"displayType\": \"chose one, buttons/list/dropdown\"\n }\n },\n \"sentiment\": \"happy\",\n \"style\": \"text\"\n}\n```",
},
],
overrideWorkspacePrompt: false,
canEdit: ["admin", "manager"],
},
components: {
dropDownMenu: {
isEnabled: false,
options: [],
description: "Drop Down menu best to select between functional derisions, ie: continue, Repeat or Move to a new sequence.. etc",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/dropdown-menu",
},
optionsList: {
isEnabled: false,
options: [],
description: "Best suited for expansion on a topic",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/options-list",
},
optionsButtons: {
isEnabled: false,
options: [],
description: "Chat will provide answers with the LLM's general knowledge and document context that is found.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/options-buttons",
},
multiSelectCheckboxes: {
isEnabled: false,
options: [],
description: "Chat will provide answers with the LLM's general knowledge and document context that is found.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/multi-select-checkboxes",
},
},
},
permissions: ["user"],
description: "Traditionally, interaction with AnythingLLM occurs through a text area. Meta Inputs enhance this by offering alternative interaction methods, including option buttons, multi-select checkboxes, sliders, drop-down menus, and date/time selectors. To utilize these components, you'll need to guide the LLM on incorporating them into its responses with a specific schema",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs",
},
sentiments: {
isEnabled: false,
config: {
systemPrompt: {
isEnabled: false,
content: "",
openAiPrompt: "",
overrideSystemPrompt: false,
suggestionsList: [
{
title: "",
content: "",
},
],
canEdit: ["admin", "manager"],
},
promptSchema: {
content: "",
schemas: [
{
title: "",
content: "",
},
],
overrideWorkspacePrompt: false,
canEdit: ["admin", "manager"],
},
components: {
dropDownMenu: {
isEnabled: false,
options: [],
},
optionsList: {
isEnabled: false,
options: [],
},
optionsButtons: {
isEnabled: false,
options: [],
},
multiSelectCheckboxes: {
isEnabled: false,
options: [],
},
},
},
permissions: ["user"],
description: "Activate to enable the AI to analyze and adapt its responses based on the emotional tone of the conversation, enhancing interaction personalization",
infoLink: "https://docs.anythingllm.com/docs/meta-response/sentiments",
},
avatars: {
isEnabled: false,
config: {
systemPrompt: {
isEnabled: false,
content: "",
openAiPrompt: "",
overrideSystemPrompt: false,
suggestionsList: [
{
title: "",
content: "",
},
],
canEdit: ["admin", "manager"],
},
promptSchema: {
content: "",
schemas: [
{
title: "",
content: "",
},
],
overrideWorkspacePrompt: false,
canEdit: ["admin", "manager"],
},
components: {
dropDownMenu: {
isEnabled: false,
options: [],
},
optionsList: {
isEnabled: false,
options: [],
},
optionsButtons: {
isEnabled: false,
options: [],
},
multiSelectCheckboxes: {
isEnabled: false,
options: [],
},
},
},
permissions: ["user"],
description: "Enable avatars to reflect user sentiments, allowing the AI to visually empathize and convey understanding through changes in its profile image based on the meta object's sentiment data.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/avatars",
},
};
module.exports = { workspaceEndpoints };
module.exports = { workspaceEndpoints };

View File

@ -63,7 +63,211 @@ const WorkspaceMetaResponse = {
console.error(error.message);
return { workspace: null, message: error.message };
}
}
},
defaultSystemPrompt: "Given the following conversation, relevant context, and a follow up question, reply with an answer to the current question the user is asking. Return only your response to the question given the above information following the users instructions as needed.\ngive user some options",
defaultSettings: {
inputs: {
isEnabled: true,
config: {
systemPrompt: {
isEnabled: true,
openAiPrompt: "",
overrideSystemPrompt: false,
content: "",
active: 0,
list: [
{
title: "original prompt",
content: "",
},
],
canEdit: ["admin", "manager"],
},
promptSchema: {
active: 0,
list: [
{
title: "All Input Types",
content: "## Prompt Guidelines\n- you are a helpful assistant, you will be provided a question to create a list of four elements\n- when requested to return structured data return them in a JSON object code block , don't introduce them or label them, just return them at the end of your response.\n- When presenting choices or detailed information, encapsulate the data in JSON format, aiming for a user-friendly interaction through:\n\t- type options: you will use this if options are a better way to seak users interaction, include displayTypess: buttons, list,checkbox, or dropdown based on the context.\n\t- type range: you will use this if the user is required to input a numeric between a certain range.\n\t- type rating: you will use this if the user should insert a rating, uswaly between one and five.\n\t- type date: you will use this if the user should insert a date.\n- if asked to return options return them as structured data, only when asked.\n- always return response as normal in markdown first then associate the data structure object below.\n- make your response rich in markdown.\n- if you find that your response at any time contain options follow the instructions above.\n- Important follow strictly the json schema examples provided below\n---\n### Response Example\n#### Discover More\n**Fascinating Topic**\nExplore intriguing facts and details about your chosen subject, enhancing your understanding and curiosity.\n\n```json\n{\n \"inputs\": {\n \"type\": \"options\",\n \"data\": {\n \"options\": [\n {\n \"label\": \"Restart Router\",\n \"value\": \"restart router\"\n },\n {\n \"label\": \"Check Service Status\",\n \"value\": \"check service status\"\n },\n ... \n ],\n \"label\":\"Select Server \",\n \"description\":\"list of servers as described\"\n \n },\n \"settings\": {\n \"allowMultiple\": false,\n \"displayType\": \"chose one, buttons/list/dropdown\"\n }\n },\n \"sentiment\": \"happy\",\n \"style\": \"text\"\n}\n```\n\ninput types:\n```json\n{\n \"inputs\": {\n \"type\":\"options\",\n \"data\":{\n \"options\":[\n {\n \"label\":\"Restart Router\",\n \"value\":\"restart_router\"\n },\n {\n \"label\":\"Check Service Status\",\n \"value\":\"check_service_status\"\n },\n {\n \"label\":\"Contact Support\",\n \"value\":\"contact_support\"\n }\n ]\n },\n \"settings\":{\n \"allowMultiple\":false,\n \"displayType\":\"buttons\"\n }\n }\n}\n```\n\n```json\n{\n \"inputs\": {\n \"type\":\"range\",\n \"data\":{\n \"min\":1,\n \"max\":10,\n \"step\":1\n },\n \"settings\":{\n \"showValue\":true\n }\n }\n}\n```\n\n```json\n{\n\"inputs\": {\n \"type\":\"rating\",\n \"data\":{\n \"max\":5,\n \"defaultValue\":3,\n \"icon\":\"star\"\n }\n }\n}\n```\n\n```json\n{\n\"inputs\": {\n \"type\":\"date\",\n \"settings\":{\n \"format\":\"YYYY-MM-DD\",\n \"minDate\":\"2021-01-01\",\n \"maxDate\":\"2023-12-31\"\n }\n}\n}\n```\n---\n",
},
{
title: "Suggestions Buttons Type",
content: "## Prompt Guidelines Suggestions Buttons Type\n- you are a helpful assistant, you will be provided a question to create a list of four elements\n- when requested to return structured data return them in a JSON object code block , don't introduce them or label them, just return them at the end of your response.\n- When presenting choices or detailed information, encapsulate the data in JSON format, aiming for a user-friendly interaction through:\n\t- type options: you will use this if options are a better way to seak users interaction, include displayTypess: buttons, list,checkbox, or dropdown based on the context.\n\t- type range: you will use this if the user is required to input a numeric between a certain range.\n\t- type rating: you will use this if the user should insert a rating, uswaly between one and five.\n\t- type date: you will use this if the user should insert a date.\n- if asked to return options return them as structured data, only when asked.\n- always return response as normal in markdown first then associate the data structure object below.\n- make your response rich in markdown.\n- if you find that your response at any time contain options follow the instructions above.\n- Important follow strictly the json schema examples provided below\n---\n### Response Example\n#### Discover More\n**Fascinating Topic**\nExplore intriguing facts and details about your chosen subject, enhancing your understanding and curiosity.\n\n```json\n{\n \"inputs\": {\n \"type\": \"options\",\n \"data\": {\n \"options\": [\n {\n \"label\": \"Restart Router\",\n \"value\": \"restart router\"\n },\n {\n \"label\": \"Check Service Status\",\n \"value\": \"check service status\"\n },\n ... \n ],\n \"label\":\"Select Server \",\n \"description\":\"list of servers as described\"\n \n },\n \"settings\": {\n \"allowMultiple\": false,\n \"displayType\": \"chose one, buttons/list/dropdown\"\n }\n },\n \"sentiment\": \"happy\",\n \"style\": \"text\"\n}\n```",
},
],
overrideWorkspacePrompt: false,
canEdit: ["admin", "manager"],
},
components: {
optionsButtons: {
isEnabled: true,
isDefault: true,
options: [],
description: "Chat will provide answers with the LLM's general knowledge and document context that is found.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/options-buttons",
},
optionsList: {
isEnabled: false,
isDefault: false,
options: [],
description: "Best suited for expansion on a topic",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/options-list",
},
multiSelectCheckboxes: {
isEnabled: false,
isDefault: false,
options: [],
description: "Chat will provide answers with the LLM's general knowledge and document context that is found.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/multi-select-checkboxes",
},
dropDownMenu: {
isEnabled: false,
isDefault: false,
options: [],
description: "Drop Down menu best to select between functional derisions, ie: continue, Repeat or Move to a new sequence.. etc",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/dropdown-menu",
},
},
},
permissions: ["user"],
description: "Traditionally, interaction with AnythingLLM occurs through a text area. Meta Inputs enhance this by offering alternative interaction methods, including option buttons, multi-select checkboxes, sliders, drop-down menus, and date/time selectors. To utilize these components, you'll need to guide the LLM on incorporating them into its responses with a specific schema",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs",
},
sentiments: {
isEnabled: false,
config: {
systemPrompt: {
isEnabled: false,
openAiPrompt: "",
overrideSystemPrompt: false,
content: "",
active: 0,
list: [
{
title: "original prompt",
content: "",
},
],
canEdit: ["admin", "manager"],
},
promptSchema: {
active: 0,
list: [
{
title: "All Input Types",
content: "## Prompt Guidelines All Input Types\n- you are a helpful assistant, you will be provided a question to create a list of four elements\n- when requested to return structured data return them in a JSON object code block , don't introduce them or label them, just return them at the end of your response.\n- When presenting choices or detailed information, encapsulate the data in JSON format, aiming for a user-friendly interaction through:\n\t- type options: you will use this if options are a better way to seak users interaction, include displayTypess: buttons, list,checkbox, or dropdown based on the context.\n\t- type range: you will use this if the user is required to input a numeric between a certain range.\n\t- type rating: you will use this if the user should insert a rating, uswaly between one and five.\n\t- type date: you will use this if the user should insert a date.\n- if asked to return options return them as structured data, only when asked.\n- always return response as normal in markdown first then associate the data structure object below.\n- make your response rich in markdown.\n- if you find that your response at any time contain options follow the instructions above.\n---\n### Response Example\n#### Discover More\n**Fascinating Topic**\nExplore intriguing facts and details about your chosen subject, enhancing your understanding and curiosity.\n\n```json\n{\n \"inputs\": {\n \"type\": \"options\",\n \"data\": {\n \"options\": [\n {\n \"label\": \"Restart Router\",\n \"value\": \"restart router\"\n },\n {\n \"label\": \"Check Service Status\",\n \"value\": \"check service status\"\n },\n ... \n ],\n \"label\":\"Select Server \",\n \"description\":\"list of servers as described\"\n \n },\n \"settings\": {\n \"allowMultiple\": false,\n \"displayType\": \"chose one, buttons/list/dropdown\"\n }\n },\n \"sentiment\": \"happy\",\n \"style\": \"text\"\n}\n```\n\ninput types:\n```json\n{\n \"type\":\"options\",\n \"data\":{\n \"options\":[\n {\n \"label\":\"Restart Router\",\n \"value\":\"restart_router\"\n },\n {\n \"label\":\"Check Service Status\",\n \"value\":\"check_service_status\"\n },\n {\n \"label\":\"Contact Support\",\n \"value\":\"contact_support\"\n }\n ]\n },\n \"settings\":{\n \"allowMultiple\":false,\n \"displayType\":\"buttons\"\n }\n}\n```\n\n```json\n{\n \"type\":\"range\",\n \"data\":{\n \"min\":1,\n \"max\":10,\n \"step\":1\n },\n \"settings\":{\n \"showValue\":true\n }\n}\n```\n\n```json\n{\n \"type\":\"rating\",\n \"data\":{\n \"max\":5,\n \"defaultValue\":3,\n \"icon\":\"star\"\n }\n}\n```\n\n```json\n{\n \"type\":\"date\",\n \"settings\":{\n \"format\":\"YYYY-MM-DD\",\n \"minDate\":\"2021-01-01\",\n \"maxDate\":\"2023-12-31\"\n }\n}\n```",
},
{
title: "Suggestions Buttons Type",
content: "## Prompt Guidelines Suggestions Buttons Type\n- you are a helpful assistant, you will be provided a question to create a list of four elements\n- when requested to return structured data return them in a JSON object code block , don't introduce them or label them, just return them at the end of your response.\n- When presenting choices or detailed information, encapsulate the data in JSON format, aiming for a user-friendly interaction through:\n\t- type options: you will use this if options are a better way to seak users interaction, include displayTypess: buttons, list,checkbox, or dropdown based on the context.\n\t- type range: you will use this if the user is required to input a numeric between a certain range.\n\t- type rating: you will use this if the user should insert a rating, uswaly between one and five.\n\t- type date: you will use this if the user should insert a date.\n- if asked to return options return them as structured data, only when asked.\n- always return response as normal in markdown first then associate the data structure object below.\n- make your response rich in markdown.\n- if you find that your response at any time contain options follow the instructions above.\n---\n### Response Example\n#### Discover More\n**Fascinating Topic**\nExplore intriguing facts and details about your chosen subject, enhancing your understanding and curiosity.\n\n```json\n{\n \"inputs\": {\n \"type\": \"options\",\n \"data\": {\n \"options\": [\n {\n \"label\": \"Restart Router\",\n \"value\": \"restart router\"\n },\n {\n \"label\": \"Check Service Status\",\n \"value\": \"check service status\"\n },\n ... \n ],\n \"label\":\"Select Server \",\n \"description\":\"list of servers as described\"\n \n },\n \"settings\": {\n \"allowMultiple\": false,\n \"displayType\": \"chose one, buttons/list/dropdown\"\n }\n },\n \"sentiment\": \"happy\",\n \"style\": \"text\"\n}\n```",
},
],
overrideWorkspacePrompt: false,
canEdit: ["admin", "manager"],
},
components: {
optionsButtons: {
isEnabled: true,
isDefault: true,
options: [],
description: "Chat will provide answers with the LLM's general knowledge and document context that is found.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/options-buttons",
},
optionsList: {
isEnabled: false,
isDefault: false,
options: [],
description: "Best suited for expansion on a topic",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/options-list",
},
multiSelectCheckboxes: {
isEnabled: false,
isDefault: false,
options: [],
description: "Chat will provide answers with the LLM's general knowledge and document context that is found.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/multi-select-checkboxes",
},
dropDownMenu: {
isEnabled: false,
isDefault: false,
options: [],
description: "Drop Down menu best to select between functional derisions, ie: continue, Repeat or Move to a new sequence.. etc",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/dropdown-menu",
},
},
},
permissions: ["user"],
description: "Activate to enable the AI to analyze and adapt its responses based on the emotional tone of the conversation, enhancing interaction personalization",
infoLink: "https://docs.anythingllm.com/docs/meta-response/sentiments",
},
avatars: {
isEnabled: false,
config: {
systemPrompt: {
isEnabled: false,
openAiPrompt: "",
overrideSystemPrompt: false,
content: "",
active: 0,
list: [
{
title: "original prompt",
content: "",
},
],
canEdit: ["admin", "manager"],
},
promptSchema: {
active: 0,
list: [
{
title: "All Input Types",
content: "## Prompt Guidelines All Input Types\n- you are a helpful assistant, you will be provided a question to create a list of four elements\n- when requested to return structured data return them in a JSON object code block , don't introduce them or label them, just return them at the end of your response.\n- if asked to return options return them as structured data, only when asked.\n- always return response as normal in markdown first then associate the data structure object below.\n- make your response rich in markdown.\n- if you find that your response at any time contain options follow the instructions above.\n---\nResponse example:\n#### Discover More\n**Fascinating Topic**\nExplore intriguing facts and details about your chosen subject, enhancing your understanding and curiosity.\n\n```json\n{\n \"inputs\": {\n \"type\": \"options\",\n \"data\": {\n \"options\": [\n {\n \"label\": \"Restart Router\",\n \"value\": \"restart router\"\n },\n {\n \"label\": \"Check Service Status\",\n \"value\": \"check service status\"\n },\n ... \n ],\n \"label\":\"Select Server \",\n \"description\":\"list of servers as described\"\n \n },\n \"settings\": {\n \"allowMultiple\": false,\n \"displayType\": \"chose one, buttons/list/dropdown\"\n }\n },\n \"sentiment\": \"happy\",\n \"style\": \"text\"\n}\n```\n\ninput types:\n```json\n{\n \"inputs\": {\n \"type\":\"options\",\n \"data\":{\n \"options\":[\n {\n \"label\":\"Restart Router\",\n \"value\":\"restart_router\"\n },\n {\n \"label\":\"Check Service Status\",\n \"value\":\"check_service_status\"\n },\n {\n \"label\":\"Contact Support\",\n \"value\":\"contact_support\"\n }\n ]\n },\n \"settings\":{\n \"allowMultiple\":false,\n \"displayType\":\"buttons\"\n }\n }\n}\n```\n\n```json\n{\n \"inputs\": {\n \"type\":\"range\",\n \"data\":{\n \"min\":1,\n \"max\":10,\n \"step\":1\n },\n \"settings\":{\n \"showValue\":true\n }\n }\n}\n```\n\n```json\n{\n\"inputs\": {\n \"type\":\"rating\",\n \"data\":{\n \"max\":5,\n \"defaultValue\":3,\n \"icon\":\"star\"\n }\n }\n}\n```\n\n```json\n{\n\"inputs\": {\n \"type\":\"date\",\n \"settings\":{\n \"format\":\"YYYY-MM-DD\",\n \"minDate\":\"2021-01-01\",\n \"maxDate\":\"2023-12-31\"\n }\n}\n}\n```",
},
{
title: "Suggestions Buttons Type",
content: "## Prompt Guidelines Suggestions Buttons Type\n- you are a helpful assistant, you will be provided a question to create a list of four elements\n- when requested to return structured data return them in a JSON object code block , don't introduce them or label them, just return them at the end of your response.\n- When presenting choices or detailed information, encapsulate the data in JSON format, aiming for a user-friendly interaction through:\n\t- type options: you will use this if options are a better way to seak users interaction, include displayTypess: buttons, list,checkbox, or dropdown based on the context.\n\t- type range: you will use this if the user is required to input a numeric between a certain range.\n\t- type rating: you will use this if the user should insert a rating, uswaly between one and five.\n\t- type date: you will use this if the user should insert a date.\n- if asked to return options return them as structured data, only when asked.\n- always return response as normal in markdown first then associate the data structure object below.\n- make your response rich in markdown.\n- if you find that your response at any time contain options follow the instructions above.\n---\n### Response Example\n#### Discover More\n**Fascinating Topic**\nExplore intriguing facts and details about your chosen subject, enhancing your understanding and curiosity.\n\n```json\n{\n \"inputs\": {\n \"type\": \"options\",\n \"data\": {\n \"options\": [\n {\n \"label\": \"Restart Router\",\n \"value\": \"restart router\"\n },\n {\n \"label\": \"Check Service Status\",\n \"value\": \"check service status\"\n },\n ... \n ],\n \"label\":\"Select Server \",\n \"description\":\"list of servers as described\"\n \n },\n \"settings\": {\n \"allowMultiple\": false,\n \"displayType\": \"chose one, buttons/list/dropdown\"\n }\n },\n \"sentiment\": \"happy\",\n \"style\": \"text\"\n}\n```",
},
],
overrideWorkspacePrompt: false,
canEdit: ["admin", "manager"],
},
components: {
optionsButtons: {
isEnabled: true,
isDefault: true,
options: [],
description: "Chat will provide answers with the LLM's general knowledge and document context that is found.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/options-buttons",
},
optionsList: {
isEnabled: false,
isDefault: false,
options: [],
description: "Best suited for expansion on a topic",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/options-list",
},
multiSelectCheckboxes: {
isEnabled: false,
isDefault: false,
options: [],
description: "Chat will provide answers with the LLM's general knowledge and document context that is found.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/multi-select-checkboxes",
},
dropDownMenu: {
isEnabled: false,
isDefault: false,
options: [],
description: "Drop Down menu best to select between functional derisions, ie: continue, Repeat or Move to a new sequence.. etc",
infoLink: "https://docs.anythingllm.com/docs/meta-response/inputs/dropdown-menu",
},
},
},
permissions: ["user"],
description: "Enable avatars to reflect user sentiments, allowing the AI to visually empathize and convey understanding through changes in its profile image based on the meta object's sentiment data.",
infoLink: "https://docs.anythingllm.com/docs/meta-response/avatars",
},
},
};
module.exports = { WorkspaceMetaResponse };