Spaces:
Paused
Paused
Download client/modules/pubSub.ts from DatazoneAI/Smart-Search: direct link, hf CLI and curl.
- Browser
- Download file 2.06 kB
-
https://huggingface.co/spaces/DatazoneAI/Smart-Search/resolve/main/client/modules/pubSub.ts
- Command line
-
hf download hf://spaces/DatazoneAI/Smart-Search/client/modules/pubSub.ts
-
curl -L -o pubSub.ts https://huggingface.co/spaces/DatazoneAI/Smart-Search/resolve/main/client/modules/pubSub.ts
2.06 kB
| import { createPubSub } from "create-pubsub"; | |
| import { SearchResults } from "./search"; | |
| function createLocalStoragePubSub<T>(localStorageKey: string, defaultValue: T) { | |
| const localStorageValue = localStorage.getItem(localStorageKey); | |
| const localStoragePubSub = createPubSub( | |
| localStorageValue ? (JSON.parse(localStorageValue) as T) : defaultValue, | |
| ); | |
| const [, onValueChange] = localStoragePubSub; | |
| onValueChange((value) => | |
| localStorage.setItem(localStorageKey, JSON.stringify(value)), | |
| ); | |
| return localStoragePubSub; | |
| } | |
| export const disableAiResponseSettingPubSub = createLocalStoragePubSub( | |
| "disableAiResponse", | |
| false, | |
| ); | |
| export const [, , getDisableAiResponseSetting] = disableAiResponseSettingPubSub; | |
| export const summarizeLinksSettingPubSub = createLocalStoragePubSub( | |
| "summarizeLinks", | |
| false, | |
| ); | |
| export const [, , getSummarizeLinksSetting] = summarizeLinksSettingPubSub; | |
| export const useLargerModelSettingPubSub = createLocalStoragePubSub( | |
| "useLargerModel", | |
| false, | |
| ); | |
| export const [, , getUseLargerModelSetting] = useLargerModelSettingPubSub; | |
| export const disableWebGpuUsageSettingPubSub = createLocalStoragePubSub( | |
| "disableWebGpuUsage", | |
| false, | |
| ); | |
| export const [, , getDisableWebGpuUsageSetting] = | |
| disableWebGpuUsageSettingPubSub; | |
| export const querySuggestionsPubSub = createLocalStoragePubSub<string[]>( | |
| "querySuggestions", | |
| [], | |
| ); | |
| export const [updateQuerySuggestions, , getQuerySuggestions] = | |
| querySuggestionsPubSub; | |
| export const promptPubSub = createPubSub(""); | |
| export const [updatePrompt] = promptPubSub; | |
| export const responsePubSub = createPubSub(""); | |
| export const [updateResponse] = responsePubSub; | |
| export const searchResultsPubSub = createPubSub<SearchResults>([]); | |
| export const [updateSearchResults, , getSearchResults] = searchResultsPubSub; | |
| export const urlsDescriptionsPubSub = createPubSub<Record<string, string>>({}); | |
| export const [updateUrlsDescriptions, , getUrlsDescriptions] = | |
| urlsDescriptionsPubSub; | |