This commit is contained in:
GH Action - Upstream Sync
2023-05-20 00:58:49 +00:00
25 changed files with 142 additions and 233 deletions

View File

@@ -5,9 +5,9 @@ import { trimTopic } from "../utils";
import Locale from "../locales";
import { showToast } from "../components/ui-lib";
import { ModelType } from "./config";
import { ModelType, useAppConfig } from "./config";
import { createEmptyMask, Mask } from "./mask";
import { REQUEST_TIMEOUT_MS, StoreKey } from "../constant";
import { StoreKey } from "../constant";
import { api, RequestMessage } from "../client/api";
import { ChatControllerPool } from "../client/controller";
import { prettyObject } from "../utils/format";
@@ -38,7 +38,6 @@ export interface ChatStat {
export interface ChatSession {
id: number;
topic: string;
memoryPrompt: string;
@@ -69,6 +68,7 @@ function createEmptySession(): ChatSession {
},
lastUpdate: Date.now(),
lastSummarizeIndex: 0,
mask: createEmptyMask(),
};
}
@@ -463,7 +463,7 @@ export const useChatStore = create<ChatStore>()(
if (
historyMsgLength > modelConfig.compressMessageLengthThreshold &&
session.mask.modelConfig.sendMemory
modelConfig.sendMemory
) {
api.llm.chat({
messages: toBeSummarizedMsgs.concat({

View File

@@ -68,6 +68,14 @@ export const ALL_MODELS = [
name: "gpt-4-32k-0314",
available: ENABLE_GPT4,
},
{
name: "gpt-4-mobile",
available: ENABLE_GPT4,
},
{
name: "ext-davinci-002-render-sha-mobile",
available: true,
},
{
name: "gpt-3.5-turbo",
available: true,
@@ -98,13 +106,13 @@ export const ALL_MODELS = [
},
] as const;
export type ModelType = (typeof ALL_MODELS)[number]["name"];
export type ModelType = typeof ALL_MODELS[number]["name"];
export function limitNumber(
x: number,
min: number,
max: number,
defaultValue: number,
defaultValue: number
) {
if (typeof x !== "number" || isNaN(x)) {
return defaultValue;
@@ -163,6 +171,6 @@ export const useAppConfig = create<ChatConfigStore>()(
return state;
},
},
),
}
)
);

View File

@@ -11,6 +11,7 @@ export type Mask = {
avatar: string;
name: string;
context: ChatMessage[];
syncGlobalConfig?: boolean;
modelConfig: ModelConfig;
lang: Lang;
builtin: boolean;
@@ -39,6 +40,7 @@ export const createEmptyMask = () =>
avatar: DEFAULT_MASK_AVATAR,
name: DEFAULT_TOPIC,
context: [],
syncGlobalConfig: true, // use global config as default
modelConfig: { ...useAppConfig.getState().modelConfig },
lang: getLang(),
builtin: false,