mirror of
https://github.com/DustinBrett/daedalOS.git
synced 2026-01-15 12:15:02 +00:00
AI tweaks
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useTheme } from "styled-components";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import {
|
||||
escapeHtml,
|
||||
formatWebLlmProgress,
|
||||
responseTweaks,
|
||||
speakMessage,
|
||||
@@ -112,7 +113,7 @@ const AIChat: FC<AIChatProps> = ({ toggleAI }) => {
|
||||
);
|
||||
const addUserPrompt = useCallback(() => {
|
||||
if (promptText) {
|
||||
addMessage(promptText, "user");
|
||||
addMessage(escapeHtml(promptText), "user");
|
||||
(textAreaRef.current as HTMLTextAreaElement).value = "";
|
||||
setPromptText("");
|
||||
}
|
||||
@@ -438,15 +439,18 @@ const AIChat: FC<AIChatProps> = ({ toggleAI }) => {
|
||||
<button
|
||||
className={clsx({
|
||||
thinking: true,
|
||||
"thinking-responding": responding,
|
||||
"thinking-responding":
|
||||
responding && index === conversation.length - 1,
|
||||
})}
|
||||
type="button"
|
||||
{...(!responding &&
|
||||
{...((!responding || index < conversation.length - 1) &&
|
||||
text.includes("</think>") && {
|
||||
onClick: () => toggleThought(index),
|
||||
})}
|
||||
>
|
||||
{text.includes("</think>") || !responding
|
||||
{text.includes("</think>") ||
|
||||
!responding ||
|
||||
index < conversation.length - 1
|
||||
? "Thoughts"
|
||||
: "Thinking..."}
|
||||
</button>
|
||||
|
||||
@@ -145,6 +145,29 @@ const StyledAIChat = styled(motion.section)<StyledAIChatProps>`
|
||||
}
|
||||
}
|
||||
|
||||
.ai {
|
||||
/* stylelint-disable-next-line selector-type-no-unknown */
|
||||
think {
|
||||
border-left: 2px solid rgb(78, 78, 86);
|
||||
color: rgb(166, 166, 166);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 13px;
|
||||
gap: 10px;
|
||||
margin-left: 5px;
|
||||
margin-top: 12px;
|
||||
padding-left: 10px;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.message.hide-think {
|
||||
/* stylelint-disable-next-line selector-type-no-unknown */
|
||||
think {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.avatar {
|
||||
display: flex;
|
||||
font-size: 15px;
|
||||
@@ -192,27 +215,6 @@ const StyledAIChat = styled(motion.section)<StyledAIChatProps>`
|
||||
padding: 12px;
|
||||
}
|
||||
|
||||
/* stylelint-disable-next-line selector-type-no-unknown */
|
||||
think {
|
||||
border-left: 2px solid rgb(78, 78, 86);
|
||||
color: rgb(166, 166, 166);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-size: 13px;
|
||||
gap: 10px;
|
||||
margin-left: 5px;
|
||||
margin-top: 12px;
|
||||
padding-left: 10px;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
&.hide-think {
|
||||
/* stylelint-disable-next-line selector-type-no-unknown */
|
||||
think {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
code {
|
||||
white-space: pre-wrap;
|
||||
|
||||
|
||||
@@ -25,15 +25,15 @@ const CONVO_STYLE_TEMPS: Record<
|
||||
AILanguageModelCreateOptionsWithSystemPrompt
|
||||
> = {
|
||||
balanced: {
|
||||
temperature: 0.5,
|
||||
temperature: 0.6,
|
||||
topK: 3,
|
||||
},
|
||||
creative: {
|
||||
temperature: 0.8,
|
||||
temperature: 0.7,
|
||||
topK: 5,
|
||||
},
|
||||
precise: {
|
||||
temperature: 0.2,
|
||||
temperature: 0.5,
|
||||
topK: 2,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -63,3 +63,11 @@ export const responseTweaks = (text: string): string => {
|
||||
|
||||
return newText;
|
||||
};
|
||||
|
||||
export const escapeHtml = (unSafeHtml: string): string =>
|
||||
unSafeHtml
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
|
||||
Reference in New Issue
Block a user