Skip to content

Commit

Permalink
Beam: recall importing rays
Browse files Browse the repository at this point in the history
  • Loading branch information
enricoros committed May 16, 2024
1 parent e513b42 commit 454a425
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/modules/beam/BeamView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function BeamView(props: {
} = props.beamStore.getState();
const {
/* root */ inputHistory, inputIssues, inputReady,
/* scatter */ isScattering, raysReady,
/* scatter */ hadImportedRays, isScattering, raysReady,
/* gather (composite) */ canGather,
} = useBeamStore(props.beamStore, useShallow(state => ({
// input
Expand Down Expand Up @@ -171,6 +171,7 @@ export function BeamView(props: {
beamStore={props.beamStore}
isMobile={props.isMobile}
rayIds={rayIds}
hadImportedRays={hadImportedRays}
onIncreaseRayCount={handleRayIncreaseCount}
// linkedLlmId={currentGatherLlmId}
/>
Expand Down
3 changes: 2 additions & 1 deletion src/modules/beam/scatter/BeamRay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ function RayControls(props: {

export function BeamRay(props: {
beamStore: BeamStoreApi,
isRemovable: boolean
hadImportedRays: boolean
isRemovable: boolean,
rayId: string,
rayIndexWeak: number,
// linkedLlmId: DLLMId | null,
Expand Down
2 changes: 2 additions & 0 deletions src/modules/beam/scatter/BeamRayGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const rayGridMobileSx: SxProps = {

export function BeamRayGrid(props: {
beamStore: BeamStoreApi,
hadImportedRays: boolean
isMobile: boolean,
onIncreaseRayCount: () => void,
rayIds: string[],
Expand All @@ -44,6 +45,7 @@ export function BeamRayGrid(props: {
key={'ray-' + rayId}
rayIndexWeak={index}
beamStore={props.beamStore}
hadImportedRays={props.hadImportedRays}
isRemovable={raysCount > SCATTER_RAY_MIN}
rayId={rayId}
// linkedLlmId={props.linkedLlmId}
Expand Down
3 changes: 3 additions & 0 deletions src/modules/beam/scatter/beam.scatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ export function rayIsImported(ray: BRay | null): boolean {
interface ScatterStateSlice {

rays: BRay[];
hadImportedRays: boolean;

// derived state
isScattering: boolean; // true if any ray is scattering at the moment
Expand All @@ -148,6 +149,7 @@ export const reInitScatterStateSlice = (prevRays: BRay[]): ScatterStateSlice =>
return {
// (remember) keep the same quantity of rays and same llms
rays: prevRays.map(prevRay => createBRay(prevRay.rayLlmId)),
hadImportedRays: false,

isScattering: false,
raysReady: 0,
Expand Down Expand Up @@ -238,6 +240,7 @@ export const createScatterSlice: StateCreator<RootStoreSlice & ScatterStoreSlice
// append the other rays (excluding the ones to remove)
...rays.filter((ray) => !raysToRemove.includes(ray)),
],
hadImportedRays: messages.length > 0,
});
_storeLastScatterConfig();
_syncRaysStateToScatter();
Expand Down
3 changes: 2 additions & 1 deletion src/modules/beam/store-beam-vanilla.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const createRootSlice: StateCreator<BeamStore, [], [], RootStoreSlice> = (_set,


open: (chatHistory: Readonly<DMessage[]>, initialChatLlmId: DLLMId | null, callback: BeamSuccessCallback) => {
const { isOpen: wasAlreadyOpen, terminateKeepingSettings, loadBeamConfig, setRayLlmIds, setCurrentGatherLlmId } = _get();
const { isOpen: wasAlreadyOpen, terminateKeepingSettings, loadBeamConfig, hadImportedRays, setRayLlmIds, setCurrentGatherLlmId } = _get();

// reset pending operations
terminateKeepingSettings();
Expand All @@ -89,6 +89,7 @@ const createRootSlice: StateCreator<BeamStore, [], [], RootStoreSlice> = (_set,
onSuccessCallback: callback,

// rays already reset
hadImportedRays,

// update the model only if the dialog was not already open
...(!wasAlreadyOpen && initialChatLlmId && {
Expand Down

0 comments on commit 454a425

Please sign in to comment.