Skip to content
This repository has been archived by the owner on Sep 23, 2024. It is now read-only.

default max attached #115

Merged
merged 3 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 10 additions & 0 deletions src/data-structure/client-option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,14 @@ const pickOne = <V extends string | number, T>(current: V | undefined, pool: T[]
}
}
return undefined
}

export const modelInUse = (llmOption: LLMOption): string | undefined => {
if (llmOption.gemini.enabled) {
return llmOption.gemini.model
} else if (llmOption.chatGPT.enabled) {
return llmOption.chatGPT.model
} else {
return undefined
}
}
37 changes: 37 additions & 0 deletions src/home/chat-window/compnent/dot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, {useState} from "react";
import {cx} from "../../../util/util.tsx";
import {capitalize} from "lodash";

interface PopOverDotProps {
text: string
popOverText: string
fixedRound?: boolean
activated?: boolean
action?: () => void
}

export const PopOverDot: React.FC<PopOverDotProps> = ({text, popOverText, fixedRound = true, activated, action}) => {
const [hovering, setHovering] = useState(false)

return <div onMouseOver={() => setHovering(true)}
onMouseLeave={() => setHovering(false)}
onClick={action}
className="relative flex transition-all duration-100">
<p className={cx("flex justify-center items-center select-none text-[11px] rounded-full h-5",
"duration-100",
fixedRound ? "w-5 cursor-pointer" : "px-2 text-sm pb-0.5",
activated ? "bg-blue-600 bg-opacity-80 text-neutral-100" : "text-violet-100 bg-black/[0.3]",
action && "hover:scale-125 hover:backdrop-blur",
!activated && action && "hover:bg-black/[0.5]"
)}>
{text}
</p>
<div className={cx("absolute bg-neutral-800/[0.8] rounded-full px-4 py-1 -top-8",
"left-1/3 -translate-x-1/3 transform whitespace-nowrap",
"text-sm text-neutral-200 backdrop-blur-lg",
hovering ? "block" : "hidden"
)}>
{capitalize(popOverText)}
</div>
</div>
}
2 changes: 1 addition & 1 deletion src/home/chat-window/prompt/prompt-editor-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const Dot: React.FC<RoleDotProps> = ({messageProxy, targetRole}) => {
bg,
)}>
{hovering &&
<div className=" bg-neutral-200/[0.8] rounded-full px-2 fixed -top-6 left-1/2 -translate-x-1/2
<div className="bg-neutral-200/[0.8] rounded-full px-2 fixed -top-6 left-1/2 -translate-x-1/2
transform text-sm text-neutral-800">
{capitalize(targetRole)}
</div>
Expand Down
1 change: 0 additions & 1 deletion src/home/chat-window/prompt/prompt-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const PromptList: React.FC<Props> = ({chatProxy}) => {

let ps: Prompt[]
if (keywords.length === 0) {
// eslint-disable-next-line valtio/state-snapshot-rule
ps = promptState.prompts
} else {
ps = promptState.prompts.filter(p => {
Expand Down
43 changes: 21 additions & 22 deletions src/home/chat-window/text-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {cx} from "../../util/util.tsx"
import {searchLinuxTerminalHistoryPotision} from "../../data-structure/message.tsx";
import {bestModel, matchKeyCombo} from "../../state/shortcuts.ts";
import IosSpinner from "../../assets/svg/ios-spinner.svg?react"
import {modelInUse} from "../../data-structure/client-option.tsx";
import {PopOverDot} from "./compnent/dot.tsx";

type Props = {
chatProxy: Chat
Expand All @@ -29,6 +31,7 @@ const TextArea: React.FC<Props> = ({chatProxy}) => {
const [isComposing, setIsComposing] = useState(false)
const [linuxTerminalHistoryIndex, setLinuxTerminalHistoryIndex] = useState(-1)

const currentModel = modelInUse(option.llm)
const stopSpacePropagation = useCallback((event: React.KeyboardEvent<HTMLTextAreaElement>) => {
if (event.key === ' ') {
event.stopPropagation()
Expand Down Expand Up @@ -170,29 +173,25 @@ const TextArea: React.FC<Props> = ({chatProxy}) => {


return (<div className="flex flex-col items-center w-full mt-auto bottom-0 max-w-4xl">
<div className="relative flex items-center justify-center w-full">
<div className="relative flex items-center justify-center w-full z-10">
<div className="absolute left-2 flex items-center gap-1.5">
<p className={cx("flex text-sm rounded-full w-5 h-5 items-center cursor-pointer",
"justify-center select-none",
option.llm.maxAttached > 0 ? "bg-blue-600/[0.8] text-neutral-100" : "text-violet-100 bg-white bg-opacity-20"
)}
onClick={() => {
if (chatProxy.option.llm.maxAttached > 0) {
chatProxy.option.llm.maxAttached = 0
} else {
chatProxy.option.llm.maxAttached = 4
}
}
}
>
{option.llm.maxAttached === Number.MAX_SAFE_INTEGER ? '∞' : option.llm.maxAttached}
</p>
<p className={cx("flex text-[11px] rounded-full w-5 h-5 items-center",
" cursor-pointer justify-center select-none",
showMarkdown ? "bg-blue-600/[0.8] text-neutral-100" : "text-violet-100 bg-white bg-opacity-20"
)}
onClick={() => appState.pref.showMarkdown = !appState.pref.showMarkdown}
>MD </p>
<PopOverDot
text={option.llm.maxAttached === Number.MAX_SAFE_INTEGER ? '∞' : option.llm.maxAttached.toString()}
popOverText="Number of attached messages"
activated={option.llm.maxAttached > 0}
action={() => {
if (chatProxy.option.llm.maxAttached > 0) {
chatProxy.option.llm.maxAttached = 0
} else {
chatProxy.option.llm.maxAttached = 2
}
}}
/>

<PopOverDot text="MD" popOverText="Display messages in markdown style" activated={showMarkdown}
action={() => appState.pref.showMarkdown = !appState.pref.showMarkdown}/>

{currentModel && <PopOverDot text={currentModel} fixedRound={false} popOverText="Lanuage model in use"/>}
<TextPendingIcon/>
</div>
<button
Expand Down
2 changes: 1 addition & 1 deletion src/home/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function Home() {
<>
<div
className="flex h-screen w-screen items-center justify-center gap-2 overflow-hidden p-3 lg:gap-5">
<div className="hidden sm:block h-full min-w-80 max-w-80">
<div className="hidden sm:block h-full min-w-60 max-w-80 w-[35%]">
<Panel/>
</div>
<ChatWindow/>
Expand Down
6 changes: 4 additions & 2 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default {
},
maxWidth: {
'11': '2.75rem',
'60': '20rem',
'40': '10rem',
'60': '15rem',
'80': '20rem',
'86': '22rem',
'96': '24rem',
Expand All @@ -38,7 +39,8 @@ export default {
minWidth: {
'11': '2.75rem',
'12': '3rem',
'60': '20rem',
'40': '10rem',
'60': '15rem',
'80': '20rem',
'86': '22rem',
'96': '24rem',
Expand Down
Loading