forked from enricoros/big-AGI
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'enricoros:main' into main
- Loading branch information
Showing
37 changed files
with
1,428 additions
and
779 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import * as React from 'react'; | ||
|
||
import { AppBeam } from '../../src/apps/beam/AppBeam'; | ||
|
||
import { withLayout } from '~/common/layout/withLayout'; | ||
|
||
|
||
export default function BeamPage() { | ||
return withLayout({ type: 'optima' }, <AppBeam />); | ||
} |
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,84 @@ | ||
import * as React from 'react'; | ||
|
||
import { Box, Button, Typography } from '@mui/joy'; | ||
|
||
import { useModelsStore } from '~/modules/llms/store-llms'; | ||
|
||
import { BeamView } from '~/common/beam/BeamView'; | ||
import { BeamStoreApi, createBeamStore, useBeamStore } from '~/common/beam/store-beam'; | ||
import { createDConversation, createDMessage, DConversation, DMessage } from '~/common/state/store-chats'; | ||
import { useIsMobile } from '~/common/components/useMatchMedia'; | ||
import { usePluggableOptimaLayout } from '~/common/layout/optima/useOptimaLayout'; | ||
|
||
|
||
function initTestConversation(): DConversation { | ||
const conversation = createDConversation(); | ||
conversation.messages.push(createDMessage('system', 'You are a helpful assistant.')); | ||
conversation.messages.push(createDMessage('user', 'Hello, who are you?')); | ||
return conversation; | ||
} | ||
|
||
function initTestBeam(messages: DMessage[]): BeamStoreApi { | ||
const beamStore = createBeamStore(); | ||
beamStore.getState().open(messages, useModelsStore.getState().chatLLMId); | ||
return beamStore; | ||
} | ||
|
||
|
||
export function AppBeam() { | ||
|
||
// state | ||
const conversation = React.useRef<DConversation>(initTestConversation()); | ||
const beamStoreApi = React.useRef(initTestBeam(conversation.current.messages)).current; | ||
const [showDebug, setShowDebug] = React.useState(false); | ||
|
||
// external state | ||
const isMobile = useIsMobile(); | ||
const beamStore = useBeamStore(beamStoreApi, state => state); | ||
|
||
// layout | ||
usePluggableOptimaLayout(null, React.useMemo(() => <> | ||
{/* button to toggle debug info */} | ||
<Button size='sm' variant='plain' color='neutral' onClick={() => setShowDebug(on => !on)}> | ||
{showDebug ? 'Hide' : 'Show'} debug | ||
</Button> | ||
|
||
{/* 'open' */} | ||
<Button size='sm' variant='plain' color='neutral' onClick={() => { | ||
conversation.current = initTestConversation(); | ||
beamStoreApi.getState().open(conversation.current.messages, useModelsStore.getState().chatLLMId); | ||
}}> | ||
.open | ||
</Button> | ||
|
||
{/* 'close' */} | ||
<Button size='sm' variant='plain' color='neutral' onClick={() => beamStoreApi.getState().close()}> | ||
.close | ||
</Button> | ||
</>, [beamStoreApi, showDebug]), null, 'AppBeam'); | ||
|
||
return ( | ||
<Box sx={{ flexGrow: 1, overflowY: 'auto', position: 'relative' }}> | ||
|
||
<BeamView | ||
beamStore={beamStoreApi} | ||
isMobile={isMobile} | ||
sx={{ height: '100%' }} | ||
/> | ||
|
||
{showDebug && ( | ||
<Typography level='body-xs' sx={{ | ||
whiteSpace: 'pre', | ||
position: 'absolute', | ||
inset: 0, | ||
zIndex: 1 /* debug on top of BeamView */, | ||
backdropFilter: 'blur(8px)', | ||
padding: '1rem', | ||
}}> | ||
{JSON.stringify({ conversationId: conversation.current.id, beamStore }, null, 2)} | ||
</Typography> | ||
)} | ||
|
||
</Box> | ||
); | ||
} |
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.
4041962
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
hi-zarina – ./
hi.zarina.io
hi-zarina-icras-projects.vercel.app
big-agi-tan.vercel.app
hi-zarina-git-main-icras-projects.vercel.app