mirror of
https://github.com/enricoros/big-AGI.git
synced 2026-05-10 21:50:14 -07:00
Beam: move instructions
This commit is contained in:
@@ -21,7 +21,6 @@ export const SCATTER_RAY_SHOW_DRAG_HANDLE = false;
|
||||
|
||||
// BEAM Gather configuration
|
||||
export const GATHER_COLOR = 'success' as const;
|
||||
export const GATHER_DEBUG_EXECUTION_CHAIN = true;
|
||||
export const GATHER_DEFAULT_TO_FIRST_FUSION = true;
|
||||
export const GATHER_PLACEHOLDER = '📦 ...';
|
||||
export const GATHER_SHOW_SYSTEM_PROMPT = false;
|
||||
|
||||
@@ -8,7 +8,7 @@ import EditRoundedIcon from '@mui/icons-material/EditRounded';
|
||||
import { InlineTextarea } from '~/common/components/InlineTextarea';
|
||||
|
||||
import type { ChatGenerateInstruction } from './instructions/ChatGenerateInstruction';
|
||||
import type { Instruction } from './beam.gather.instructions';
|
||||
import type { Instruction } from './instructions/beam.gather.execution';
|
||||
import { BeamStoreApi, useBeamStore } from '../store-beam.hooks';
|
||||
import { GATHER_SHOW_SYSTEM_PROMPT } from '../beam.config';
|
||||
import { fusionIsEditable } from './beam.gather';
|
||||
|
||||
@@ -19,7 +19,7 @@ import { useScrollToBottom } from '~/common/scroll-to-bottom/useScrollToBottom';
|
||||
import { BEAM_BTN_SX, GATHER_COLOR } from '../beam.config';
|
||||
import { BeamGatherDropdown } from './BeamGatherPaneDropdown';
|
||||
import { BeamStoreApi, useBeamStore } from '../store-beam.hooks';
|
||||
import { FUSION_FACTORIES } from './beam.gather.factories';
|
||||
import { FUSION_FACTORIES } from './instructions/beam.gather.factories';
|
||||
import { beamPaneSx } from '../BeamCard';
|
||||
import { fusionIsFusing, fusionIsUsableOutput } from './beam.gather';
|
||||
import { useModuleBeamStore } from '../store-module-beam';
|
||||
@@ -39,7 +39,7 @@ const gatherPaneSx: SxProps = {
|
||||
boxShadow: `0px 6px 20px -8px rgb(var(--joy-palette-neutral-darkChannel) / 30%)`,
|
||||
[`&.${gatherPaneClasses.ready}`]: {
|
||||
backgroundColor: 'background.popup',
|
||||
boxShadow: `0px 6px 16px -8px rgb(var(--joy-palette-${/*GATHER_COLOR*/ 'neutral'}-darkChannel) / 40%)`,
|
||||
boxShadow: `0px 6px 16px -8px rgb(var(--joy-palette-neutral-darkChannel) / 40%)`,
|
||||
},
|
||||
[`&.${gatherPaneClasses.busy}`]: {
|
||||
animation: `${animationShadowLimey} 2s linear infinite`,
|
||||
|
||||
@@ -5,9 +5,9 @@ import type { StateCreator } from 'zustand/vanilla';
|
||||
import type { DLLMId } from '~/modules/llms/store-llms';
|
||||
|
||||
import type { DMessage } from '~/common/state/store-chats';
|
||||
import { FUSION_FACTORIES } from './beam.gather.factories';
|
||||
import { FUSION_FACTORIES } from './instructions/beam.gather.factories';
|
||||
import { GATHER_DEFAULT_TO_FIRST_FUSION, GATHER_PLACEHOLDER } from '../beam.config';
|
||||
import { gatherStartFusion, gatherStopFusion, Instruction } from './beam.gather.instructions';
|
||||
import { gatherStartFusion, gatherStopFusion, Instruction } from './instructions/beam.gather.execution';
|
||||
|
||||
|
||||
/// Gather Store > BFusion ///
|
||||
@@ -39,7 +39,7 @@ export interface BFusion {
|
||||
fusingInstructionComponent?: React.ReactNode;
|
||||
}
|
||||
|
||||
export const createBFusion = (factoryId: string, instructions: Instruction[]): BFusion => ({
|
||||
const createBFusion = (factoryId: string, instructions: Instruction[]): BFusion => ({
|
||||
// const
|
||||
fusionId: uuidv4(),
|
||||
factoryId,
|
||||
@@ -98,7 +98,7 @@ export const reInitGatherStateSlice = (prevFusions: BFusion[]): GatherStateSlice
|
||||
prevFusions.forEach(gatherStopFusion);
|
||||
|
||||
// fully use new fusions
|
||||
const newFusions = FUSION_FACTORIES.map(spec => spec.factory());
|
||||
const newFusions = FUSION_FACTORIES.map(factory => createBFusion(factory.id, factory.createInstructions()));
|
||||
|
||||
return {
|
||||
gatherLlmId: null, // will be re-set during open() of the Beam Store
|
||||
@@ -177,10 +177,8 @@ export const createGatherSlice: StateCreator<GatherStoreSlice, [], [], GatherSto
|
||||
if (!sourceFusion || !sourceFusionFactory)
|
||||
return;
|
||||
|
||||
const newCustomFusion: BFusion = {
|
||||
...sourceFusionFactory.factory(),
|
||||
factoryId: 'custom', // changes whatever is the source to 'custom', which makes it editable
|
||||
};
|
||||
// create a custom from the source fusion factory
|
||||
const newCustomFusion: BFusion = createBFusion('custom', sourceFusionFactory.createInstructions());
|
||||
|
||||
// replace the only editable fusion with the new custom fusion
|
||||
_set({
|
||||
|
||||
@@ -11,7 +11,7 @@ import { bareBonesPromptMixer } from '~/modules/persona/pmix/pmix';
|
||||
import { DMessage } from '~/common/state/store-chats';
|
||||
import { getUXLabsHighPerformance } from '~/common/state/store-ux-labs';
|
||||
|
||||
import type { BaseInstruction, ExecutionInputState } from '../beam.gather.instructions';
|
||||
import type { BaseInstruction, ExecutionInputState } from './beam.gather.execution';
|
||||
import { GATHER_PLACEHOLDER } from '../../beam.config';
|
||||
import { fusionChatMessageSx } from '../BeamGatherOutput';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { BaseInstruction, ExecutionInputState } from '../beam.gather.instructions';
|
||||
import { GATHER_DEBUG_EXECUTION_CHAIN } from '../../beam.config';
|
||||
import type { BaseInstruction, ExecutionInputState } from './beam.gather.execution';
|
||||
|
||||
import { parseTextToChecklist, UserInputChecklistComponent } from './UserInputChecklistComponent';
|
||||
import { bareBonesPromptMixer } from '~/modules/persona/pmix/pmix';
|
||||
|
||||
@@ -28,8 +28,6 @@ export async function executeUserInputChecklist(
|
||||
|
||||
// if no options, there's an error
|
||||
if (options.length < 2) {
|
||||
if (GATHER_DEBUG_EXECUTION_CHAIN)
|
||||
console.log('No checklist options found:', previousResult);
|
||||
reject(new Error('Oops! It looks like we had trouble understanding the Model. Could you please try again?'));
|
||||
return;
|
||||
}
|
||||
|
||||
+5
-14
@@ -5,10 +5,10 @@ import type { DLLMId } from '~/modules/llms/store-llms';
|
||||
|
||||
import { createDMessage, type DMessage } from '~/common/state/store-chats';
|
||||
|
||||
import type { BFusion, FusionUpdateOrFn } from './beam.gather';
|
||||
import { ChatGenerateInstruction, executeChatGenerate } from './instructions/ChatGenerateInstruction';
|
||||
import { GATHER_DEBUG_EXECUTION_CHAIN, GATHER_PLACEHOLDER } from '../beam.config';
|
||||
import { executeUserInputChecklist, UserInputChecklistInstruction } from './instructions/UserInputChecklistInstruction';
|
||||
import type { BFusion, FusionUpdateOrFn } from '../beam.gather';
|
||||
import { ChatGenerateInstruction, executeChatGenerate } from './ChatGenerateInstruction';
|
||||
import { GATHER_PLACEHOLDER } from '../../beam.config';
|
||||
import { executeUserInputChecklist, UserInputChecklistInstruction } from './UserInputChecklistInstruction';
|
||||
|
||||
|
||||
/// [Asynchronous Instruction Framework] ///
|
||||
@@ -43,7 +43,7 @@ export function gatherStartFusion(
|
||||
) {
|
||||
|
||||
// abort any current fusion
|
||||
const { fusionId, instructions } = initialFusion;
|
||||
const { instructions } = initialFusion;
|
||||
initialFusion.fusingAbortController?.abort();
|
||||
|
||||
// validate preconditions
|
||||
@@ -61,9 +61,6 @@ export function gatherStartFusion(
|
||||
if (!llmId)
|
||||
return onError('No Merge model selected');
|
||||
|
||||
if (GATHER_DEBUG_EXECUTION_CHAIN)
|
||||
console.log('beam.gather: executing instructions', instructions);
|
||||
|
||||
|
||||
// full execution state
|
||||
const inputState: ExecutionInputState = {
|
||||
@@ -122,8 +119,6 @@ export function gatherStartFusion(
|
||||
// Chain completion handlers
|
||||
promiseChain
|
||||
.then(() => {
|
||||
if (GATHER_DEBUG_EXECUTION_CHAIN)
|
||||
console.log('All instructions executed for fusion:', fusionId);
|
||||
onUpdateBFusion({
|
||||
stage: 'success',
|
||||
errorText: undefined,
|
||||
@@ -133,8 +128,6 @@ export function gatherStartFusion(
|
||||
.catch((error) => {
|
||||
// User abort: no need to show an error
|
||||
if (inputState.chainAbortController.signal.aborted) {
|
||||
if (GATHER_DEBUG_EXECUTION_CHAIN)
|
||||
console.log('Fusion aborted:', fusionId);
|
||||
return onUpdateBFusion({
|
||||
stage: 'stopped',
|
||||
errorText: 'Merge Canceled.',
|
||||
@@ -143,8 +136,6 @@ export function gatherStartFusion(
|
||||
}
|
||||
|
||||
// Error handling
|
||||
if (GATHER_DEBUG_EXECUTION_CHAIN)
|
||||
console.error('Error executing instructions:', error, fusionId);
|
||||
onUpdateBFusion({
|
||||
stage: 'error',
|
||||
errorText: 'Issue: ' + (error?.message || error?.toString() || 'Unknown error'),
|
||||
+10
-10
@@ -4,7 +4,7 @@ import CheckBoxOutlinedIcon from '@mui/icons-material/CheckBoxOutlined';
|
||||
import MediationOutlinedIcon from '@mui/icons-material/MediationOutlined';
|
||||
import TableViewRoundedIcon from '@mui/icons-material/TableViewRounded';
|
||||
|
||||
import { BFusion, createBFusion } from './beam.gather';
|
||||
import type { Instruction } from './beam.gather.execution';
|
||||
|
||||
|
||||
interface FusionFactorySpec {
|
||||
@@ -13,7 +13,7 @@ interface FusionFactorySpec {
|
||||
Icon?: React.FunctionComponent;
|
||||
description: string;
|
||||
isDev?: boolean;
|
||||
factory: () => BFusion;
|
||||
createInstructions: () => Instruction[];
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ export const FUSION_FACTORIES: FusionFactorySpec[] = [
|
||||
Icon: CheckBoxOutlinedIcon,
|
||||
description: 'A brainstorming session with AI, where you first pick your favorite ideas from a list it generates, and then the AI combines those picks into a tailored solution.',
|
||||
// description: 'This approach employs a two-stage, interactive process where an AI first generates a checklist of insights from a conversation for user selection, then synthesizes those selections into a tailored, comprehensive response, integrating user preferences with AI analysis and creativity.',
|
||||
factory: () => createBFusion('guided', [
|
||||
createInstructions: () => [
|
||||
{
|
||||
type: 'chat-generate',
|
||||
label: 'Generating Checklist',
|
||||
@@ -77,7 +77,7 @@ Given the user preferences below, synthesize the {{N}} response alternatives abo
|
||||
Ensure the synthesis is coherent, integrating the response alternatives in a clear manner.
|
||||
The final output should reflect a deep understanding of the user's preferences and the conversation's context.`.trim(),
|
||||
},
|
||||
]),
|
||||
],
|
||||
},
|
||||
|
||||
// 2: Fuse
|
||||
@@ -86,7 +86,7 @@ The final output should reflect a deep understanding of the user's preferences a
|
||||
label: 'Fuse',
|
||||
Icon: MediationOutlinedIcon,
|
||||
description: 'AI combines conversation details and various AI-generated ideas into one clear, comprehensive answer, making sense of diverse insights for you.',
|
||||
factory: () => createBFusion('fuse', [
|
||||
createInstructions: () => [
|
||||
{
|
||||
type: 'chat-generate',
|
||||
label: 'Syntesizing Fusion',
|
||||
@@ -103,7 +103,7 @@ Synthesize the perfect response that merges the key insights and provides clear
|
||||
Synthesize the perfect cohesive response to my last message that merges the collective intelligence of the {{N}} alternatives above.`.trim(),
|
||||
// evalPrompt: `Evaluate the synthesized response provided by the AI synthesizer. Consider its relevance to the original query, the coherence of the integration of different perspectives, and its completeness in addressing the objectives or questions raised throughout the conversation.`.trim(),
|
||||
},
|
||||
]),
|
||||
],
|
||||
},
|
||||
|
||||
// 3: Eval
|
||||
@@ -113,7 +113,7 @@ Synthesize the perfect cohesive response to my last message that merges the coll
|
||||
Icon: TableViewRoundedIcon,
|
||||
description: 'Analyzes and ranks AI responses, offering a clear, comparative overview to support your choice of answer.',
|
||||
isDev: true,
|
||||
factory: () => createBFusion('eval', [
|
||||
createInstructions: () => [
|
||||
{
|
||||
type: 'chat-generate',
|
||||
label: 'Evaluation',
|
||||
@@ -147,7 +147,7 @@ Complete this table to offer a structured and detailed comparison of the {{N}} o
|
||||
|
||||
Only work with the provided {{N}} responses. Begin with listing the criteria.`.trim(),
|
||||
},
|
||||
]),
|
||||
],
|
||||
},
|
||||
|
||||
// 4: Custom (this may be overwritten by other factories, if editing those)
|
||||
@@ -156,7 +156,7 @@ Only work with the provided {{N}} responses. Begin with listing the criteria.`.t
|
||||
label: 'Custom',
|
||||
// Icon: BuildCircleOutlinedIcon,
|
||||
description: 'Define your own fusion prompt.',
|
||||
factory: () => createBFusion('custom', [
|
||||
createInstructions: () => [
|
||||
{
|
||||
type: 'chat-generate',
|
||||
label: 'Executing Your Merge Strategy',
|
||||
@@ -169,7 +169,7 @@ Based on the {{N}} alternatives provided, synthesize a single, comprehensive res
|
||||
// userPrompt: 'Answer again using the best elements from the {{N}} answers above. Be truthful, honest, reliable.',
|
||||
// userPrompt: 'Based on the {{N}} alternatives provided, synthesize a single, comprehensive response that effectively addresses the query or problem at hand.',
|
||||
},
|
||||
]),
|
||||
],
|
||||
},
|
||||
|
||||
// ... future ...
|
||||
Reference in New Issue
Block a user