Merge pull request #19 from heimoshuiyu/dev
Enhance current API display
This commit is contained in:
@@ -110,7 +110,14 @@ export function App() {
|
|||||||
|
|
||||||
const getChatStoreByIndex = async (index: number): Promise<ChatStore> => {
|
const getChatStoreByIndex = async (index: number): Promise<ChatStore> => {
|
||||||
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) {
|
||||||
|
const newStore = newChatStore({});
|
||||||
|
toast({
|
||||||
|
title: "New chat created",
|
||||||
|
description: `Current API Endpoint: ${newStore.apiEndpoint}`,
|
||||||
|
});
|
||||||
|
return newStore;
|
||||||
|
}
|
||||||
// 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 +133,11 @@ 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;
|
||||||
|
|
||||||
|
toast({
|
||||||
|
title: "Chat ready",
|
||||||
|
description: `Current API Endpoint: ${ret.apiEndpoint}`,
|
||||||
|
});
|
||||||
return ret;
|
return ret;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -139,8 +151,8 @@ export function App() {
|
|||||||
setSelectedChatIndex(newKey as number);
|
setSelectedChatIndex(newKey as number);
|
||||||
setAllChatStoreIndexes(await (await db).getAllKeys(STORAGE_NAME));
|
setAllChatStoreIndexes(await (await db).getAllKeys(STORAGE_NAME));
|
||||||
toast({
|
toast({
|
||||||
title: "New chat session created",
|
title: "New chat 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