diff --git a/EdgeChain/src/main/java/com/application/project/CoT/ProblemDecomposer.java b/EdgeChain/src/main/java/com/application/project/CoT/ProblemDecomposer.java new file mode 100644 index 000000000..f16efe9e4 --- /dev/null +++ b/EdgeChain/src/main/java/com/application/project/CoT/ProblemDecomposer.java @@ -0,0 +1,18 @@ +public class ProblemDecomposer { + public List decomposeProblem(Problem problem) { + + List subproblems = new ArrayList<>(); + + // Logic to decompose the problem into subproblems + // Assume the problem has a list of elements, and we want to decompose it into individual + // subproblems for each element + List elements = problem.getElements(); + + for (Element element : elements) { + Subproblem subproblem = new Subproblem(element); + subproblems.add(subproblem); + } + + return subproblems; + } +} diff --git a/EdgeChain/src/main/java/com/application/project/CoT/SocraticCoT.java b/EdgeChain/src/main/java/com/application/project/CoT/SocraticCoT.java new file mode 100644 index 000000000..552fce8ae --- /dev/null +++ b/EdgeChain/src/main/java/com/application/project/CoT/SocraticCoT.java @@ -0,0 +1,22 @@ +public class SocraticCoT { + private ProblemDecomposer problemDecomposer; + private SubproblemSolver subproblemSolver; + + public SocraticCoT() { + problemDecomposer = new ProblemDecomposer(); + subproblemSolver = new SubproblemSolver(); + } + + public Solution solveProblem(Problem problem) { + List subproblems = problemDecomposer.decomposeProblem(problem); + Solution finalSolution = new Solution(); + + for (Subproblem subproblem : subproblems) { + Solution subproblemSolution = subproblemSolver.solveSubproblem(subproblem); + // Logic to integrate subproblem solutions into the final solution + finalSolution.merge(subproblemSolution); + } + + return finalSolution; + } +} diff --git a/EdgeChain/src/main/java/com/application/project/CoT/SubproblemSolver.java b/EdgeChain/src/main/java/com/application/project/CoT/SubproblemSolver.java new file mode 100644 index 000000000..d73bdd6bc --- /dev/null +++ b/EdgeChain/src/main/java/com/application/project/CoT/SubproblemSolver.java @@ -0,0 +1,23 @@ +public class SubproblemSolver { + public Solution solveSubproblem(Subproblem subproblem) { + + Solution subproblemSolution = new Solution(); + + // Logic to solve the subproblem and update the subproblem solution + // Assume the subproblem contains a single element, and we want to perform some operation on it + Element element = subproblem.getElement(); + OperationResult result = performOperation(element); + subproblemSolution.addResult(result); + + return subproblemSolution; + } + + private OperationResult performOperation(Element element) { + // Logic to perform the operation on the element and return the result + + OperationResult result = new OperationResult(); + // Perform the operation and update the result + + return result; + } +} diff --git a/EdgeChain/src/main/java/com/application/project/DemoApplication.java b/EdgeChain/src/main/java/com/application/project/DemoApplication.java index d168fda17..e449e82a3 100644 --- a/EdgeChain/src/main/java/com/application/project/DemoApplication.java +++ b/EdgeChain/src/main/java/com/application/project/DemoApplication.java @@ -7,5 +7,13 @@ public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); + + SocraticCoT socraticCoT = new SocraticCoT(); + Problem problem = new Problem(); + + Solution solution = socraticCoT.solveProblem(problem); + + // Process and use the final solution as needed + solution.display(); } } diff --git a/EdgeChain/src/main/java/com/application/project/parser/Scratchpad.java b/EdgeChain/src/main/java/com/application/project/parser/Scratchpad.java index b52cce2a6..812ad8cd1 100644 --- a/EdgeChain/src/main/java/com/application/project/parser/Scratchpad.java +++ b/EdgeChain/src/main/java/com/application/project/parser/Scratchpad.java @@ -43,6 +43,27 @@ public String getActionContent() { return actionContent; } + // Getter and Setter for scratchpadList + public void setScratchpadList(List scratchpadList) { + this.scratchpadList = scratchpadList; + } + + public List getScratchpadList() { + return scratchpadList; + } + + // Method to remove an entry + public void removeEntry(int index) { + if (index >= 0 && index < scratchpadList.size()) { + scratchpadList.remove(index); + } + } + + // Method to add a new entry + public void addEntry(String entry) { + scratchpadList.add(entry); + } + // Method to replace the content of an action by the given index with a new string called // wikiContentForAction public void observationReplacer(String newString) { diff --git a/README.md b/README.md index 024262c7b..a726a03da 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ git checkout newbranch # Go to the new branch that still has the desired comm - Sandeep Srinivasa ([@sandys](https://twitter.com/sandeepssrin)) - Rohan Guha ([@pizzaboi21](https://github.com/pizzaboi21)) +- Md Shahil ([@Shahil093](https://github.com/Shahil093)) We love contributors! Feel free to contribute to this project but please read the [CLA](https://github.com/wootzapp/.github/blob/main/CLA.md) first!