{part.slice(1, -1)};
+ } else {
+ return part;
+ }
+ });
+ } else {
+ return part;
+ }
+ });
- return <>{codeParts}>; // return the wrapped text
-}
\ No newline at end of file
+ return <>{codeParts}>; // return the wrapped text
+ } else {
+ const matchRegex = /(`[^`]+?`)/g;
+ const parts = text.split(matchRegex);
+ // console.log('parts', parts);
+
+ // map over the parts and wrap any text between tildes with tags
+ const codeParts = parts.map((part, i) => {
+ if (part.match(matchRegex)) {
+ return {part.slice(1, -1)};
+ } else {
+ return part;
+ }
+ });
+
+ return <>{codeParts}>; // return the wrapped text
+ }
+}
diff --git a/src/components/Messages/Embed.jsx b/src/components/Messages/Embed.jsx
new file mode 100644
index 0000000000..004d4a1e16
--- /dev/null
+++ b/src/components/Messages/Embed.jsx
@@ -0,0 +1,62 @@
+import React from 'react';
+// import '~/atom-one-dark.css';
+
+export default function Embed({ children, language = ''}) {
+ return (
+
+
+
+ { language }
+
+
+
+ { children }
+ {/* export default function CodeWrapper({ text }) {
+ const matchRegex = /(`[^`]+?`)/g; // regex to match backticks and text between them
+ const parts = text.split(matchRegex);
+ console.log('parts', parts);
+
+ // map over the parts and wrap any backticked text with <code> tags
+ const codeParts = parts.map((part, index) => {
+ if (part.match(matchRegex)) {
+ <>
+ return <code key={index}>{part}</code>;
+ >
+ } else {
+ <>
+ return part.trim(); // remove leading/trailing whitespace from non-backticked text
+ >
+ }
+ });
+
+ return <>{codeParts}</>; // return the wrapped text
+} */}
+
+
+
+ );
+}
diff --git a/src/components/Nav/index.jsx b/src/components/Nav/index.jsx
index b517de335a..35e9dcd1f6 100644
--- a/src/components/Nav/index.jsx
+++ b/src/components/Nav/index.jsx
@@ -28,7 +28,7 @@ export default function Nav() {
onMouseLeave={() => setIsHovering(false)}
>
- {!!isLoading ? : }
+ {isLoading ? : }
diff --git a/src/components/main/TextChat.jsx b/src/components/main/TextChat.jsx
index 58b37e6d2e..0d6bf3d9b5 100644
--- a/src/components/main/TextChat.jsx
+++ b/src/components/main/TextChat.jsx
@@ -38,7 +38,7 @@ export default function TextChat({ messages }) {
};
const convoHandler = (data) => {
console.log('in convo handler');
- if (model !== 'bingai' && convo.conversationId && convo.parentMessageId === null) {
+ if (model !== 'bingai' && convo.conversationId === null && convo.parentMessageId === null) {
const { title, conversationId, id } = data;
console.log('parentMessageId is null');
console.log('title, convoId, id', title, conversationId, id);
diff --git a/src/utils/handleSubmit.js b/src/utils/handleSubmit.js
index d5e9d110da..c2467e4a6c 100644
--- a/src/utils/handleSubmit.js
+++ b/src/utils/handleSubmit.js
@@ -1,5 +1,6 @@
import { SSE } from '../../app/sse';
const endpoint = 'http://localhost:3050/ask';
+// const newLineRegex = /^\n+/;
export default function handleSubmit({
model,
@@ -40,8 +41,10 @@ export default function handleSubmit({
events.onmessage = function (e) {
const data = JSON.parse(e.data);
- const text = data.text || data.response;
+ let text = data.text || data.response;
if (data.message) {
+ // text = text.match(newLineRegex) ? text.replace(newLineRegex, '') : text;
+ // console.log(data);
messageHandler(text);
} else if (data.final) {
console.log(data);