Skip to content

Commit

Permalink
Voice Calls - Labs option
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed Nov 24, 2023
1 parent dff83c5 commit 2dfa78f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
3 changes: 0 additions & 3 deletions src/apps/call/AppCall.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import { CallUI } from './CallUI';
import { CallWizard } from './CallWizard';


export const APP_CALL_ENABLED = false;


export function AppCall() {
// external state
const { query } = useRouter();
Expand Down
6 changes: 3 additions & 3 deletions src/apps/chat/components/applayout/usePersonaDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import { shallow } from 'zustand/shallow';
import { ListItemButton, ListItemDecorator } from '@mui/joy';
import CallIcon from '@mui/icons-material/Call';

import { APP_CALL_ENABLED } from '../../../call/AppCall';

import { SystemPurposeId, SystemPurposes } from '../../../../data';

import { AppBarDropdown } from '~/common/layout/AppBarDropdown';
import { DConversationId, useChatStore } from '~/common/state/store-chats';
import { launchAppCall } from '~/common/app.routes';
import { useUIPreferencesStore } from '~/common/state/store-ui';
import { useUXLabsStore } from '~/common/state/store-ux-labs';


function AppBarPersonaDropdown(props: {
Expand Down Expand Up @@ -55,6 +54,7 @@ function AppBarPersonaDropdown(props: {
export function usePersonaIdDropdown(conversationId: DConversationId | null) {

// external state
const labsCalling = useUXLabsStore(state => state.labsCalling);
const { systemPurposeId } = useChatStore(state => {
const conversation = state.conversations.find(conversation => conversation.id === conversationId);
return {
Expand All @@ -69,7 +69,7 @@ export function usePersonaIdDropdown(conversationId: DConversationId | null) {
if (conversationId && systemPurposeId)
useChatStore.getState().setSystemPurposeId(conversationId, systemPurposeId);
}}
onCall={APP_CALL_ENABLED ? () => {
onCall={labsCalling ? () => {
if (conversationId && systemPurposeId)
launchAppCall(conversationId, systemPurposeId);
} : undefined}
Expand Down
7 changes: 4 additions & 3 deletions src/apps/chat/components/composer/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import StopOutlinedIcon from '@mui/icons-material/StopOutlined';
import TelegramIcon from '@mui/icons-material/Telegram';

import type { ChatModeId } from '../../AppChat';
import { APP_CALL_ENABLED } from '../../../call/AppCall';

import { ContentReducer } from '~/modules/aifn/summarize/ContentReducer';
import { LLMOptionsOpenAI } from '~/modules/llms/vendors/openai/openai.vendor';
Expand All @@ -36,6 +35,7 @@ import { useDebouncer } from '~/common/components/useDebouncer';
import { useGlobalShortcut } from '~/common/components/useGlobalShortcut';
import { useIsMobile } from '~/common/components/useMatchMedia';
import { useUIPreferencesStore } from '~/common/state/store-ui';
import { useUXLabsStore } from '~/common/state/store-ux-labs';

import { ButtonCameraCapture } from './ButtonCameraCapture';
import { ButtonClipboardPaste } from './ButtonClipboardPaste';
Expand Down Expand Up @@ -135,6 +135,7 @@ export function Composer(props: {

// external state
const isMobile = useIsMobile();
const labsCalling = useUXLabsStore(state => state.labsCalling);
const [chatModeId, setChatModeId] = React.useState<ChatModeId>('immediate');
const [startupText, setStartupText] = useComposerStartupText();
const enterIsNewline = useUIPreferencesStore(state => state.enterIsNewline);
Expand Down Expand Up @@ -585,7 +586,7 @@ export function Composer(props: {

{/* [mobile] bottom-corner secondary button */}
{isMobile && (isChat
? <CallButtonMobile disabled={!APP_CALL_ENABLED || !props.conversationId || !chatLLM} onClick={handleCallClicked} sx={{ mr: { xs: 1, md: 2 } }} />
? <CallButtonMobile disabled={!labsCalling || !props.conversationId || !chatLLM} onClick={handleCallClicked} sx={{ mr: { xs: 1, md: 2 } }} />
: (isDraw || isDrawPlus)
? <DrawOptionsButtonMobile onClick={handleDrawOptionsClicked} sx={{ mr: { xs: 1, md: 2 } }} />
: <IconButton disabled variant='plain' color='neutral' sx={{ mr: { xs: 1, md: 2 } }} />
Expand Down Expand Up @@ -623,7 +624,7 @@ export function Composer(props: {
{isDesktop && <Box sx={{ flexGrow: 1, display: 'flex', flexDirection: 'column', gap: 1, justifyContent: 'flex-end' }}>

{/* [desktop] Call secondary button */}
{isChat && <CallButtonDesktop disabled={!APP_CALL_ENABLED || !props.conversationId || !chatLLM} onClick={handleCallClicked} />}
{isChat && <CallButtonDesktop disabled={!labsCalling || !props.conversationId || !chatLLM} onClick={handleCallClicked} />}

{/* [desktop] Draw Options secondary button */}
{(isDraw || isDrawPlus) && <DrawOptionsButtonDesktop onClick={handleDrawOptionsClicked} />}
Expand Down
10 changes: 8 additions & 2 deletions src/apps/settings-modal/UxLabsSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';

import { FormControl, Typography } from '@mui/joy';
import CallIcon from '@mui/icons-material/Call';
import FormatPaintIcon from '@mui/icons-material/FormatPaint';
import VerticalSplitIcon from '@mui/icons-material/VerticalSplit';
import YouTubeIcon from '@mui/icons-material/YouTube';
Expand All @@ -15,8 +16,8 @@ export function UxLabsSettings() {

// external state
const {
/*labsEnhancedUI,*/ labsMagicDraw, labsPersonaYTCreator, labsSplitBranching,
/*setLabsEnhancedUI,*/ setLabsMagicDraw, setLabsPersonaYTCreator, setLabsSplitBranching,
labsCalling, /*labsEnhancedUI,*/ labsMagicDraw, labsPersonaYTCreator, labsSplitBranching,
setLabsCalling, /*setLabsEnhancedUI,*/ setLabsMagicDraw, setLabsPersonaYTCreator, setLabsSplitBranching,
} = useUXLabsStore();

return <>
Expand All @@ -31,6 +32,11 @@ export function UxLabsSettings() {
checked={labsMagicDraw} onChange={setLabsMagicDraw}
/>

<FormSwitchControl
title={<><CallIcon /> Voice Calls</>} description={labsCalling ? 'Call AGI' : 'Disabled'}
checked={labsCalling} onChange={setLabsCalling}
/>

<FormSwitchControl
title={<><VerticalSplitIcon /> Split Branching</>} description={labsSplitBranching ? 'Enabled' : 'Disabled'} disabled
checked={labsSplitBranching} onChange={setLabsSplitBranching}
Expand Down
6 changes: 6 additions & 0 deletions src/common/state/store-ux-labs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { persist } from 'zustand/middleware';
*/
interface UXLabsStore {

labsCalling: boolean;
setLabsCalling: (labsCalling: boolean) => void;

labsEnhancedUI: boolean;
setLabsEnhancedUI: (labsEnhancedUI: boolean) => void;

Expand All @@ -30,6 +33,9 @@ export const useUXLabsStore = create<UXLabsStore>()(
persist(
(set) => ({

labsCalling: false,
setLabsCalling: (labsCalling: boolean) => set({ labsCalling }),

labsEnhancedUI: false,
setLabsEnhancedUI: (labsEnhancedUI: boolean) => set({ labsEnhancedUI }),

Expand Down

0 comments on commit 2dfa78f

Please sign in to comment.