-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse: full support for markdown transform
- Loading branch information
Showing
4 changed files
with
94 additions
and
41 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,62 +1,95 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'zustand/shallow'; | ||
import { useShallow } from 'zustand/react/shallow'; | ||
|
||
import { Checkbox, FormControl, FormHelperText } from '@mui/joy'; | ||
import { Checkbox, FormControl, FormHelperText, Option, Select, Typography } from '@mui/joy'; | ||
|
||
import { FormInputKey } from '~/common/components/forms/FormInputKey'; | ||
import { Link } from '~/common/components/Link'; | ||
import { platformAwareKeystrokes } from '~/common/components/KeyStroke'; | ||
|
||
import { useBrowseCapability, useBrowseStore } from './store-module-browsing'; | ||
import { ExternalLink } from '~/common/components/ExternalLink'; | ||
import { FormLabelStart } from '~/common/components/forms/FormLabelStart'; | ||
|
||
|
||
export function BrowseSettings() { | ||
|
||
// external state | ||
const { mayWork, isServerConfig, isClientValid, inCommand, inComposer, inReact } = useBrowseCapability(); | ||
const { wssEndpoint, setWssEndpoint, setEnableCommandBrowse, setEnableComposerAttach, setEnableReactTool } = useBrowseStore(state => ({ | ||
const { mayWork, isServerConfig, isClientValid, inCommand, inComposer, inReact, inPersonas } = useBrowseCapability(); | ||
const { | ||
wssEndpoint, setWssEndpoint, | ||
pageTransform, setPageTransform, | ||
setEnableCommandBrowse, setEnableComposerAttach, setEnableReactTool, setEnablePersonaTool, | ||
} = useBrowseStore(useShallow(state => ({ | ||
wssEndpoint: state.wssEndpoint, | ||
pageTransform: state.pageTransform, | ||
setPageTransform: state.setPageTransform, | ||
setWssEndpoint: state.setWssEndpoint, | ||
setEnableCommandBrowse: state.setEnableCommandBrowse, | ||
setEnableComposerAttach: state.setEnableComposerAttach, | ||
setEnableReactTool: state.setEnableReactTool, | ||
}), shallow); | ||
setEnablePersonaTool: state.setEnablePersonaTool, | ||
}))); | ||
|
||
const handlePageTransformChange = (_event: any, value: typeof pageTransform | null) => value && setPageTransform(value); | ||
|
||
|
||
return <> | ||
|
||
<FormHelperText sx={{ display: 'block' }}> | ||
Configure a browsing service to enable loading links and pages. See the <Link | ||
href='https://github.com/enricoros/big-agi/blob/main/docs/config-feature-browse.md' target='_blank' noLinkStyle> | ||
browse configuration guide</Link> for more information. | ||
</FormHelperText> | ||
<Typography level='body-sm'> | ||
Configure Browsing to enable loading links and web pages. <ExternalLink | ||
href='https://github.com/enricoros/big-agi/blob/main/docs/config-feature-browse.md'> | ||
Learn more</ExternalLink>. | ||
</Typography> | ||
|
||
<FormInputKey | ||
autoCompleteId='browse-wss' label='Puppeteer Endpoint' noKey | ||
autoCompleteId='browse-wss' label='Puppeteer Wss' noKey | ||
value={wssEndpoint} onChange={setWssEndpoint} | ||
rightLabel={!isServerConfig ? 'required' : '✔️ already set in server'} | ||
required={!isServerConfig} isError={!isClientValid && !isServerConfig} | ||
placeholder='wss://...' | ||
/> | ||
|
||
|
||
<FormControl orientation='horizontal' sx={{ justifyContent: 'space-between', alignItems: 'center' }}> | ||
<FormLabelStart title='Load pages as:' /> | ||
<Select | ||
variant='outlined' | ||
value={pageTransform} onChange={handlePageTransformChange} | ||
slotProps={{ | ||
root: { sx: { minWidth: '140px' } }, | ||
indicator: { sx: { opacity: 0.5 } }, | ||
button: { sx: { whiteSpace: 'inherit' } }, | ||
}} | ||
> | ||
<Option value='text'>Text (default)</Option> | ||
<Option value='markdown'>Markdown</Option> | ||
<Option value='html'>HTML</Option> | ||
</Select> | ||
</FormControl> | ||
|
||
|
||
<Typography level='body-sm' sx={{ mt: 2 }}>Browsing enablement:</Typography> | ||
|
||
<FormControl disabled={!mayWork}> | ||
<Checkbox variant='outlined' label='Attach URLs' checked={inComposer} onChange={(event) => setEnableComposerAttach(event.target.checked)} /> | ||
<FormHelperText>{platformAwareKeystrokes('Load and attach a page when pasting a URL')}</FormHelperText> | ||
<Checkbox size='sm' label='Paste URLs' checked={inComposer} onChange={(event) => setEnableComposerAttach(event.target.checked)} /> | ||
<FormHelperText>{platformAwareKeystrokes('Load and attach when pasting a URL')}</FormHelperText> | ||
</FormControl> | ||
|
||
<FormControl disabled={!mayWork}> | ||
<Checkbox variant='outlined' label='/browse' checked={inCommand} onChange={(event) => setEnableCommandBrowse(event.target.checked)} /> | ||
<Checkbox size='sm' label='/browse' checked={inCommand} onChange={(event) => setEnableCommandBrowse(event.target.checked)} /> | ||
<FormHelperText>{platformAwareKeystrokes('Use /browse to load a web page')}</FormHelperText> | ||
</FormControl> | ||
|
||
<FormControl disabled={!mayWork}> | ||
<Checkbox variant='outlined' label='ReAct' checked={inReact} onChange={(event) => setEnableReactTool(event.target.checked)} /> | ||
<Checkbox size='sm' label='ReAct' checked={inReact} onChange={(event) => setEnableReactTool(event.target.checked)} /> | ||
<FormHelperText>Enables loadURL() in ReAct</FormHelperText> | ||
</FormControl> | ||
|
||
{/*<FormControl disabled>*/} | ||
{/* <Checkbox variant='outlined' label='Personas' checked={inPersonas} onChange={(event) => setEnablePersonaTool(event.target.checked)} />*/} | ||
{/* <FormHelperText>Enable loading URLs by Personas</FormHelperText>*/} | ||
{/*</FormControl>*/} | ||
<FormControl disabled> | ||
<Checkbox size='sm' label='Chat with Personas' checked={false} onChange={(event) => setEnablePersonaTool(event.target.checked)} /> | ||
<FormHelperText>Not yet available</FormHelperText> | ||
{/*<FormHelperText>Enable loading URLs by Personas</FormHelperText>*/} | ||
</FormControl> | ||
|
||
</>; | ||
} |
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