v0.2.3
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
import type { RootState } from '.';
|
||||
|
||||
const initialState: {
|
||||
openAIApiKey?: string | null | undefined;
|
||||
useOpenAIWhisper: boolean;
|
||||
elevenLabsApiKey?: string | null | undefined;
|
||||
|
||||
} = {
|
||||
openAIApiKey: localStorage.getItem('openai-api-key'),
|
||||
useOpenAIWhisper: false,
|
||||
elevenLabsApiKey: localStorage.getItem('elevenlabs-api-key'),
|
||||
};
|
||||
|
||||
export const apiKeysSlice = createSlice({
|
||||
name: 'apiKeys',
|
||||
initialState,
|
||||
reducers: {
|
||||
setOpenAIApiKey: (state, action: PayloadAction<string>) => {
|
||||
state.openAIApiKey = action.payload;
|
||||
},
|
||||
setElevenLabsApiKey: (state, action: PayloadAction<string>) => {
|
||||
state.elevenLabsApiKey = action.payload;
|
||||
},
|
||||
setUseOpenAIWhisper: (state, action: PayloadAction<boolean>) => {
|
||||
state.useOpenAIWhisper = action.payload;
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
export const { setOpenAIApiKey, setElevenLabsApiKey } = apiKeysSlice.actions;
|
||||
|
||||
export const setOpenAIApiKeyFromEvent = (event: React.ChangeEvent<HTMLInputElement>) => apiKeysSlice.actions.setOpenAIApiKey(event.target.value);
|
||||
export const setElevenLabsApiKeyFromEvent = (event: React.ChangeEvent<HTMLInputElement>) => apiKeysSlice.actions.setElevenLabsApiKey(event.target.value);
|
||||
export const setUseOpenAIWhisperFromEvent = (event: React.ChangeEvent<HTMLInputElement>) => apiKeysSlice.actions.setUseOpenAIWhisper(event.target.checked);
|
||||
|
||||
export const selectOpenAIApiKey = (state: RootState) => state.apiKeys.openAIApiKey;
|
||||
export const selectElevenLabsApiKey = (state: RootState) => state.apiKeys.elevenLabsApiKey;
|
||||
export const selectUseOpenAIWhisper = (state: RootState) => state.apiKeys.useOpenAIWhisper;
|
||||
|
||||
export default apiKeysSlice.reducer;
|
@@ -3,11 +3,8 @@ import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { persistReducer, persistStore } from 'redux-persist';
|
||||
import messageReducer from './message';
|
||||
import parametersReducer from './parameters';
|
||||
import apiKeysReducer from './api-keys';
|
||||
import voiceReducer from './voices';
|
||||
import settingsUIReducer from './settings-ui';
|
||||
import uiReducer from './ui';
|
||||
import settingsUIReducer from './settings-ui';
|
||||
import sidebarReducer from './sidebar';
|
||||
|
||||
const persistConfig = {
|
||||
@@ -29,13 +26,9 @@ const persistMessageConfig = {
|
||||
|
||||
const store = configureStore({
|
||||
reducer: {
|
||||
// auth: authReducer,
|
||||
apiKeys: persistReducer(persistConfig, apiKeysReducer),
|
||||
settingsUI: settingsUIReducer,
|
||||
voices: persistReducer(persistConfig, voiceReducer),
|
||||
parameters: persistReducer(persistConfig, parametersReducer),
|
||||
message: persistReducer(persistMessageConfig, messageReducer),
|
||||
ui: uiReducer,
|
||||
settingsUI: settingsUIReducer,
|
||||
sidebar: persistReducer(persistSidebarConfig, sidebarReducer),
|
||||
},
|
||||
})
|
||||
|
@@ -1,37 +0,0 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit'
|
||||
import type { RootState } from '.';
|
||||
import { defaultSystemPrompt, defaultModel } from '../openai';
|
||||
import { defaultParameters } from '../parameters';
|
||||
import { Parameters } from '../types';
|
||||
|
||||
const initialState: Parameters = defaultParameters;
|
||||
|
||||
export const parametersSlice = createSlice({
|
||||
name: 'parameters',
|
||||
initialState,
|
||||
reducers: {
|
||||
setSystemPrompt: (state, action: PayloadAction<string>) => {
|
||||
state.initialSystemPrompt = action.payload;
|
||||
},
|
||||
resetSystemPrompt: (state) => {
|
||||
state.initialSystemPrompt = defaultSystemPrompt;
|
||||
},
|
||||
setModel: (state, action: PayloadAction<string>) => {
|
||||
state.model = action.payload;
|
||||
},
|
||||
resetModel: (state) => {
|
||||
state.model = defaultModel;
|
||||
},
|
||||
setTemperature: (state, action: PayloadAction<number>) => {
|
||||
state.temperature = action.payload;
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export const { setSystemPrompt, setModel, setTemperature, resetSystemPrompt, resetModel } = parametersSlice.actions;
|
||||
|
||||
export const selectSystemPrompt = (state: RootState) => state.parameters.initialSystemPrompt;
|
||||
export const selectModel = (state: RootState) => state.parameters.model;
|
||||
export const selectTemperature = (state: RootState) => state.parameters.temperature;
|
||||
|
||||
export default parametersSlice.reducer;
|
@@ -30,9 +30,9 @@ export const closeSettingsUI = () => settingsUISlice.actions.setTabAndOption({ t
|
||||
export const selectSettingsTab = (state: RootState) => state.settingsUI.tab;
|
||||
export const selectSettingsOption = (state: RootState) => state.settingsUI.option;
|
||||
|
||||
export const openOpenAIApiKeyPanel = () => settingsUISlice.actions.setTabAndOption({ tab: 'user', option: 'openai-api-key' });
|
||||
export const openOpenAIApiKeyPanel = () => settingsUISlice.actions.setTabAndOption({ tab: 'user', option: 'apiKey' });
|
||||
export const openElevenLabsApiKeyPanel = () => settingsUISlice.actions.setTabAndOption({ tab: 'speech', option: 'elevenlabs-api-key' });
|
||||
export const openSystemPromptPanel = () => settingsUISlice.actions.setTabAndOption({ tab: 'options', option: 'system-prompt' });
|
||||
export const openSystemPromptPanel = () => settingsUISlice.actions.setTabAndOption({ tab: 'options', option: 'systemPrompt' });
|
||||
export const openTemperaturePanel = () => settingsUISlice.actions.setTabAndOption({ tab: 'options', option: 'temperature' });
|
||||
|
||||
export default settingsUISlice.reducer;
|
@@ -1,23 +0,0 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
import type { RootState } from '.';
|
||||
import { defaultElevenLabsVoiceID } from '../tts/defaults';
|
||||
|
||||
const initialState = {
|
||||
voice: defaultElevenLabsVoiceID,
|
||||
};
|
||||
|
||||
export const voicesSlice = createSlice({
|
||||
name: 'voices',
|
||||
initialState,
|
||||
reducers: {
|
||||
setVoice: (state, action: PayloadAction<string|null>) => {
|
||||
state.voice = action.payload || '';
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
export const { setVoice } = voicesSlice.actions;
|
||||
|
||||
export const selectVoice = (state: RootState) => state.voices.voice;
|
||||
|
||||
export default voicesSlice.reducer;
|
Reference in New Issue
Block a user