Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0 Prompt Templates #993

Merged
merged 19 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: add mask crud
  • Loading branch information
Yidadaa committed Apr 25, 2023
commit a7a8aad9bc584f3bac0aa27eb8d295381939995b
4 changes: 3 additions & 1 deletion app/components/chat-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export function ChatItem(props: {
<div className={styles["chat-item-count"]}>
{Locale.ChatItem.ChatItemCount(props.count)}
</div>
<div className={styles["chat-item-date"]}>{props.time}</div>
<div className={styles["chat-item-date"]}>
{new Date(props.time).toLocaleString()}
</div>
</div>
</>
)}
Expand Down
36 changes: 31 additions & 5 deletions app/components/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import ReturnIcon from "../icons/return.svg";
import CopyIcon from "../icons/copy.svg";
import DownloadIcon from "../icons/download.svg";
import LoadingIcon from "../icons/three-dots.svg";
import AddIcon from "../icons/add.svg";
import DeleteIcon from "../icons/delete.svg";
import PromptIcon from "../icons/prompt.svg";
import MaskIcon from "../icons/mask.svg";
import MaxIcon from "../icons/max.svg";
import MinIcon from "../icons/min.svg";

Expand Down Expand Up @@ -261,9 +261,11 @@ function useScrollToBottom() {
export function ChatActions(props: {
showPromptModal: () => void;
scrollToBottom: () => void;
showPromptHints: () => void;
hitBottom: boolean;
}) {
const config = useAppConfig();
const navigate = useNavigate();

// switch themes
const theme = config.theme;
Expand Down Expand Up @@ -318,6 +320,22 @@ export function ChatActions(props: {
<DarkIcon />
) : null}
</div>

<div
className={`${chatStyle["chat-input-action"]} clickable`}
onClick={props.showPromptHints}
>
<PromptIcon />
</div>

<div
className={`${chatStyle["chat-input-action"]} clickable`}
onClick={() => {
navigate(Path.Masks);
}}
>
<MaskIcon />
</div>
</div>
);
}
Expand Down Expand Up @@ -360,9 +378,9 @@ export function Chat() {
);

const onPromptSelect = (prompt: Prompt) => {
setUserInput(prompt.content);
setPromptHints([]);
inputRef.current?.focus();
setUserInput(prompt.content);
};

// auto grow input
Expand Down Expand Up @@ -723,6 +741,10 @@ export function Chat() {
showPromptModal={() => setShowPromptModal(true)}
scrollToBottom={scrollToBottom}
hitBottom={hitBottom}
showPromptHints={() => {
inputRef.current?.focus();
onSearch("");
}}
/>
<div className={styles["chat-input-panel-inner"]}>
<textarea
Expand All @@ -734,8 +756,12 @@ export function Chat() {
onKeyDown={onInputKeyDown}
onFocus={() => setAutoScroll(true)}
onBlur={() => {
setAutoScroll(false);
setTimeout(() => setPromptHints([]), 500);
setTimeout(() => {
if (document.activeElement !== inputRef.current) {
setAutoScroll(false);
setPromptHints([]);
}
}, 100);
}}
autoFocus
rows={inputRows}
Expand Down
6 changes: 3 additions & 3 deletions app/components/emoji.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ export function Avatar(props: { model?: ModelType; avatar?: string }) {
return (
<div className="no-dark">
{props.model?.startsWith("gpt-4") ? (
<BlackBotIcon className="user-avtar" />
<BlackBotIcon className="user-avatar" />
) : (
<BotIcon className="user-avtar" />
<BotIcon className="user-avatar" />
)}
</div>
);
}

return (
<div className="user-avtar">
<div className="user-avatar">
{props.avatar && <EmojiAvatar avatar={props.avatar} />}
</div>
);
Expand Down
76 changes: 71 additions & 5 deletions app/components/mask.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
@import "../styles/animation.scss";

@keyframes search-in {
from {
opacity: 0;
transform: translateY(5vh) scaleX(0.5);
}
to {
opacity: 1;
transform: translateY(0) scaleX(1);
}
}

.mask-page {
height: 100%;
display: flex;
Expand All @@ -11,23 +24,76 @@
width: 100%;
max-width: 100%;
margin-bottom: 20px;
animation: search-in ease 0.3s;
}

.mask-item {
.mask-icon {
display: flex;
justify-content: space-between;
padding: 20px;
border: var(--border-in-light);
animation: slide-in ease 0.3s;

&:not(:last-child) {
border-bottom: 0;
}

&:first-child {
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}

&:last-child {
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}

.mask-header {
display: flex;
align-items: center;
justify-content: center;
border: var(--border-in-light);
border-radius: 10px;
padding: 6px;

.mask-icon {
display: flex;
align-items: center;
justify-content: center;
margin-right: 10px;
}

.mask-title {
.mask-name {
font-size: 14px;
font-weight: bold;
}
.mask-info {
font-size: 12px;
}
}
}

.mask-actions {
display: flex;
flex-wrap: nowrap;
transition: all ease 0.3s;
}

@media screen and (max-width: 600px) {
display: flex;
flex-direction: column;
padding-bottom: 10px;
border-radius: 10px;
margin-bottom: 20px;
box-shadow: var(--card-shadow);

&:not(:last-child) {
border-bottom: var(--border-in-light);
}

.mask-actions {
width: 100%;
justify-content: space-between;
padding-top: 10px;
}
}
}
}
}
Loading