Skip to content

Commit

Permalink
Refactor (#12)
Browse files Browse the repository at this point in the history
* Break up structure with directories
* Split out Option
* Option card areas are themselves toggles
  • Loading branch information
cybermaggedon authored Oct 12, 2024
1 parent a4e9eb9 commit 9ac6f26
Show file tree
Hide file tree
Showing 17 changed files with 129 additions and 59 deletions.
22 changes: 16 additions & 6 deletions src/simple-editor/Configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import React from 'react';
import { Typography, Box } from '@mui/material';
import { Tabs, Tab } from '@mui/material';

import ParamsForm from './ParamsForm';
import AdvancedOptions from './AdvancedOptions';
import Deployment from './Deployment';
import ParamsForm from './model-params/ParamsForm';
import Options from './options/Options';
import Deployment from './deployment/Deployment';

import { usePromptsStore } from './state/Prompts';
import {
Expand All @@ -16,7 +16,7 @@ import {
} from './state/Options';
import { useDeploymentStore } from './state/Deployment';

import Prompt from './Prompt';
import Prompt from './options/Prompt';

interface TabPanelProps {
children?: React.ReactNode;
Expand Down Expand Up @@ -156,11 +156,21 @@ const Configuration: React.FC = () => {

<CustomTabPanel value={value} tabId="more">

<Box sx={{ mb: 2}}>
<Typography variant="h5" component="h2" gutterBottom>
Additional configuration
Additional configuration
</Typography>

<AdvancedOptions/>
<Typography variant="body">
Listed here are additional configuraton options and
add-ons, all optional. Click on additional
configuration options to include in the configuration,
further configuration options may appear on separate
configuration tabs.
</Typography>
</Box>

<Options/>

</CustomTabPanel>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import {
} from '@mui/material';
import { Close } from '@mui/icons-material';

import { generateConfig } from './generate-config';
import { useModelParamsStore } from './state/ModelParams';
import { usePromptsStore } from './state/Prompts';
import { useDeploymentStore } from './state/Deployment';
import { useOptionsStore } from './state/Options';
import { generateConfig } from '../generate-config';
import { useModelParamsStore } from '../state/ModelParams';
import { usePromptsStore } from '../state/Prompts';
import { useDeploymentStore } from '../state/Deployment';
import { useOptionsStore } from '../state/Options';

const Generating = () => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';

import { Box } from '@mui/material';

//import { useModelParamsStore } from './state/ModelParams';
//import { useModelParamsStore } from '../state/ModelParams';

import DeploymentModel from './DeploymentModel';
import DeploymentConfig from './DeploymentConfig';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import React from 'react';

import { useDeploymentStore } from './state/Deployment';
import { useDeploymentStore } from '../state/Deployment';

import ConfigGeneration from './ConfigGeneration';
import PreparedConfig from './PreparedConfig';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Typography, Paper, Box, Stack,
} from '@mui/material';

import { useModelParamsStore } from './state/ModelParams';
import { useModelParamsStore } from '../state/ModelParams';

const getInstructions = (model : string) => {
if (model == "claude") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {

import { Check } from '@mui/icons-material';

import { useModelParamsStore } from './state/ModelParams';
import { useDeploymentStore } from './state/Deployment';
import { useModelParamsStore } from '../state/ModelParams';
import { useDeploymentStore } from '../state/Deployment';

const PreparedConfig = () => {

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import Chunker from './Chunker';
import ModelDeployment from './ModelDeployment';
import ModelParameters from './ModelParameters';

import { useModelParamsStore } from './state/ModelParams';
import { useDeploymentStore } from './state/Deployment';
import { useModelParamsStore } from '../state/ModelParams';
import { useDeploymentStore } from '../state/Deployment';

import modelsRaw from './models.json';
const models = modelsRaw as { [ix : string ] : string[] };
Expand Down
File renamed without changes.
File renamed without changes.
97 changes: 97 additions & 0 deletions src/simple-editor/options/Option.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@

import React from 'react';

import {
Card, CardHeader, CardContent, CardActions, CardActionArea
} from '@mui/material';
import { Typography, ToggleButton, ToggleButtonGroup } from '@mui/material';
import { Check, } from '@mui/icons-material';
import { blue } from '@mui/material/colors';

const Option = ({enabled, onChange, avatar, title, content} : {
enabled : boolean;
onChange : () => void,
avatar : any;
title : string;
content : any;
}) => {

const Header = () => {

if (enabled) {
return (
<CardHeader
sx={{
backgroundColor: blue[200]
}}
avatar={avatar}
title={title}
subheader={
<Typography variant="body">
active
</Typography>
}
/>
);
} else {
return (
<CardHeader
avatar={avatar}
title={title}
subheader={
<Typography variant="body">
available
</Typography>
}
/>
);
}

}

const Content = () => {

if (enabled) {
return (
<CardContent sx={{
height: '4rem', backgroundColor: blue[200]
}}>
<Typography
variant="body2"
sx={{ fontSize: 12 }}
>
{content}
</Typography>
</CardContent>
);
} else {
return (
<CardContent sx={{height: '4rem'}}>
<Typography
variant="body2"
sx={{ fontSize: 12 }}
>
{content}
</Typography>
</CardContent>
);
}

}

return (
<Card sx={{ width: '16rem' }}>
<CardActionArea onClick={() => onChange()}>
<Header
sx={{ backgroundColor: "primary.dark", color: "primary.contrastText" }}
avatar={avatar}
title={title}
/>
<Content/>
</CardActionArea>
</Card>
);
};

export default Option;

Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@

import React from 'react';

import { Typography, ToggleButton } from '@mui/material';
import { Card, CardHeader, CardContent, CardActions } from '@mui/material';
import { Stack } from '@mui/material';
import {
Psychology,
Check,
// Spoke,
// Plumbing,
// Engineering,
Expand All @@ -16,13 +12,15 @@ import {
// MonitorHeart,
// Polyline,
} from '@mui/icons-material';
import { useDeploymentStore } from './state/Deployment';
import { useDeploymentStore } from '../state/Deployment';

import {
useOptionsStore, DEFINITIONS_PROMPT, RELATIONSHIPS_PROMPT,
TOPICS_PROMPT, KNOWLEDGE_QUERY_PROMPT, DOCUMENT_QUERY_PROMPT,
ROWS_PROMPT,
} from './state/Options';
} from '../state/Options';

import Option from './Option';

const ParamsForm: React.FC = ({
}) => {
Expand Down Expand Up @@ -81,41 +79,6 @@ const ParamsForm: React.FC = ({
set(ROWS_PROMPT, !rows);
};

const Option = ({enabled, onChange, avatar, title, content} : {
enabled : boolean;
onChange : () => void,
avatar : any;
title : string;
content : any;
}) => {
return (
<Card sx={{ width: '16rem' }}>
<CardHeader
avatar={avatar}
title={title}
/>
<CardContent>
<Typography
variant="body2"
sx={{ fontSize: 12 }}
>
{content}
</Typography>
</CardContent>
<CardActions>
<ToggleButton
value="check"
selected={enabled}
color="primary"
onChange={() => onChange()}
>
<Check/>
</ToggleButton>
</CardActions>
</Card>
);
};

return (
<>

Expand Down
File renamed without changes.

0 comments on commit 9ac6f26

Please sign in to comment.