diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/DynamicInput/OptionSelect/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/DynamicInput/OptionSelect/index.jsx
new file mode 100644
index 00000000..f8b4d7ef
--- /dev/null
+++ b/frontend/src/components/WorkspaceChat/ChatContainer/DynamicInput/OptionSelect/index.jsx
@@ -0,0 +1,79 @@
+const OptionSelect = ({ data, settings }) => {
+ const handleSelection = (value) => {
+ // Implement your logic to handle selection
+ console.log(value);
+ };
+
+ // Grid of Buttons
+ if (settings.displayType === "buttons") {
+ return (
+
+ {data.options.map((option, index) => (
+
+ ))}
+
+ );
+ }
+
+ // Normal List with Hyperlinks
+ if (settings.displayType === "list") {
+ return (
+
+ );
+ }
+
+ // Dropdown Menu
+ return (
+
+
+
+
+ {data?.description}
+
+
+
+
+ );
+};
+
+export default OptionSelect;
diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/DynamicInput/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/DynamicInput/index.jsx
new file mode 100644
index 00000000..fbebab6c
--- /dev/null
+++ b/frontend/src/components/WorkspaceChat/ChatContainer/DynamicInput/index.jsx
@@ -0,0 +1,63 @@
+import React from "react";
+// import TextInput from './TextInput';
+import OptionSelect from "@/components/WorkspaceChat/ChatContainer/DynamicInput/OptionSelect";
+import { ArrowUUpLeft, Keyboard } from "@phosphor-icons/react";
+// import RangeSlider from './RangeSlider';
+// import DatePicker from './DatePicker';
+// import TimePicker from './TimePicker';
+// import DateTimePicker from './DateTimePicker';
+// import FileUpload from './FileUpload';
+// import Rating from './Rating';
+// import Checkbox from './Checkbox';
+
+const inputComponents = {
+ // text: TextInput,
+ options: OptionSelect,
+ // range: RangeSlider,
+ // date: DatePicker,
+ // time: TimePicker,
+ // datetime: DateTimePicker,
+ // file: FileUpload,
+ // rating: Rating,
+ // checkbox: Checkbox
+};
+
+const DynamicInput = ({
+ inputs,
+ isDynamicInput,
+ isForcedTextInput,
+ setIsForcedTextInput,
+}) => {
+ const InputComponent = inputComponents[inputs?.type] || null;
+ if (!InputComponent) {
+ return null; // or any fallback UI
+ }
+ return (
+
+
+
+ {isDynamicInput && inputs != undefined && (
+
+
+
+ )}
+
+
+ );
+};
+
+export default DynamicInput;
diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx
index 2b9c5ca4..f545d692 100644
--- a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx
+++ b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/index.jsx
@@ -52,7 +52,7 @@ export default function PromptInput({
const watchForSlash = debounce(checkForSlash, 300);
return (
-
+
{
setMessage(event.target.value);
};
@@ -123,6 +130,31 @@ export default function ChatContainer({ workspace, knownHistory = [], isDynamicI
loadingResponse === true && fetchReply();
}, [loadingResponse, chatHistory, workspace]);
+ const renderInputComponent = () => {
+ if (
+ !isDynamicInput ||
+ currentInputMeta?.inputs?.type === "text" ||
+ currentInputMeta?.inputs === undefined ||
+ isForcedTextInput
+ ) {
+ return (
+
+ );
+ }
+
+ if (currentInputMeta?.inputs?.type !== "text") {
+ return ;
+ }
+ };
+
return (
-
+ {renderInputComponent()}
+ {isDynamicInput && currentInputMeta?.inputs != undefined && (
+
+
+
+ )}
);
diff --git a/frontend/src/components/WorkspaceChat/index.jsx b/frontend/src/components/WorkspaceChat/index.jsx
index 964b6319..dbbd9370 100644
--- a/frontend/src/components/WorkspaceChat/index.jsx
+++ b/frontend/src/components/WorkspaceChat/index.jsx
@@ -11,8 +11,9 @@ export default function WorkspaceChat({ loading, workspace }) {
const { threadSlug = null } = useParams();
const [history, setHistory] = useState([]);
const [loadingHistory, setLoadingHistory] = useState(true);
+ const [currentInputMeta, setCurrentInputMeta] = useState(null);
- const isDynamicInput = false;
+ const isDynamicInput = true;
useEffect(() => {
async function getHistory() {
@@ -34,6 +35,7 @@ export default function WorkspaceChat({ loading, workspace }) {
const { remainingText, metaData } = extractMetaData(
message.content
);
+ setCurrentInputMeta(metaData);
return { ...message, content: remainingText, metaData };
}
return message;
@@ -79,7 +81,15 @@ export default function WorkspaceChat({ loading, workspace }) {
}
setEventDelegatorForCodeSnippets();
- return ;
+ return (
+
+ );
}
// Enables us to safely markdown and sanitize all responses without risk of injection