Skip to content

Commit 8d5ae26

Browse files
authored
Merge pull request #276 from n4ze3m/next
v1.3.9
2 parents 216b21d + 93879fe commit 8d5ae26

File tree

15 files changed

+316
-34
lines changed

15 files changed

+316
-34
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ bun build:firefox
8282

8383
Once the extension is installed, you can open the sidebar via context menu or keyboard shortcut.
8484

85-
Default Keyboard Shortcut: `Ctrl+Shift+P`
85+
Default Keyboard Shortcut: `Ctrl+Shift+Y`
8686

8787
### Web UI
8888

src/assets/locale/en/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@
7474
"braveApi": {
7575
"label": "Brave API Key",
7676
"placeholder": "Enter your Brave API key"
77+
},
78+
"googleDomain": {
79+
"label": "Google Domain"
7780
}
7881
},
7982
"system": {

src/components/Common/Playground/Message.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const PlaygroundMessage = (props: Props) => {
6868
)}
6969
</div>
7070
</div>
71-
<div className="flex w-[calc(100%-50px)] flex-col gap-3 lg:w-[calc(100%-115px)]">
71+
<div className="flex w-[calc(100%-50px)] flex-col gap-2 lg:w-[calc(100%-115px)]">
7272
<span className="text-xs font-bold text-gray-800 dark:text-white">
7373
{props.isBot
7474
? props.name === "chrome::gemini-nano::page-assist"
@@ -212,7 +212,9 @@ export const PlaygroundMessage = (props: Props) => {
212212
{props.generationInfo && (
213213
<Popover
214214
content={
215-
<GenerationInfo generationInfo={props.generationInfo} />
215+
<GenerationInfo
216+
generationInfo={props.generationInfo}
217+
/>
216218
}
217219
title={t("generationInfo")}>
218220
<button className="flex items-center justify-center w-6 h-6 rounded-full bg-gray-100 dark:bg-gray-800 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500">

src/components/Common/ProviderIcon.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { OpenAiIcon } from "../Icons/OpenAI"
77
import { TogtherMonoIcon } from "../Icons/Togther"
88
import { OpenRouterIcon } from "../Icons/OpenRouter"
99
import { LLamaFile } from "../Icons/Llamafile"
10+
import { GeminiIcon } from "../Icons/GeminiIcon"
1011

1112
export const ProviderIcons = ({
1213
provider,
@@ -34,6 +35,8 @@ export const ProviderIcons = ({
3435
return <OpenRouterIcon className={className} />
3536
case "llamafile":
3637
return <LLamaFile className={className} />
38+
case "gemini":
39+
return <GeminiIcon className={className} />
3740
default:
3841
return <OllamaIcon className={className} />
3942
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from "react"
2+
3+
export const GeminiIcon = React.forwardRef<
4+
SVGSVGElement,
5+
React.SVGProps<SVGSVGElement>
6+
>((props, ref) => {
7+
return (
8+
<svg
9+
fill="currentColor"
10+
fillRule="evenodd"
11+
ref={ref}
12+
viewBox="0 0 24 24"
13+
xmlns="http://www.w3.org/2000/svg"
14+
{...props}>
15+
<path d="M12 24A14.304 14.304 0 000 12 14.304 14.304 0 0012 0a14.305 14.305 0 0012 12 14.305 14.305 0 00-12 12"></path>
16+
</svg>
17+
)
18+
})

src/components/Option/Playground/PlaygroundChat.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const PlaygroundChat = () => {
5858
/>
5959
))}
6060
{messages.length > 0 && (
61-
<div className="w-full h-16 flex-shrink-0"></div>
61+
<div className="w-full h-10 flex-shrink-0"></div>
6262
)}
6363
</div>
6464
{!isAtBottom && (

src/components/Option/Playground/PlaygroundForm.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
192192

193193
return (
194194
<div
195-
className={`px-3 pt-3 md:px-4 md:pt-4 bg-gray-100 dark:bg-[#262626] border rounded-t-xl dark:border-gray-600
195+
className={`px-3 pt-3 bg-gray-100 dark:bg-[#262626] border rounded-t-xl dark:border-gray-600
196196
${temporaryChat && "!bg-gray-300 dark:!bg-black "}
197197
`}>
198198
<div
@@ -217,9 +217,10 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
217217
</div>
218218
</div>
219219
<div>
220-
<div className={`flex rounded-t-xl bg-white dark:bg-transparent ${
221-
temporaryChat && "!bg-gray-300 dark:!bg-black"
222-
}`}>
220+
<div
221+
className={`flex rounded-t-xl bg-white dark:bg-transparent ${
222+
temporaryChat && "!bg-gray-300 dark:!bg-black"
223+
}`}>
223224
<form
224225
onSubmit={form.onSubmit(async (value) => {
225226
stopListening()
@@ -275,17 +276,17 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
275276
className="px-2 py-2 w-full resize-none bg-transparent focus-within:outline-none focus:ring-0 focus-visible:ring-0 ring-0 dark:ring-0 border-0 dark:text-gray-100"
276277
onPaste={handlePaste}
277278
rows={1}
278-
style={{ minHeight: "40px" }}
279+
style={{ minHeight: "30px" }}
279280
tabIndex={0}
280281
placeholder={t("form.textarea.placeholder")}
281282
{...form.getInputProps("message")}
282283
/>
283-
<div className="mt-4 flex justify-between items-center">
284+
<div className="mt-2 flex justify-between items-center">
284285
<div className="flex">
285286
{!selectedKnowledge && (
286287
<Tooltip title={t("tooltip.searchInternet")}>
287288
<div className="inline-flex items-center gap-2">
288-
<PiGlobe className="h-5 w-5 dark:text-gray-300" />
289+
<PiGlobe className={`h-5 w-5 dark:text-gray-300 `} />
289290
<Switch
290291
value={webSearch}
291292
onChange={(e) => setWebSearch(e)}

src/components/Option/Settings/search-mode.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { SaveButton } from "@/components/Common/SaveButton"
22
import { getSearchSettings, setSearchSettings } from "@/services/search"
3+
import { ALL_GOOGLE_DOMAINS } from "@/utils/google-domains"
34
import { SUPPORTED_SERACH_PROVIDERS } from "@/utils/search-provider"
45
import { useForm } from "@mantine/form"
56
import { useQuery } from "@tanstack/react-query"
@@ -18,6 +19,7 @@ export const SearchModeSettings = () => {
1819
searxngURL: "",
1920
searxngJSONMode: false,
2021
braveApiKey: "",
22+
googleDomain: ""
2123
}
2224
})
2325

@@ -82,6 +84,32 @@ export const SearchModeSettings = () => {
8284
</div>
8385
</>
8486
)}
87+
{form.values.searchProvider === "google" && (
88+
<>
89+
<div className="flex sm:flex-row flex-col space-y-4 sm:space-y-0 sm:justify-between">
90+
<span className="text-gray-700 dark:text-neutral-50">
91+
{t("generalSettings.webSearch.googleDomain.label")}
92+
</span>
93+
<div>
94+
<Select
95+
showSearch
96+
className="w-full mt-4 sm:mt-0 sm:w-[200px]"
97+
options={ALL_GOOGLE_DOMAINS.map((e) => ({
98+
label: e,
99+
value: e
100+
}))}
101+
filterOption={(input, option) =>
102+
option!.label.toLowerCase().indexOf(input.toLowerCase()) >=
103+
0 ||
104+
option!.value.toLowerCase().indexOf(input.toLowerCase()) >=
105+
0
106+
}
107+
{...form.getInputProps("googleDomain")}
108+
/>
109+
</div>
110+
</div>
111+
</>
112+
)}
85113
{form.values.searchProvider === "brave-api" && (
86114
<>
87115
<div className="flex sm:flex-row flex-col space-y-4 sm:space-y-0 sm:justify-between">

src/models/ChatGoogleAI.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ChatOpenAI } from "@langchain/openai";
2+
3+
export class ChatGoogleAI extends ChatOpenAI {
4+
5+
frequencyPenalty: number = undefined;
6+
presencePenalty: number = undefined;
7+
8+
static lc_name() {
9+
return "ChatGoogleAI";
10+
}
11+
}

src/models/index.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ChatOllama } from "./ChatOllama"
44
import { getOpenAIConfigById } from "@/db/openai"
55
import { ChatOpenAI } from "@langchain/openai"
66
import { urlRewriteRuntime } from "@/libs/runtime"
7+
import { ChatGoogleAI } from "./ChatGoogleAI"
78

89
export const pageAssistModel = async ({
910
model,
@@ -30,18 +31,15 @@ export const pageAssistModel = async ({
3031
numPredict?: number
3132
useMMap?: boolean
3233
}) => {
33-
3434
if (model === "chrome::gemini-nano::page-assist") {
3535
return new ChatChromeAI({
3636
temperature,
37-
topK,
37+
topK
3838
})
3939
}
4040

41-
4241
const isCustom = isCustomModel(model)
4342

44-
4543
if (isCustom) {
4644
const modelInfo = await getModelInfo(model)
4745
const providerInfo = await getOpenAIConfigById(modelInfo.provider_id)
@@ -50,6 +48,20 @@ export const pageAssistModel = async ({
5048
await urlRewriteRuntime(providerInfo.baseUrl || "")
5149
}
5250

51+
if (providerInfo.provider === "gemini") {
52+
return new ChatGoogleAI({
53+
modelName: modelInfo.model_id,
54+
openAIApiKey: providerInfo.apiKey || "temp",
55+
temperature,
56+
topP,
57+
maxTokens: numPredict,
58+
configuration: {
59+
apiKey: providerInfo.apiKey || "temp",
60+
baseURL: providerInfo.baseUrl || ""
61+
}
62+
}) as any
63+
}
64+
5365
return new ChatOpenAI({
5466
modelName: modelInfo.model_id,
5567
openAIApiKey: providerInfo.apiKey || "temp",
@@ -58,13 +70,11 @@ export const pageAssistModel = async ({
5870
maxTokens: numPredict,
5971
configuration: {
6072
apiKey: providerInfo.apiKey || "temp",
61-
baseURL: providerInfo.baseUrl || "",
62-
},
73+
baseURL: providerInfo.baseUrl || ""
74+
}
6375
}) as any
6476
}
6577

66-
67-
6878
return new ChatOllama({
6979
baseUrl,
7080
keepAlive,
@@ -76,9 +86,6 @@ export const pageAssistModel = async ({
7686
model,
7787
numGpu,
7888
numPredict,
79-
useMMap,
89+
useMMap
8090
})
81-
82-
83-
8491
}

0 commit comments

Comments
 (0)