Skip to content

Commit

Permalink
Merge pull request #162 from Phuire-Research/UI
Browse files Browse the repository at this point in the history
UI
  • Loading branch information
REllEK-IO authored Nov 17, 2023
2 parents 6f74af2 + 7020661 commit b187942
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 28 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ User Interface Proof of Concept and Demo: [logixUX](https://github.com/Phuire-Re
*Note if you notice a strange any capitalization, this is a new format that is being formalized as conceptual logic. Where we capitalize not just people, places, and things, but concepts as well. In addition, there was no generative intelligence used in the creation of this framework or documentation. This is **100% hand written.***

## Change Log ![Tests](https://github.com/Phuire-Research/Stratimux/actions/workflows/node.js.yml/badge.svg)
### 11/17/23
* selectSlice now performing deep selections.
### 11/15/23
* Action Payloads must extend type: Record<string, unknown>
* This change is to provide a guarantee of advanced functionality in the current UI Proof of Concept.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "stratimux",
"license": "GPL-3.0",
"version": "0.0.73",
"version": "0.0.74",
"description": "Unified Turing Machine",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
34 changes: 11 additions & 23 deletions src/model/selector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,37 +105,25 @@ export function selectSlice<T>(
return undefined;
}
}

const keys = selector.stateKeys.split(' ');
if (concept === undefined) {return undefined;}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const cast = concept.state as Record<string, any>;
const existsKeys = Object.keys(cast);
let exists = false;
existsKeys.forEach(key => {key === keys[0] ? exists = true : null;});
if (!exists) {
return undefined;
}
if (keys.length === 1) {
return cast[keys[0]] as T;
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let target: Record<string, any> = cast[keys.shift() as string];
let finalKey = '';
for (const [i, key] of keys.entries()) {
let aspectExists = false;
const aspectExistsKeys = Object.keys(target);
aspectExistsKeys.forEach(_key => {_key === key ? aspectExists = true : null;});
if (!aspectExists) {
return undefined;
}
if (i !== keys.length - 1) {
target = target[key];
let previous = cast;
for (const k of keys) {
if (typeof previous === 'object' && previous[k] !== undefined) {
previous = previous[k];
exists = true;
} else {
finalKey = key;
exists = false;
}
}
return target[finalKey] as T;
if (exists) {
return previous as T;
} else {
return undefined;
}
}

export function selectConcept(concepts: Concepts, name: string): Concept {
Expand Down
47 changes: 47 additions & 0 deletions src/test/selectDataSlice.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Concepts, createConcept } from '../model/concept';
import { KeyedSelector, createUnifiedKeyedSelector, selectSlice } from '../model/selector';

export type BaseDataSet = {
prompt: string,
content: string,
}

export type NamedDataSet = {
name: string,
dataSet: BaseDataSet[]
}

export const generateBaseDataSetEntry = (): BaseDataSet => {
return {
prompt: '#insert prompt#',
content: '#insert chosen output#',
};
};

export const generateDefaultNamedDataSet = (name: string): NamedDataSet => ({
name,
dataSet: [generateBaseDataSetEntry()]
});

test('userInterfaceBindingsToString', (done) => {
const simulated = {
trainingData: [generateDefaultNamedDataSet('something')],
shallow: true,
};
const experiment = createConcept(
'experiment',
simulated
);
const concepts: Concepts = {
1: experiment
};
const entry = generateBaseDataSetEntry();
const selector = createUnifiedKeyedSelector(concepts, 1, 'trainingData 0 dataSet 0 prompt') as KeyedSelector;
const shallow = createUnifiedKeyedSelector(concepts, 1, 'shallow') as KeyedSelector;
const getUndefined = {...selector};
getUndefined.conceptName = 'something';
expect(selectSlice(concepts, selector)).toBe(entry.prompt);
expect(selectSlice(concepts, shallow)).toBe(true);
expect(selectSlice(concepts, getUndefined)).toBe(undefined);
done();
});
11 changes: 7 additions & 4 deletions src/test/unifiedSelector.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ test('Unified Selector Test', (done) => {
createCounterConcept()
], true, true);
const plan = axium.stage('Plan: Counter Selector', [
(concepts, dispatch) => {
expect(selectSlice(concepts, updateUnifiedKeyedSelector(concepts, 1, counterSelectCount) as KeyedSelector)).toBe(0);
expect(selectSlice(concepts, createConceptKeyedSelector(concepts, counterName, counterSelectCount) as KeyedSelector)).toBe(0);
expect(selectSlice(concepts, createUnifiedKeyedSelector<Counter>(concepts, 1, 'count') as KeyedSelector)).toBe(0);
(concepts, _) => {
const updated = updateUnifiedKeyedSelector(concepts, 1, counterSelectCount) as KeyedSelector;
const concept = createConceptKeyedSelector(concepts, counterName, counterSelectCount) as KeyedSelector;
const unified = createUnifiedKeyedSelector<Counter>(concepts, 1, 'count') as KeyedSelector;
expect(selectSlice(concepts, updated)).toBe(0);
expect(selectSlice(concepts, concept)).toBe(0);
expect(selectSlice(concepts, unified)).toBe(0);
setTimeout(() => done(), 0);
plan.conclude();
},
Expand Down

0 comments on commit b187942

Please sign in to comment.