diff --git a/app/components/emoji.tsx b/app/components/emoji.tsx index a2a50320d..b24349307 100644 --- a/app/components/emoji.tsx +++ b/app/components/emoji.tsx @@ -13,7 +13,7 @@ export function getEmojiUrl(unified: string, style: EmojiStyle) { // Whoever owns this Content Delivery Network (CDN), I am using your CDN to serve emojis // Old CDN broken, so I had to switch to this one // Author: https://github.com/H0llyW00dzZ - return `https://cdn.jsdelivr.net/npm/emoji-datasource-apple/img/${style}/64/${unified}.png`; + return `https://fastly.jsdelivr.net/npm/emoji-datasource-apple/img/${style}/64/${unified}.png`; } export function AvatarPicker(props: { diff --git a/app/components/settings.tsx b/app/components/settings.tsx index 42d88f35e..4ca5656cd 100644 --- a/app/components/settings.tsx +++ b/app/components/settings.tsx @@ -268,7 +268,7 @@ function CheckButton() { const syncStore = useSyncStore(); const couldCheck = useMemo(() => { - return syncStore.coundSync(); + return syncStore.cloudSync(); }, [syncStore]); const [checkState, setCheckState] = useState< @@ -472,7 +472,7 @@ function SyncItems() { const promptStore = usePromptStore(); const maskStore = useMaskStore(); const couldSync = useMemo(() => { - return syncStore.coundSync(); + return syncStore.cloudSync(); }, [syncStore]); const [showSyncConfigModal, setShowSyncConfigModal] = useState(false); diff --git a/app/constant.ts b/app/constant.ts index f7adf0fea..d57cf2476 100644 --- a/app/constant.ts +++ b/app/constant.ts @@ -99,7 +99,7 @@ export const Google = { export const DEFAULT_INPUT_TEMPLATE = `{{input}}`; // input / time / model / lang export const DEFAULT_SYSTEM_TEMPLATE = ` -You are ChatGPT, a large language model trained by OpenAI. +You are ChatGPT, a large language model trained by {{ServiceProvider}}. Knowledge cutoff: {{cutoff}} Current model: {{model}} Current time: {{time}} @@ -115,7 +115,9 @@ export const KnowledgeCutOffDate: Record = { "gpt-4-1106-preview": "2023-04", "gpt-4-0125-preview": "2023-04", "gpt-4-vision-preview": "2023-04", - "gemini-pro": "2021-04", + // After improvements, + // it's now easier to add "KnowledgeCutOffDate" instead of stupid hardcoding it, as was done previously. + "gemini-pro": "2023-12", }; export const DEFAULT_MODELS = [ diff --git a/app/store/chat.ts b/app/store/chat.ts index 504e3f21f..4c5d02ce2 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -6,6 +6,7 @@ import { ModelConfig, ModelType, useAppConfig } from "./config"; import { createEmptyMask, Mask } from "./mask"; import { DEFAULT_INPUT_TEMPLATE, + DEFAULT_MODELS, DEFAULT_SYSTEM_TEMPLATE, KnowledgeCutOffDate, ModelProvider, @@ -99,10 +100,20 @@ function countMessages(msgs: ChatMessage[]) { } function fillTemplateWith(input: string, modelConfig: ModelConfig) { - let cutoff = + const cutoff = KnowledgeCutOffDate[modelConfig.model] ?? KnowledgeCutOffDate.default; + // Find the model in the DEFAULT_MODELS array that matches the modelConfig.model + const modelInfo = DEFAULT_MODELS.find((m) => m.name === modelConfig.model); + if (!modelInfo) { + throw new Error( + `Model ${modelConfig.model} not found in DEFAULT_MODELS array.`, + ); + } + // Directly use the providerName from the modelInfo + const serviceProvider = modelInfo.provider.providerName; const vars = { + ServiceProvider: serviceProvider, cutoff, model: modelConfig.model, time: new Date().toLocaleString(), @@ -119,7 +130,8 @@ function fillTemplateWith(input: string, modelConfig: ModelConfig) { } Object.entries(vars).forEach(([name, value]) => { - output = output.replaceAll(`{{${name}}}`, value); + const regex = new RegExp(`{{${name}}}`, "g"); + output = output.replace(regex, value.toString()); // Ensure value is a string }); return output; diff --git a/app/store/sync.ts b/app/store/sync.ts index a45913047..5ff1cc6e5 100644 --- a/app/store/sync.ts +++ b/app/store/sync.ts @@ -48,7 +48,7 @@ const DEFAULT_SYNC_STATE = { export const useSyncStore = createPersistStore( DEFAULT_SYNC_STATE, (set, get) => ({ - coundSync() { + cloudSync() { const config = get()[get().provider]; return Object.values(config).every((c) => c.toString().length > 0); },