feat: support dall-e model chat

This commit is contained in:
Hk-Gosuto
2024-09-22 20:03:22 +08:00
parent 4331c0d9af
commit 3f78a6425e
24 changed files with 659 additions and 15871 deletions

View File

@@ -18,6 +18,7 @@ import {
GEMINI_SUMMARIZE_MODEL,
MYFILES_BROWSER_TOOLS_SYSTEM_PROMPT,
} from "../constant";
import { isDalle3, safeLocalStorage } from "../utils";
import { getClientApi } from "../client/api";
import type {
ClientApi,
@@ -39,6 +40,20 @@ import { FileInfo } from "../client/platforms/utils";
import { collectModelsWithDefaultModel } from "../utils/model";
import { useAccessStore } from "./access";
const localStorage = safeLocalStorage();
export type ChatMessageTool = {
id: string;
index?: number;
type?: string;
function?: {
name: string;
arguments?: string;
};
content?: string;
isError?: boolean;
};
export type ChatMessage = RequestMessage & {
date: string;
toolMessages?: ChatToolMessage[];
@@ -670,6 +685,10 @@ ${file.partial}
const config = useAppConfig.getState();
const session = get().currentSession();
const modelConfig = session.mask.modelConfig;
// skip summarize when using dalle3?
if (isDalle3(modelConfig.model)) {
return;
}
const api: ClientApi = getClientApi(modelConfig.providerName);

View File

@@ -1,4 +1,5 @@
import { LLMModel } from "../client/api";
import { DalleSize, DalleQuality, DalleStyle } from "../typing";
import { getClientConfig } from "../config/client";
import {
DEFAULT_INPUT_TEMPLATE,
@@ -61,7 +62,7 @@ export const DEFAULT_CONFIG = {
models: DEFAULT_MODELS as any as LLMModel[],
modelConfig: {
model: "gpt-3.5-turbo" as ModelType,
model: "gpt-4o-mini" as ModelType,
providerName: "OpenAI" as ServiceProvider,
temperature: 0.5,
top_p: 1,
@@ -73,6 +74,9 @@ export const DEFAULT_CONFIG = {
compressMessageLengthThreshold: 1000,
enableInjectSystemPrompts: true,
template: config?.template ?? DEFAULT_INPUT_TEMPLATE,
size: "1024x1024" as DalleSize,
quality: "standard" as DalleQuality,
style: "vivid" as DalleStyle,
},
pluginConfig: {

View File

@@ -2,3 +2,4 @@ export * from "./chat";
export * from "./update";
export * from "./access";
export * from "./config";
export * from "./plugin";