+
+
+
+
+
+
+
+
+
+
+
+Score: 0
++ Created by + {value.createdByName} +
+ {:else} +Official HuggingChat tool
+ {/if} ++ Start typing to search for tools... +
+ {:else} + {#each suggestions as suggestion} + + {/each} + {/if} +{@html DOMPurify.sanitize(code)}
+ + {publicConfig.PUBLIC_APP_DESCRIPTION} +
+ ++ {publicConfig.PUBLIC_APP_DISCLAIMER_MESSAGE} +
+ ++ {publicConfig.PUBLIC_APP_DESCRIPTION} +
++ {publicConfig.PUBLIC_APP_GUEST_MESSAGE} +
+ + ++ {message.args} +
+ {/if} ++ {message.args} +
+ {/if} ++ Please try again later or consider using a different model. We currently have {page.data + .models.length} models available. +
+ ++ {nTokens}{truncate ? `/${truncate}` : ""} +
++ Created by + {value.createdByName} +
+ {:else} +Official HuggingChat tool
+ {/if} ++ When enabled, the model will try to complement its answer with information queried from the + web. +
++ {assistant.description || "No description provided."} +
+ + +Examples
+ ++ {publicConfig.PUBLIC_APP_DESCRIPTION || + "Making the community's best AI chat models available to everyone."} +
+Examples
+ ++ {message.content.trim()} +
+ {:else} + + {/if} + {#if !loading && !editMode} +
+ Model:
+ {#if !assistant}
+ {#if models.find((m) => m.id === currentModel.id)}
+ {currentModel.displayName}
Generated content may be inaccurate
+ or false.
+
Drop File to add to chat
+{toolUpdate.message}
+ {:else if isMessageToolResultUpdate(toolUpdate) && toolUpdate.result.status === ToolResultStatus.Success && toolUpdate.result.display} ++ If you prefer to inject clipboard content directly in the chat, you can disable this + feature in the + settings page. +
+ {/if} + + {#if file.type === "hash"} + {#await fetch(urlNotTrailing + "/output/" + file.value).then((res) => res.text())} +{result}
+ {/await}
+ {:else}
+ {atob(file.value)}
+ {/if}
+ Text here
+ * the P tag is highest parent. + */ + const findHighestDirectParentOfReadableNode = (node: Node): HTMLElement => { + // go up the tree until the parent is no longer an only child + let parent = node.parentElement; + // if the parent is an inline tag, then go up one more level + while ( + parent && + hasValidInlineParent(parent) && + InlineTags.includes(parent?.tagName.toLowerCase()) + ) { + parent = parent.parentElement; + } + + while (parent && isOnlyChild(parent)) { + if (!hasValidParent(parent)) break; + parent = parent.parentElement; + } + + if (!parent) { + throw new Error( + "disconnected node found, this should not really be possible when traversing through the dom" + ); + } + + // if the parent is a span, code or div tag check if there is a pre tag or p tag above it + if (["span", "code", "div"].includes(parent.nodeName.toLowerCase())) { + const hasParent = possibleCodeParents.find((tag) => tag.contains(parent)) as HTMLElement; + if (hasParent) { + parent = hasParent; + } + } + + // if the parent is a li tag check if there is a ul or ol tag above it + if (parent.nodeName.toLowerCase() === "li") { + const hasParent = possibleListParents.find((tag) => tag.contains(parent)) as HTMLElement; + if (hasParent) { + parent = hasParent; + } + } + + // if the parent is a td, th, tr tag check if there is a table tag above it + if (["td", "th", "tr"].includes(parent.nodeName.toLowerCase())) { + const hasParent = possibleTableParents.find((tag) => tag.contains(parent)) as HTMLElement; + if (hasParent) { + parent = hasParent; + } + } + + return parent; + }; + const barredNodes = Array.from(document.querySelectorAll(IgnoredTagsList.join(","))); + + const doesNodePassHeuristics = (node: Node) => { + if ((node.textContent ?? "").trim().length < 10) { + return false; + } + + const parentNode = findHighestDirectParentOfReadableNode(node); + + if (parentNode && parentNode instanceof Element) { + if ( + !parentNode.checkVisibility({ + checkOpacity: true, + checkVisibilityCSS: true, + }) + ) + return false; + + const rect = parentNode.getBoundingClientRect(); + // elements that are readable usually don't have really small height or width + if (rect.width < 4 || rect.height < 4) { + return false; + } + } + + if (parentNode && parentNode instanceof Element) { + if (barredNodes.some((barredNode) => barredNode.contains(parentNode))) { + return false; + } + } + + return true; + }; + + const getAllReadableNodes = (): NodeWithRect[] => { + if (!document.body) throw new Error("Page failed to load"); + const treeWalker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, { + acceptNode(node) { + if (doesNodePassHeuristics(node)) { + return NodeFilter.FILTER_ACCEPT; + } else { + return NodeFilter.FILTER_SKIP; + } + }, + }); + + const readableNodes = []; + + while (treeWalker.nextNode()) { + readableNodes.push(treeWalker.currentNode as ReadableNode); + } + + /* + *