-
Notifications
You must be signed in to change notification settings - Fork 60.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
323 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import type { | ||
CreateChatCompletionRequest, | ||
CreateChatCompletionResponse, | ||
CreateImageRequestSizeEnum, | ||
} from "openai"; | ||
|
||
export type ChatRequest = CreateChatCompletionRequest; | ||
export type ChatResponse = CreateChatCompletionResponse; | ||
|
||
export type ImageRequestSizeEnum = CreateImageRequestSizeEnum; | ||
export type Updater<T> = (updater: (value: T) => void) => void; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { | ||
ALL_MODELS, | ||
ImageModalConfigValidator, | ||
ImageModelConfig, | ||
ModalConfigValidator, | ||
ModelConfig, | ||
} from "../store"; | ||
|
||
import Locale from "../locales"; | ||
import { InputRange } from "./input-range"; | ||
import { Input, List, ListItem, Select } from "./ui-lib"; | ||
import { ImageRequestSizeEnum } from "../api/openai/typing"; | ||
import { CreateImageRequestSizeEnum } from "openai"; | ||
|
||
export function ImageModelConfigList(props: { | ||
imageModelConfig: ImageModelConfig; | ||
updateConfig: (updater: (config: ImageModelConfig) => void) => void; | ||
}) { | ||
return ( | ||
<> | ||
<ListItem title={Locale.Settings.ImageModel.Title}> | ||
<input value={Locale.Settings.ImageModel.Model} disabled={true} /> | ||
</ListItem> | ||
<ListItem title={Locale.Settings.ImageModel.Command}> | ||
<input | ||
value={props.imageModelConfig.command} | ||
onChange={(e) => { | ||
props.updateConfig((config) => { | ||
config.command = e.currentTarget.value; // Assign the parsed value | ||
return config; | ||
}); | ||
}} | ||
/> | ||
</ListItem> | ||
<ListItem title={Locale.Settings.ImageModel.CountLimit}> | ||
<InputRange | ||
value={props.imageModelConfig.imageLimit.toString()} // Keep the value as a string | ||
onChange={(e) => { | ||
const newValue = parseInt(e.currentTarget.value, 10); // Parse the value as an integer | ||
if (!isNaN(newValue)) { | ||
props.updateConfig((config) => { | ||
config.imageLimit = newValue; // Assign the parsed value | ||
return config; | ||
}); | ||
} | ||
}} | ||
min={"1"} // Convert the min value to a string | ||
max={"10"} // Convert the max value to a string | ||
step={"1"} // Convert the step value to a string | ||
/> | ||
</ListItem> | ||
<ListItem title={Locale.Settings.ImageModel.Size}> | ||
<Select | ||
value={props.imageModelConfig.size} | ||
onChange={(e) => { | ||
const newSize = ImageModalConfigValidator.size( | ||
e.currentTarget.value, | ||
); | ||
props.updateConfig((config) => { | ||
config.size = newSize; | ||
return config; | ||
}); | ||
}} | ||
> | ||
{Object.values(CreateImageRequestSizeEnum).map((v) => ( | ||
<option value={v} key={v}> | ||
{v} | ||
</option> | ||
))} | ||
</Select> | ||
</ListItem> | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.