(null)
+ const {
+ onSubmit,
+ selectedModel,
+ chatMode,
+ speechToTextLanguage,
+ stopStreamingRequest,
+ streaming: isSending,
+ webSearch,
+ setWebSearch,
+ selectedQuickPrompt,
+ textareaRef,
+ setSelectedQuickPrompt
+ } = useMessageOption()
const textAreaFocus = () => {
if (textareaRef.current) {
@@ -62,19 +74,6 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
useDynamicTextareaSize(textareaRef, form.values.message, 300)
- const {
- onSubmit,
- selectedModel,
- chatMode,
- speechToTextLanguage,
- stopStreamingRequest,
- streaming: isSending,
- webSearch,
- setWebSearch,
- selectedQuickPrompt,
- setSelectedQuickPrompt
- } = useMessageOption()
-
const { isListening, start, stop, transcript } = useSpeechRecognition()
const { sendWhenEnter, setSendWhenEnter } = useWebUI()
@@ -92,6 +91,7 @@ export const PlaygroundForm = ({ dropedFile }: Props) => {
textareaRef.current?.focus()
const interval = setTimeout(() => {
textareaRef.current?.setSelectionRange(word.start, word.end)
+ setSelectedQuickPrompt(null)
}, 100)
return () => {
clearInterval(interval)
diff --git a/src/components/Option/Prompt/index.tsx b/src/components/Option/Prompt/index.tsx
index 14aaf77..2d18bbe 100644
--- a/src/components/Option/Prompt/index.tsx
+++ b/src/components/Option/Prompt/index.tsx
@@ -224,7 +224,7 @@ export const PromptBody = () => {
@@ -268,7 +268,7 @@ export const PromptBody = () => {
diff --git a/src/components/Option/Settings/other.tsx b/src/components/Option/Settings/other.tsx
index e1acd26..6a2e717 100644
--- a/src/components/Option/Settings/other.tsx
+++ b/src/components/Option/Settings/other.tsx
@@ -5,6 +5,7 @@ import { PageAssitDatabase } from "~libs/db"
import { Select } from "antd"
import { SUPPORTED_LANGUAGES } from "~utils/supporetd-languages"
import { MoonIcon, SunIcon } from "lucide-react"
+import { SearchModeSettings } from "./search-mode"
export const SettingOther = () => {
const { clearChat, speechToTextLanguage, setSpeechToTextLanguage } =
@@ -82,6 +83,7 @@ export const SettingOther = () => {
Delete
+
)
}
diff --git a/src/components/Option/Settings/search-mode.tsx b/src/components/Option/Settings/search-mode.tsx
new file mode 100644
index 0000000..5a1ab85
--- /dev/null
+++ b/src/components/Option/Settings/search-mode.tsx
@@ -0,0 +1,37 @@
+import { useQuery, useQueryClient } from "@tanstack/react-query"
+import { Skeleton, Switch } from "antd"
+import {
+ getIsSimpleInternetSearch,
+ setIsSimpleInternetSearch
+} from "~services/ollama"
+
+export const SearchModeSettings = () => {
+ const { data, status } = useQuery({
+ queryKey: ["fetchIsSimpleInternetSearch"],
+ queryFn: () => getIsSimpleInternetSearch()
+ })
+
+ const queryClient = useQueryClient()
+
+ if (status === "pending" || status === "error") {
+ return
+ }
+
+ return (
+
+
+ Perform Simple Internet Search
+
+
+ {
+ setIsSimpleInternetSearch(checked)
+ queryClient.invalidateQueries({
+ queryKey: ["fetchIsSimpleInternetSearch"]
+ })
+ }}
+ />
+
+ )
+}
diff --git a/src/hooks/useMessageOption.tsx b/src/hooks/useMessageOption.tsx
index 07534d2..ca2446a 100644
--- a/src/hooks/useMessageOption.tsx
+++ b/src/hooks/useMessageOption.tsx
@@ -115,6 +115,7 @@ export const useMessageOption = () => {
} = useStoreMessageOption()
const navigate = useNavigate()
+ const textareaRef = React.useRef(null)
const abortControllerRef = React.useRef(null)
@@ -126,6 +127,7 @@ export const useMessageOption = () => {
setIsLoading(false)
setIsProcessing(false)
setStreaming(false)
+ textareaRef?.current?.focus()
navigate("/")
}
@@ -671,6 +673,7 @@ export const useMessageOption = () => {
selectedQuickPrompt,
setSelectedQuickPrompt,
selectedSystemPrompt,
- setSelectedSystemPrompt
+ setSelectedSystemPrompt,
+ textareaRef
}
}
diff --git a/src/services/ollama.ts b/src/services/ollama.ts
index 976a992..6c0ec14 100644
--- a/src/services/ollama.ts
+++ b/src/services/ollama.ts
@@ -288,4 +288,18 @@ export const setWebSearchFollowUpPrompt = async (prompt: string) => {
export const setWebPrompts = async (prompt: string, followUpPrompt: string) => {
await setWebSearchPrompt(prompt)
await setWebSearchFollowUpPrompt(followUpPrompt)
+}
+
+export const getIsSimpleInternetSearch = async () => {
+ const isSimpleInternetSearch = await storage.get("isSimpleInternetSearch")
+ if (!isSimpleInternetSearch || isSimpleInternetSearch.length === 0) {
+ return true
+ }
+ return isSimpleInternetSearch === "true"
+}
+
+
+
+export const setIsSimpleInternetSearch = async (isSimpleInternetSearch: boolean) => {
+ await storage.set("isSimpleInternetSearch", isSimpleInternetSearch.toString())
}
\ No newline at end of file
diff --git a/src/web/local-google.ts b/src/web/local-google.ts
index e76475a..f07cb82 100644
--- a/src/web/local-google.ts
+++ b/src/web/local-google.ts
@@ -5,7 +5,7 @@ import { MemoryVectorStore } from "langchain/vectorstores/memory"
import { cleanUrl } from "~libs/clean-url"
import { chromeRunTime } from "~libs/runtime"
import { PageAssistHtmlLoader } from "~loader/html"
-import { defaultEmbeddingChunkOverlap, defaultEmbeddingChunkSize, defaultEmbeddingModelForRag, getOllamaURL } from "~services/ollama"
+import { defaultEmbeddingChunkOverlap, defaultEmbeddingChunkSize, defaultEmbeddingModelForRag, getIsSimpleInternetSearch, getOllamaURL } from "~services/ollama"
const BLOCKED_HOSTS = [
"google.com",
@@ -40,13 +40,7 @@ export const localGoogleSearch = async (query: string) => {
(result) => {
const title = result.querySelector("h3")?.textContent
const link = result.querySelector("a")?.getAttribute("href")
- let content = result.querySelector("div[data-sncf='2']")?.textContent
- if(content === "") {
- content = result.querySelector("div[data-sncf='1']")?.textContent
- if(content === "") {
- content = result.querySelector("div[data-sncf='3']")?.textContent
- }
- }
+ const content = Array.from(result.querySelectorAll("span")).map((span) => span.textContent).join(" ")
return { title, link, content }
}
)
@@ -65,6 +59,18 @@ export const webSearch = async (query: string) => {
const results = await localGoogleSearch(query)
const searchResults = results.slice(0, TOTAL_SEARCH_RESULTS)
+ const isSimpleMode = await getIsSimpleInternetSearch()
+
+ if (isSimpleMode) {
+ await getOllamaURL()
+ return searchResults.map((result) => {
+ return {
+ url: result.link,
+ content: result.content
+ }
+ })
+ }
+
const docs: Document>[] = [];
for (const result of searchResults) {
const loader = new PageAssistHtmlLoader({