- {t("generalSettings.settings.advanced.urlRewriteEnabled.label")}
+ {t("ollamaSettings.settings.advanced.rewriteUrl.label")}
setRewriteUrl(e.target.value)}
/>
diff --git a/src/components/Option/Playground/PlaygroundEmpty.tsx b/src/components/Option/Playground/PlaygroundEmpty.tsx
index 6636605..7fb94ab 100644
--- a/src/components/Option/Playground/PlaygroundEmpty.tsx
+++ b/src/components/Option/Playground/PlaygroundEmpty.tsx
@@ -1,7 +1,8 @@
+import { cleanUrl } from "@/libs/clean-url"
import { useQuery } from "@tanstack/react-query"
import { RotateCcw } from "lucide-react"
import { useEffect, useState } from "react"
-import { useTranslation } from "react-i18next"
+import { Trans, useTranslation } from "react-i18next"
import {
getOllamaURL,
isOllamaRunning,
@@ -79,6 +80,23 @@ export const PlaygroundEmpty = () => {
{t("common:retry")}
+
+ {ollamaURL &&
+ cleanUrl(ollamaURL) !== "http://127.0.0.1:11434" && (
+
+
+ )
+ }}
+ />
+
+ )}
)
) : null}
diff --git a/src/components/Option/Settings/ollama.tsx b/src/components/Option/Settings/ollama.tsx
index 534b8a0..8e24a42 100644
--- a/src/components/Option/Settings/ollama.tsx
+++ b/src/components/Option/Settings/ollama.tsx
@@ -12,7 +12,7 @@ import {
setOllamaURL as saveOllamaURL
} from "~/services/ollama"
import { SettingPrompt } from "./prompt"
-import { useTranslation } from "react-i18next"
+import { Trans, useTranslation } from "react-i18next"
import { useStorage } from "@plasmohq/storage/hook"
import { AdvanceOllamaSettings } from "@/components/Common/AdvanceOllamaSettings"
@@ -87,9 +87,24 @@ export const SettingsOllama = () => {
{
key: "1",
label: (
-
- {t("ollamaSettings.settings.advanced.label")}
-
+
+
+ {t("ollamaSettings.settings.advanced.label")}
+
+
+
+ )
+ }}
+ />
+
+
),
children:
}
diff --git a/src/components/Sidepanel/Chat/empty.tsx b/src/components/Sidepanel/Chat/empty.tsx
index 499e320..000d4e3 100644
--- a/src/components/Sidepanel/Chat/empty.tsx
+++ b/src/components/Sidepanel/Chat/empty.tsx
@@ -1,8 +1,9 @@
+import { cleanUrl } from "@/libs/clean-url"
import { useQuery, useQueryClient } from "@tanstack/react-query"
import { Select } from "antd"
import { RotateCcw } from "lucide-react"
import { useEffect, useState } from "react"
-import { useTranslation } from "react-i18next"
+import { Trans, useTranslation } from "react-i18next"
import { useMessage } from "~/hooks/useMessage"
import {
getAllModels,
@@ -91,6 +92,22 @@ export const EmptySidePanel = () => {
{t("common:retry")}
+ {ollamaURL &&
+ cleanUrl(ollamaURL) !== "http://127.0.0.1:11434" && (
+
+
+ )
+ }}
+ />
+
+ )}
)
) : null}
diff --git a/src/libs/runtime.ts b/src/libs/runtime.ts
index cf4aa96..dc54c4a 100644
--- a/src/libs/runtime.ts
+++ b/src/libs/runtime.ts
@@ -1,13 +1,16 @@
import { getAdvancedOllamaSettings } from "@/services/app"
-export const urlRewriteRuntime = async function (domain: string) {
+export const urlRewriteRuntime = async function (
+ domain: string,
+ type = "ollama"
+) {
if (browser.runtime && browser.runtime.id) {
const { isEnableRewriteUrl, rewriteUrl } = await getAdvancedOllamaSettings()
if (import.meta.env.BROWSER === "chrome") {
const url = new URL(domain)
const domains = [url.hostname]
let origin = `${url.protocol}//${url.hostname}`
- if (!isEnableRewriteUrl && rewriteUrl) {
+ if (isEnableRewriteUrl && rewriteUrl && type === "ollama") {
origin = rewriteUrl
}
const rules = [
@@ -42,7 +45,7 @@ export const urlRewriteRuntime = async function (domain: string) {
browser.webRequest.onBeforeSendHeaders.addListener(
(details) => {
let origin = `${url.protocol}//${url.hostname}`
- if (!isEnableRewriteUrl && rewriteUrl) {
+ if (isEnableRewriteUrl && rewriteUrl && type === "ollama") {
origin = rewriteUrl
}
for (let i = 0; i < details.requestHeaders.length; i++) {
diff --git a/src/loader/html.ts b/src/loader/html.ts
index 37a07f1..786c60e 100644
--- a/src/loader/html.ts
+++ b/src/loader/html.ts
@@ -102,7 +102,7 @@ export class PageAssistHtmlLoader
}
]
}
- await urlRewriteRuntime(this.url)
+ await urlRewriteRuntime(this.url, "web")
const fetchHTML = await fetch(this.url)
let html = await fetchHTML.text()
@@ -111,11 +111,6 @@ export class PageAssistHtmlLoader
html = parseWikipedia(await fetchHTML.text())
}
- // else if (isTwitter(this.url)) {
- // console.log("Twitter URL detected")
- // html = parseTweet(await fetchHTML.text(), this.url)
- // }
-
const htmlCompiler = compile({
wordwrap: false,
selectors: [
diff --git a/src/services/app.ts b/src/services/app.ts
index 3b0f671..8f0cc66 100644
--- a/src/services/app.ts
+++ b/src/services/app.ts
@@ -5,9 +5,6 @@ const DEFAULT_URL_REWRITE_URL = "http://127.0.0.1:11434"
export const isUrlRewriteEnabled = async () => {
const enabled = await storage.get