feat: Add Chrome AI support

This commit is contained in:
n4ze3m
2024-06-30 20:45:06 +05:30
parent 52f9a2953a
commit d41ec2a89c
36 changed files with 463 additions and 47 deletions

View File

@@ -6,11 +6,17 @@ import "property-information"
import React from "react"
import { CodeBlock } from "./CodeBlock"
export default function Markdown({ message }: { message: string }) {
export default function Markdown({
message,
className = "prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 dark:prose-dark"
}: {
message: string
className?: string
}) {
return (
<React.Fragment>
<ReactMarkdown
className="prose break-words dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 dark:prose-dark"
className={className}
remarkPlugins={[remarkGfm, remarkMath]}
components={{
code({ node, inline, className, children, ...props }) {

View File

@@ -3,9 +3,9 @@ import { Dropdown, Tooltip } from "antd"
import { LucideBrain } from "lucide-react"
import React from "react"
import { useTranslation } from "react-i18next"
import { OllamaIcon } from "../Icons/Ollama"
import { fetchChatModels } from "@/services/ollama"
import { useMessage } from "@/hooks/useMessage"
import { ProviderIcons } from "./ProviderIcon"
export const ModelSelect: React.FC = () => {
const { t } = useTranslation("common")
@@ -29,7 +29,10 @@ export const ModelSelect: React.FC = () => {
label: (
<div className="w-52 gap-2 text-lg truncate inline-flex line-clamp-3 items-center dark:border-gray-700">
<div>
<OllamaIcon className="h-6 w-6 text-gray-400" />
<ProviderIcons
provider={d?.provider}
className="h-6 w-6 text-gray-400"
/>
</div>
{d.name}
</div>
@@ -53,7 +56,7 @@ export const ModelSelect: React.FC = () => {
trigger={["click"]}>
<Tooltip title={t("selectAModel")}>
<button type="button" className="dark:text-gray-300">
<LucideBrain className="h-5 w-5"/>
<LucideBrain className="h-5 w-5" />
</button>
</Tooltip>
</Dropdown>

View File

@@ -64,7 +64,11 @@ export const PlaygroundMessage = (props: Props) => {
</div>
<div className="flex w-[calc(100%-50px)] flex-col gap-3 lg:w-[calc(100%-115px)]">
<span className="text-xs font-bold text-gray-800 dark:text-white">
{props.isBot ? props.name : "You"}
{props.isBot
? props.name === "chrome::gemini-nano::page-assist"
? "Gemini Nano"
: props.name
: "You"}
</span>
{props.isBot &&

View File

@@ -0,0 +1,17 @@
import { ChromeIcon } from "lucide-react"
import { OllamaIcon } from "../Icons/Ollama"
export const ProviderIcons = ({
provider,
className
}: {
provider: string
className?: string
}) => {
switch (provider) {
case "chrome":
return <ChromeIcon className={className} />
default:
return <OllamaIcon className={className} />
}
}