feat: enhance chat session notifications with API endpoint details
This commit is contained in:
@@ -90,6 +90,7 @@ import { useToast } from "@/hooks/use-toast";
|
|||||||
import { ModeToggle } from "@/components/ModeToggle";
|
import { ModeToggle } from "@/components/ModeToggle";
|
||||||
|
|
||||||
import Navbar from "@/components/navbar";
|
import Navbar from "@/components/navbar";
|
||||||
|
import { is } from "date-fns/locale";
|
||||||
|
|
||||||
export function App() {
|
export function App() {
|
||||||
// init selected index
|
// init selected index
|
||||||
@@ -109,8 +110,12 @@ export function App() {
|
|||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
|
|
||||||
const getChatStoreByIndex = async (index: number): Promise<ChatStore> => {
|
const getChatStoreByIndex = async (index: number): Promise<ChatStore> => {
|
||||||
|
let isOverrideEndpoint = false;
|
||||||
const ret: ChatStore = await (await db).get(STORAGE_NAME, index);
|
const ret: ChatStore = await (await db).get(STORAGE_NAME, index);
|
||||||
if (ret === null || ret === undefined) return newChatStore({});
|
if (ret === null || ret === undefined) {
|
||||||
|
isOverrideEndpoint = true;
|
||||||
|
return newChatStore({});
|
||||||
|
}
|
||||||
// handle read from old version chatstore
|
// handle read from old version chatstore
|
||||||
if (ret.maxGenTokens === undefined) ret.maxGenTokens = 2048;
|
if (ret.maxGenTokens === undefined) ret.maxGenTokens = 2048;
|
||||||
if (ret.maxGenTokens_enabled === undefined) ret.maxGenTokens_enabled = true;
|
if (ret.maxGenTokens_enabled === undefined) ret.maxGenTokens_enabled = true;
|
||||||
@@ -126,6 +131,19 @@ export function App() {
|
|||||||
message.token = calculate_token_length(message.content);
|
message.token = calculate_token_length(message.content);
|
||||||
}
|
}
|
||||||
if (ret.cost === undefined) ret.cost = 0;
|
if (ret.cost === undefined) ret.cost = 0;
|
||||||
|
if (isOverrideEndpoint) {
|
||||||
|
// if the chatStore is not found, we need to override the endpoint
|
||||||
|
// with the default one
|
||||||
|
toast({
|
||||||
|
title: "New chat session created",
|
||||||
|
description: `API Endpoint: ${ret.apiEndpoint}`,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
toast({
|
||||||
|
title: "Chat history loaded",
|
||||||
|
description: `Current API Endpoint: ${ret.apiEndpoint}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -140,7 +158,7 @@ export function App() {
|
|||||||
setAllChatStoreIndexes(await (await db).getAllKeys(STORAGE_NAME));
|
setAllChatStoreIndexes(await (await db).getAllKeys(STORAGE_NAME));
|
||||||
toast({
|
toast({
|
||||||
title: "New chat session created",
|
title: "New chat session created",
|
||||||
description: `A new chat session (ID. ${newKey}) has been created.`,
|
description: `Current API Endpoint: ${chatStore.apiEndpoint}`,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const handleNewChatStore = async () => {
|
const handleNewChatStore = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user