diff --git a/bun.lockb b/bun.lockb index 6ebbd7a..597e5c5 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 13645a1..4960a8d 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "bake": "bun build/build.ts" }, "dependencies": { + "@huggingface/hub": "0.19.0", "@huggingface/jinja": "0.3.1", "@inquirer/select": "2.3.10", "ace-builds": "1.36.3", diff --git a/src/games/ai/components/ace.tsx b/src/games/ai/components/ace.tsx index cd82bd4..e5af98f 100644 --- a/src/games/ai/components/ace.tsx +++ b/src/games/ai/components/ace.tsx @@ -26,6 +26,8 @@ export const Ace = ({ value, onInput }: IAceProps) => { displayIndentGuides: false, fontSize: 16, maxLines: Infinity, + tabSize: 2, + useSoftTabs: true, wrap: "free", }); return e; diff --git a/src/games/ai/components/header/header.module.css b/src/games/ai/components/header/header.module.css index ee7f15e..4e6b9d6 100644 --- a/src/games/ai/components/header/header.module.css +++ b/src/games/ai/components/header/header.module.css @@ -23,6 +23,11 @@ } } + .info { + margin: 0 8px; + line-height: 36px; + } + .buttons { display: flex; flex-direction: row; diff --git a/src/games/ai/components/header/header.tsx b/src/games/ai/components/header/header.tsx index d0c4ab1..8031bc8 100644 --- a/src/games/ai/components/header/header.tsx +++ b/src/games/ai/components/header/header.tsx @@ -11,38 +11,25 @@ import styles from './header.module.css'; import { Ace } from "../ace"; export const Header = () => { - const { getContextLength } = useContext(LLMContext); + const { modelName, modelTemplate, contextLength, promptTokens, blockConnection } = useContext(LLMContext); const { messages, connectionUrl, systemPrompt, lore, userPrompt, bannedWords, instruct, setConnectionUrl, setSystemPrompt, setLore, setUserPrompt, addSwipe, setBannedWords, setInstruct } = useContext(StateContext); - const [urlValid, setUrlValid] = useState(false); - const [urlEditing, setUrlEditing] = useState(false); const loreOpen = useBool(); const promptsOpen = useBool(); const assistantOpen = useBool(); const bannedWordsInput = useMemo(() => bannedWords.join('\n'), [bannedWords]); - - const handleFocusUrl = useCallback(() => setUrlEditing(true), []); + const urlValid = useMemo(() => contextLength > 0, [contextLength]); const handleBlurUrl = useCallback(() => { const regex = /^(?:http(s?):\/\/)?(.*?)\/?$/i const normalizedConnectionUrl = connectionUrl.replace(regex, 'http$1://$2'); - console.log({ connectionUrl, normalizedConnectionUrl }) setConnectionUrl(normalizedConnectionUrl); - setUrlEditing(false); - setUrlValid(false); - }, [connectionUrl, setConnectionUrl]); - - useEffect(() => { - if (!urlEditing) { - getContextLength().then(length => { - setUrlValid(length > 0); - }); - } - }, [connectionUrl, urlEditing]); + blockConnection.setFalse(); + }, [connectionUrl, setConnectionUrl, blockConnection]); const handleAssistantAddSwipe = useCallback((answer: string) => { const index = messages.findLastIndex(m => m.role === 'assistant'); @@ -69,17 +56,21 @@ export const Header = () => {
+
+ {promptTokens} / {contextLength} +