v0.2.3
This commit is contained in:
43
app/src/global-options/index.tsx
Normal file
43
app/src/global-options/index.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import { pluginMetadata } from "../core/plugins/metadata";
|
||||
import { Option } from "../core/options/option";
|
||||
import { OptionGroup } from "../core/options/option-group";
|
||||
import { openAIOptions } from "./openai";
|
||||
import { parameterOptions } from "./parameters";
|
||||
import { ttsServiceOptions } from "./tts-service";
|
||||
import { autoScrollOptions, inputOptions } from "./ui";
|
||||
import { whisperOptions } from "./whisper";
|
||||
|
||||
export const globalOptions: OptionGroup[] = [
|
||||
openAIOptions,
|
||||
autoScrollOptions,
|
||||
parameterOptions,
|
||||
inputOptions,
|
||||
whisperOptions,
|
||||
ttsServiceOptions,
|
||||
];
|
||||
|
||||
const optionsForQuickSettings: Option[] = [];
|
||||
[...globalOptions, ...pluginMetadata].forEach(plugin => {
|
||||
plugin.options.forEach(option => {
|
||||
if (option.displayInQuickSettings) {
|
||||
optionsForQuickSettings.push({
|
||||
id: plugin.id + "--" + option.id,
|
||||
defaultValue: !!option.displayInQuickSettings?.displayByDefault,
|
||||
displayOnSettingsScreen: "ui",
|
||||
displayAsSeparateSection: false,
|
||||
renderProps: {
|
||||
type: 'checkbox',
|
||||
label: option.displayInQuickSettings?.name || option.id,
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
export const quickSettings: OptionGroup = {
|
||||
id: 'quick-settings',
|
||||
name: "Quick Settings",
|
||||
options: optionsForQuickSettings,
|
||||
}
|
||||
|
||||
globalOptions.push(quickSettings);
|
32
app/src/global-options/openai.tsx
Normal file
32
app/src/global-options/openai.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import { OptionGroup } from "../core/options/option-group";
|
||||
|
||||
export const openAIOptions: OptionGroup = {
|
||||
id: 'openai',
|
||||
options: [
|
||||
{
|
||||
id: 'apiKey',
|
||||
defaultValue: "",
|
||||
displayOnSettingsScreen: "user",
|
||||
displayAsSeparateSection: true,
|
||||
renderProps: () => ({
|
||||
type: "password",
|
||||
label: "Your OpenAI API Key",
|
||||
placeholder: "sk-************************************************",
|
||||
description: <>
|
||||
<p>
|
||||
<a href="https://platform.openai.com/account/api-keys" target="_blank" rel="noreferrer">
|
||||
<FormattedMessage defaultMessage="Find your API key here." description="Label for the link that takes the user to the page on the OpenAI website where they can find their API key." />
|
||||
</a>
|
||||
</p>
|
||||
<p>
|
||||
<FormattedMessage defaultMessage="Your API key is stored only on this device and never transmitted to anyone except OpenAI." />
|
||||
</p>
|
||||
<p>
|
||||
<FormattedMessage defaultMessage="OpenAI API key usage is billed at a pay-as-you-go rate, separate from your ChatGPT subscription." />
|
||||
</p>
|
||||
</>,
|
||||
}),
|
||||
},
|
||||
],
|
||||
}
|
64
app/src/global-options/parameters.tsx
Normal file
64
app/src/global-options/parameters.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
import { defaultModel } from "../core/chat/openai";
|
||||
import { OptionGroup } from "../core/options/option-group";
|
||||
|
||||
export const parameterOptions: OptionGroup = {
|
||||
id: 'parameters',
|
||||
options: [
|
||||
{
|
||||
id: "model",
|
||||
defaultValue: defaultModel,
|
||||
resettable: false,
|
||||
scope: "user",
|
||||
displayOnSettingsScreen: "chat",
|
||||
displayAsSeparateSection: true,
|
||||
displayInQuickSettings: {
|
||||
name: "Model",
|
||||
displayByDefault: true,
|
||||
label: (value) => value,
|
||||
},
|
||||
renderProps: (value, options, context) => ({
|
||||
type: "select",
|
||||
label: "Model",
|
||||
description: value === 'gpt-4' && context.intl.formatMessage(
|
||||
{
|
||||
defaultMessage: "Note: GPT-4 will only work if your OpenAI account has been granted access to the new model. <a>Request access here.</a>",
|
||||
},
|
||||
{
|
||||
a: (text: string) => <a href="https://openai.com/waitlist/gpt-4-api" target="_blank" rel="noreferer">{text}</a>
|
||||
} as any,
|
||||
),
|
||||
options: [
|
||||
{
|
||||
label: "GPT 3.5 Turbo (default)",
|
||||
value: "gpt-3.5-turbo",
|
||||
},
|
||||
{
|
||||
label: "GPT 4 (requires invite)",
|
||||
value: "gpt-4",
|
||||
},
|
||||
],
|
||||
}),
|
||||
},
|
||||
{
|
||||
id: "temperature",
|
||||
defaultValue: 0.5,
|
||||
resettable: true,
|
||||
scope: "chat",
|
||||
displayOnSettingsScreen: "chat",
|
||||
displayAsSeparateSection: true,
|
||||
displayInQuickSettings: {
|
||||
name: "Temperature",
|
||||
displayByDefault: false,
|
||||
label: (value) => "Temperature: " + value.toFixed(1),
|
||||
},
|
||||
renderProps: (value, options, context) => ({
|
||||
type: "slider",
|
||||
label: "Temperature: " + value.toFixed(1),
|
||||
min: 0,
|
||||
max: 1,
|
||||
step: 0.1,
|
||||
description: context.intl.formatMessage({ defaultMessage: "The temperature parameter controls the randomness of the AI's responses. Lower values will make the AI more predictable, while higher values will make it more creative." }),
|
||||
})
|
||||
}
|
||||
]
|
||||
};
|
34
app/src/global-options/tts-service.tsx
Normal file
34
app/src/global-options/tts-service.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ttsPlugins } from "../core/plugins/metadata";
|
||||
import { OptionGroup } from "../core/options/option-group";
|
||||
|
||||
const ttsPluginMetadata = ttsPlugins.map(p => new p().describe());
|
||||
|
||||
export const ttsServiceOptions: OptionGroup = {
|
||||
id: 'tts',
|
||||
options: [
|
||||
{
|
||||
id: 'autoplay',
|
||||
displayOnSettingsScreen: "speech",
|
||||
defaultValue: false,
|
||||
displayAsSeparateSection: true,
|
||||
renderProps: {
|
||||
type: "checkbox",
|
||||
label: "Read messages aloud automatically",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'service',
|
||||
displayOnSettingsScreen: "speech",
|
||||
defaultValue: "elevenlabs",
|
||||
displayAsSeparateSection: true,
|
||||
renderProps: {
|
||||
type: "select",
|
||||
label: "Choose a Text-to-Speech Provider",
|
||||
options: ttsPluginMetadata.map(p => ({
|
||||
label: p.name,
|
||||
value: p.id,
|
||||
})),
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
50
app/src/global-options/ui.tsx
Normal file
50
app/src/global-options/ui.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { OptionGroup } from "../core/options/option-group";
|
||||
|
||||
export const autoScrollOptions: OptionGroup = {
|
||||
id: 'auto-scroll',
|
||||
name: "Autoscroll",
|
||||
options: [
|
||||
{
|
||||
id: 'auto-scroll-when-opening-chat',
|
||||
defaultValue: false,
|
||||
displayOnSettingsScreen: "ui",
|
||||
displayAsSeparateSection: false,
|
||||
renderProps: {
|
||||
type: "checkbox",
|
||||
label: "Auto-scroll to the bottom of the page when opening a chat",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'auto-scroll-while-generating',
|
||||
defaultValue: true,
|
||||
displayOnSettingsScreen: "ui",
|
||||
displayAsSeparateSection: false,
|
||||
renderProps: {
|
||||
type: "checkbox",
|
||||
label: "Auto-scroll while generating a response",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
export const inputOptions: OptionGroup = {
|
||||
id: 'input',
|
||||
name: "Message Input",
|
||||
options: [
|
||||
{
|
||||
id: 'submit-on-enter',
|
||||
defaultValue: true,
|
||||
displayOnSettingsScreen: "ui",
|
||||
displayAsSeparateSection: false,
|
||||
displayInQuickSettings: {
|
||||
name: "Enable/disable submit message when Enter is pressed",
|
||||
displayByDefault: false,
|
||||
label: (value) => value ? "Disable submit on Enter" : "Enable submit on Enter",
|
||||
},
|
||||
renderProps: {
|
||||
type: "checkbox",
|
||||
label: "Submit message when Enter is pressed",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
31
app/src/global-options/whisper.tsx
Normal file
31
app/src/global-options/whisper.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import { OptionGroup } from "../core/options/option-group";
|
||||
import { supportsSpeechRecognition } from "../core/speech-recognition-types";
|
||||
|
||||
export const whisperOptions: OptionGroup = {
|
||||
id: 'speech-recognition',
|
||||
name: "Microphone",
|
||||
hidden: !supportsSpeechRecognition,
|
||||
options: [
|
||||
{
|
||||
id: 'use-whisper',
|
||||
defaultValue: false,
|
||||
displayOnSettingsScreen: "speech",
|
||||
displayAsSeparateSection: false,
|
||||
renderProps: {
|
||||
type: "checkbox",
|
||||
label: "Use the OpenAI Whisper API for speech recognition",
|
||||
hidden: !supportsSpeechRecognition,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'show-microphone',
|
||||
defaultValue: true,
|
||||
displayOnSettingsScreen: "speech",
|
||||
displayAsSeparateSection: false,
|
||||
renderProps: {
|
||||
type: "checkbox",
|
||||
label: "Show microphone in message input",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
Reference in New Issue
Block a user