2024-05-11 19:32:36 +05:30
|
|
|
import { Storage } from "@plasmohq/storage"
|
|
|
|
|
const storage = new Storage()
|
|
|
|
|
|
2024-05-12 21:14:27 +05:30
|
|
|
const DEFAULT_URL_REWRITE_URL = "http://127.0.0.1:11434"
|
|
|
|
|
|
2024-05-11 19:32:36 +05:30
|
|
|
export const isUrlRewriteEnabled = async () => {
|
2024-05-12 21:14:27 +05:30
|
|
|
const enabled = await storage.get<boolean | undefined>("urlRewriteEnabled")
|
|
|
|
|
return enabled
|
2024-05-11 19:32:36 +05:30
|
|
|
}
|
|
|
|
|
export const setUrlRewriteEnabled = async (enabled: boolean) => {
|
|
|
|
|
await storage.set("urlRewriteEnabled", enabled ? "true" : "false")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const getRewriteUrl = async () => {
|
|
|
|
|
const rewriteUrl = await storage.get("rewriteUrl")
|
2024-05-12 21:14:27 +05:30
|
|
|
if (!rewriteUrl || rewriteUrl.trim() === "") {
|
|
|
|
|
return DEFAULT_URL_REWRITE_URL
|
|
|
|
|
}
|
2024-05-11 19:32:36 +05:30
|
|
|
return rewriteUrl
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const setRewriteUrl = async (url: string) => {
|
|
|
|
|
await storage.set("rewriteUrl", url)
|
|
|
|
|
}
|
2024-05-12 21:14:27 +05:30
|
|
|
|
|
|
|
|
export const getAdvancedOllamaSettings = async () => {
|
|
|
|
|
const [isEnableRewriteUrl, rewriteUrl] = await Promise.all([
|
|
|
|
|
isUrlRewriteEnabled(),
|
|
|
|
|
getRewriteUrl()
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
isEnableRewriteUrl,
|
|
|
|
|
rewriteUrl
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-05-24 21:01:10 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
export const copilotResumeLastChat = async () => {
|
|
|
|
|
return await storage.get<boolean>("copilotResumeLastChat")
|
|
|
|
|
}
|