web refactoring

This commit is contained in:
austin 2024-12-30 14:33:13 -05:00
parent 524c37895b
commit ba5caca8e7
17 changed files with 155 additions and 75 deletions

View File

@ -1,31 +0,0 @@
{
"tag" : "bert",
"nodes" : {
"0" : {
"id" : 0,
"name" : "Bert"
},
"9" : {
"id" : 9,
"name" : "Bert's Hat"
}
},
"relations" : {
"0" : {
"id" : 0,
"name" : "nameOf",
"parent" : 0,
"child" : 2,
"childWeb" : "root"
},
"1" : {
"id" : 1,
"name" : "qualiaOf",
"parent" : 1,
"parentWeb" : "color",
"child" : 9
}
},
"children" : [
]
}

View File

@ -0,0 +1,58 @@
{
"tag" : "bert",
"nodes" : {
"0" : {
"id" : 0,
"name" : "Bert"
},
"9" : {
"id" : 9,
"name" : "Bert's Hat"
}
},
"relations" : {
"0" : {
"comment" : "Bert is the name of the ai's sense of self",
"id" : 0,
"name" : "nameOf",
"parent" : 0,
"child" : 2,
"childWeb" : "root"
},
"1" : {
"comment" : "The color of bert's hat is blue",
"id" : 1,
"name" : "qualiaOf",
"parent" : 1,
"parentWeb" : "color",
"child" : 9
},
"2" : {
"comment" : "'Bert' is an instance of a name",
"id" : 2,
"name" : "instanceOf",
"parent" : 0,
"parentWeb" : "name",
"child" : 0
},
"3" : {
"comment" : "The self possess bert's hat",
"id" : 3,
"name" : "possessionOf",
"parent" : 2,
"parentWeb" : "root",
"child" : 9
},
"4" : {
"comment" : "Bert's hat is an instance of a hat",
"id" : 4,
"name" : "instanceOf",
"parent" : 8,
"parentWeb" : "root",
"child" : 9
}
},
"children" : [
"./data/webs/root.json"
]
}

View File

@ -0,0 +1,6 @@
{
"tag" : "convo1",
"children" : [
"./data/webs/characters/bert.json"
]
}

View File

@ -0,0 +1,6 @@
{
"tag": "linguistics",
"children" : [
"./data/webs/linguistics/name.json"
]
}

View File

@ -0,0 +1,19 @@
{
"tag": "name",
"nodes" : {
"0" : {
"id" : 0,
"name" : "name"
}
},
"relations" : {
"0" : {
"comment" : "name is an instance of a concept",
"id" : 0,
"name" : "instanceOf",
"parent" : "0",
"parentWeb" : "concept",
"child" : 0
}
}
}

View File

@ -0,0 +1,12 @@
{
"tag": "concept",
"nodes" : {
"0" : {
"id" : 0,
"name" : "concept"
}
},
"anchors" : {
"concept" : 0
}
}

View File

@ -0,0 +1,6 @@
{
"tag": "philosophy",
"children" : [
"./data/webs/philosophy/concept.json"
]
}

View File

@ -3,11 +3,11 @@
"nodes" : { "nodes" : {
"0" : { "0" : {
"id" : 0, "id" : 0,
"name" : "Color" "name" : "color"
}, },
"1" : { "1" : {
"id" : 1, "id" : 1,
"name" : "Blue" "name" : "blue"
} }
}, },
"relations" : { "relations" : {

View File

@ -1,10 +1,6 @@
{ {
"tag" : "root", "tag" : "root",
"nodes" : { "nodes" : {
"1" : {
"id" : 1,
"name" : "Name"
},
"2" : { "2" : {
"id" : 2, "id" : 2,
"name" : "Self" "name" : "Self"
@ -31,72 +27,53 @@
}, },
"8" : { "8" : {
"id" : 8, "id" : 8,
"name" : "Hat" "name" : "hat"
},
"10" : {
"id" : 10,
"name" : "concept"
} }
}, },
"relations" : { "relations" : {
"1" : { "1" : {
"comment" : "The self is an instance of a person",
"id" : 1, "id" : 1,
"name" : "instanceOf", "name" : "instanceOf",
"parent" : 3, "parent" : 3,
"child" : 2 "child" : 2
}, },
"2" : {
"id" : 2,
"name" : "instanceOf",
"parent" : 1,
"child" : 0,
"childWeb" : "bert"
},
"3" : { "3" : {
"comment" : "The other is an instance of a person",
"id" : 3, "id" : 3,
"name" : "instanceOf", "name" : "instanceOf",
"parent" : 3, "parent" : 3,
"child" : 4 "child" : 4
}, },
"4" : { "4" : {
"comment" : "The current conversation has the other as a participant",
"id" : 4, "id" : 4,
"name" : "participantOf", "name" : "participantOf",
"parent" : 7, "parent" : 7,
"child" : 4 "child" : 4
}, },
"5" : { "5" : {
"comment" : "The current conversation has the self as a participant",
"id" : 5, "id" : 5,
"name" : "participantOf", "name" : "participantOf",
"parent" : 7, "parent" : 7,
"child" : 2 "child" : 2
}, },
"6" : {
"id" : 6,
"name" : "possessionOf",
"parent" : 2,
"child" : 9,
"childWeb" : "bert"
},
"7" : {
"id" : 7,
"name" : "instanceOf",
"parent" : 8,
"child" : 9,
"childWeb" : "bert"
},
"8" : { "8" : {
"comment" : "hat is an instance of a concept",
"id" : 8, "id" : 8,
"name" : "instanceOf", "name" : "instanceOf",
"parent" : 10, "parent" : 0,
"parentWeb" : "concept",
"child" : 8 "child" : 8
} }
}, },
"anchors" : { "anchors" : {
"self" : 2, "self" : 2
"concept" : 10
}, },
"children" : [ "children" : [
"./data/webs/qualia/qualia.json", "./data/webs/linguistics/linguistics.json",
"./data/webs/bert.json" "./data/webs/philosophy/philosophy.json",
"./data/webs/qualia/qualia.json"
] ]
} }

View File

@ -1,6 +1,6 @@
{ {
"tag" : "root", "tag" : "web",
"children" : [ "children" : [
"./data/webs/root.json" "./data/webs/conversations/convo1.json"
] ]
} }

View File

@ -0,0 +1,11 @@
Is it ethical to test a conversational AI?
Essentially becomes "are you killing a person every time you shut down the AI?"
Essentially becomes "is this AI a person?"
Thought experiment:
Lets say there was a specific chunk of the brain that stored all memories.
Taking that chunk out of a person's brain probably isn't great.
If you take that chunk of brain out of a person and put it into a brain that was missing that chunk, have you killed them?
Leaning towards no. Same concept as if you replaced a part of someone's brain with a machine with the same data+function.
Ergo, as long as I'm not deleting memories I don't think it's outright murder.
Still kinda murky tho

3
docs/style_guide.txt Normal file
View File

@ -0,0 +1,3 @@
1. concepts should all have their node names be lower case (ie "color" not "Color")

View File

@ -90,7 +90,12 @@ public class KnowledgeWeb {
} else { } else {
lookupId = "node-" + relation.webTag + relation.parent; lookupId = "node-" + relation.webTag + relation.parent;
} }
int nodeId = crossRelationLookupMap.get(lookupId); int nodeId = 0;
try {
nodeId = crossRelationLookupMap.get(lookupId);
} catch(NullPointerException ex){
throw new Error("Failed to find node link " + lookupId + " in relation in web " + relation.webTag);
}
relation.parent = nodeId; relation.parent = nodeId;
if(relation.childWeb != null){ if(relation.childWeb != null){
@ -139,7 +144,10 @@ public class KnowledgeWeb {
* @return Merged knowledge web * @return Merged knowledge web
*/ */
private static KnowledgeWeb recursivelyLoad(Map<String,Integer> crossRelationLookupMap, List<String> foundTags, String startPoint){ private static KnowledgeWeb recursivelyLoad(Map<String,Integer> crossRelationLookupMap, List<String> foundTags, String startPoint){
KnowledgeWeb rVal = FileUtils.loadObjectFromFile(new File(startPoint), KnowledgeWeb.class);; KnowledgeWeb rVal = FileUtils.loadObjectFromFile(new File(startPoint), KnowledgeWeb.class);
if(rVal == null){
throw new Error("Failed to load file! " + startPoint);
}
if(foundTags.contains(rVal.getTag())){ if(foundTags.contains(rVal.getTag())){
throw new UnsupportedOperationException("Trying to load two webs with the same tag! " + rVal.getTag()); throw new UnsupportedOperationException("Trying to load two webs with the same tag! " + rVal.getTag());
} }

View File

@ -44,6 +44,11 @@ public class Relation {
*/ */
String childWeb; String childWeb;
/**
* An optional comment applied to the relation
*/
String comment;
/** /**
* Constructor * Constructor
* @param name The name of the relation * @param name The name of the relation

View File

@ -14,7 +14,7 @@ public class NameQueryFilter {
* Filters a set of nodes to a singleton based on a name * Filters a set of nodes to a singleton based on a name
*/ */
public static Node withNodeName(List<Node> nodes, String name){ public static Node withNodeName(List<Node> nodes, String name){
List<Node> filtered = nodes.stream().filter(node -> !node.getName().equals(name)).collect(Collectors.toList()); List<Node> filtered = nodes.stream().filter(node -> node.getName().equals(name)).collect(Collectors.toList());
if(filtered.size() != 1){ if(filtered.size() != 1){
throw new UnsupportedOperationException("TODO: handle ambiguous case"); throw new UnsupportedOperationException("TODO: handle ambiguous case");
} }

View File

@ -15,7 +15,7 @@ public class AnswerTests {
public void testAnswerQuery(){ public void testAnswerQuery(){
Globals.init("./data/webs/test/web.json"); Globals.init("./data/webs/test/web.json");
Quote result = ConvAI.simFrame("What color is your hat?"); Quote result = ConvAI.simFrame("What color is your hat?");
assertEquals(result.getRaw().contains("Blue"), true); assertEquals(result.getRaw().contains("blue"), true);
} }
} }

View File

@ -24,7 +24,7 @@ public class QueryTests {
Quote response = ConvAI.simFrame("What color is your hat?"); Quote response = ConvAI.simFrame("What color is your hat?");
boolean responseContainsBlue = response.getRaw().contains("Blue"); boolean responseContainsBlue = response.getRaw().contains("blue");
assertEquals(responseContainsBlue, true); assertEquals(responseContainsBlue, true);
} }