Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
Another CherryPicks from expermental branch
Browse files Browse the repository at this point in the history
[+] chore(config.ts): update DEFAULT_CONFIG with DALL·E Models and Text Moderation Open AI settings
[+] chore(config.ts): add validation for DALL·E Models configuration properties
[+] chore(config.ts): update useAppConfig version to 4.2 to include DALL·E Models and Text Moderation Open AI settings
  • Loading branch information
H0llyW00dzZ committed Nov 10, 2023
1 parent a3bf10d commit 4546827
Showing 1 changed file with 75 additions and 2 deletions.
77 changes: 75 additions & 2 deletions app/store/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,46 @@ export const DEFAULT_CONFIG = {
model: "gpt-3.5-turbo" as ModelType,
temperature: 0.5,
top_p: 1,
max_tokens: 2000, // this bad if keep 8192 as default lmao we are not only using other ai that 100% not stable hahaha
max_tokens: 2000,
presence_penalty: 0,
frequency_penalty: 0,
/**
* DALL·E Models
* Author: @H0llyW00dzZ
*
**/
n: 1, // The number of images to generate. Must be between 1 and 10. For dall-e-3, only n=1 is supported.
/** Quality Only DALL·E-3 Models
* Author: @H0llyW00dzZ
* The quality of the image that will be generated.
* `hd` creates images with finer details and greater consistency across the image.
**/
quality: "hd", // Only DALL·E-3 for DALL·E-2 not not really needed
/** SIZE ALL·E Models
* Author: @H0llyW00dzZ
* DALL·E-2 : Must be one of `256x256`, `512x512`, or `1024x1024`.
* DALL-E-3 : Must be one of `1024x1024`, `1792x1024`, or `1024x1792`.
**/
size: "1024x1024",
/** Style DALL-E-3 Models
* Author: @H0llyW00dzZ
* Must be one of `vivid` or `natural`.
* `Vivid` causes the model to lean towards generating hyper-real and dramatic images.
* `Natural` causes the model to produce more natural, less hyper-real looking images.
*/
style: "vivid", // Only DALL·E-3 for DALL·E-2 not not really needed
system_fingerprint: "",
sendMemory: true,
historyMessageCount: 4,
compressMessageLengthThreshold: 1000,
enableInjectSystemPrompts: true,
template: DEFAULT_INPUT_TEMPLATE,
},
/**
* Text Moderation Open AI
* Author: @H0llyW00dzZ
**/
textmoderation: true, // text moderation default is enabled
};

export type ChatConfig = typeof DEFAULT_CONFIG;
Expand Down Expand Up @@ -96,6 +127,25 @@ export const ModalConfigValidator = {
top_p(x: number) {
return limitNumber(x, 0, 1, 1);
},
n(x: number) {
return limitNumber(x, 1, 10, 1);
},
quality(x: string) {
return ["hd"].includes(x) ? x : "hd";
},
size(x: string) {
const validSizes = ["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"];
return validSizes.includes(x) ? x : "1024x1024";
},
style(x: string) {
const validStyles = ["vivid", "natural"];
return validStyles.includes(x) ? x : "vivid";
},
system_fingerprint(x: string) {
// Example: Ensure the fingerprint matches the format "fp_XXXXXXXXXX" where X represents a hexadecimal digit
const regex = /^fp_[0-9a-fA-F]{10}$/;
return regex.test(x) ? x : "";
},
};

export const useAppConfig = createPersistStore(
Expand Down Expand Up @@ -132,7 +182,7 @@ export const useAppConfig = createPersistStore(
}),
{
name: StoreKey.Config,
version: 3.8,
version: 4.2, // DALL·E Models switching version to 4.1 because in 4.0 @Yidadaa using it.
migrate(persistedState, version) {
const state = persistedState as ChatConfig;

Expand Down Expand Up @@ -163,6 +213,29 @@ export const useAppConfig = createPersistStore(
state.lastUpdate = Date.now();
}

if (version < 3.9) {
state.textmoderation = true;
}

if (version < 4.1) {
state.modelConfig = {
...state.modelConfig,
n: 1,
quality: "hd",
size: "1024x1024",
style: "vivid",
};
}

// In the wilds 🚀

if (version < 4.2) {
state.modelConfig = {
...state.modelConfig,
system_fingerprint: "",
};
}

return state as any;
},
},
Expand Down

0 comments on commit 4546827

Please sign in to comment.