diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts.scala deleted file mode 100644 index 2ee0e6e4f..000000000 --- a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts.scala +++ /dev/null @@ -1,104 +0,0 @@ -package kyo.llm - -import kyo.llm.ais._ - -object thoughts { - - import Reasoning._ - - case class Reasoning( - startReasoning: StartReasoning, - contextualize: Contextualize, - reflect: Reflect, - plan: Plan, - endReasoning: EndReasoning - ) - - object Reasoning { - case class StartReasoning( - `I understand that the fields under 'reasoning' are meant as a way for me to reason about the json I need to generate`: Boolean, - `When generating the values for the 'reasoning' fields, I won't mention themselves in the reasoning process`: Boolean, - `Some fields in the json schema have a 'const' definition. I understand the provided const value is the only possible value for the field`: Boolean - ) - case class Contextualize( - `When I disconsider the fields under 'reasoning' and analyze the other fields in the json schema, I briefly conclude the purpose of the other fields is`: String, - `My goal generating this data is`: String, - `Important restrictions I should take in consideration when generating the data`: String - ) - case class Reflect( - `I noticed that I previously failed to produce valid data`: Boolean, - `The reasons I failed previously are`: List[String] - ) - case class Step( - name: String, - description: String, - `potential mistakes`: String - ) - case class Plan( - `Considering all the information provided so far, I'll produce a plan to generate high-quality data that satisfies the user's needs`: Boolean, - `Formal techniques from literature I can be used to aid the generation`: String, - `Additional informal techniques`: String, - `Let's think step by step`: List[Step], - `Now that I have the plan steps, I'll generate 'endReasoning'`: Boolean - ) - case class EndReasoning( - `This reasoning process was helpful to generate the json because`: String, - `I understand the reasoning process has ended and will now focus on generating actual data requested by the user based on the reasoning`: Boolean - ) - } - - import Collect._ - case class Collect[T]( - `I'll now generate a complete array with as elements as necessary to fully satisfy the user's request`: Boolean, - `Number of elements I can generate`: Int, - elements: List[Element[T]] - ) { - def list: List[T] = elements.map(_.elementValue) - } - - object Collect { - case class Element[T]( - `Brief description of the facts that support this information`: List[String], - elementValue: T, - `Should I continue generating more elements`: Boolean - ) - } - - case class Constrain[T, C <: String]( - `constraints to consider to proceed with the 'value' json generation`: C, - value: T - ) - - type NonEmpty = "Non-empty" -} - -object tt extends KyoLLMApp { - - import thoughts._ - import kyo.llm.ais._ - - case class CQA( - @desc("Excerpt from the input text") - excerpt: Constrain[String, NonEmpty], - @desc("An elaborate question regarding the excerpt") - question: Constrain[String, NonEmpty], - @desc("A comprehensive answer") - answer: Constrain[String, NonEmpty] - ) - case class Req( - reasoning: Reasoning, - @desc("Comprehensive set of questions covering all information in the input text") - questions: Collect[Constrain[String, NonEmpty]], - @desc("Process each question") - processedQuestions: Constrain[Collect[CQA], NonEmpty] - ) - - run { - AIs.gen[Req](text) - } - - def text = - p""" - General relativity is a theory of gravitation developed by Einstein in the years 1907–1915. The development of general relativity began with the equivalence principle, under which the states of accelerated motion and being at rest in a gravitational field (for example, when standing on the surface of the Earth) are physically identical. The upshot of this is that free fall is inertial motion: an object in free fall is falling because that is how objects move when there is no force being exerted on them, instead of this being due to the force of gravity as is the case in classical mechanics. This is incompatible with classical mechanics and special relativity because in those theories inertially moving objects cannot accelerate with respect to each other, but objects in free fall do so. To resolve this difficulty Einstein first proposed that spacetime is curved. Einstein discussed his idea with mathematician Marcel Grossmann and they concluded that general relativity could be formulated in the context of Riemannian geometry which had been developed in the 1800s.[10] In 1915, he devised the Einstein field equations which relate the curvature of spacetime with the mass, energy, and any momentum within it. - """ -} diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Chain.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Chain.scala new file mode 100644 index 000000000..45fca3b42 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Chain.scala @@ -0,0 +1,45 @@ +package kyo.llm.thoughts.meta + +import kyo.llm.ais._ + +object Chain { + + val chainDesc = + p""" + The Chain thoughts enable sequential linking of multiple reasoning processes. + - Facilitates the flow of reasoning from one thought to another. + - Ensures coherence and logical progression in the reasoning chain. + - Allows complex reasoning to be broken down into manageable segments. + """ +} +import Chain._ + +@desc(chainDesc) +case class Chain[A, B]( + `First thought or process`: A, + `Second thought or process`: B +) + +@desc(chainDesc) +case class Chain3[A, B, C]( + `First thought or process`: A, + `Second thought or process`: B, + `Third thought or process`: C +) + +@desc(chainDesc) +case class Chain4[A, B, C, D]( + `First thought or process`: A, + `Second thought or process`: B, + `Third thought or process`: C, + `Fourth thought or process`: D +) + +@desc(chainDesc) +case class Chain5[A, B, C, D, E]( + `First thought or process`: A, + `Second thought or process`: B, + `Third thought or process`: C, + `Fourth thought or process`: D, + `Fifth thought or process`: E +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Collect.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Collect.scala new file mode 100644 index 000000000..acbcc2859 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Collect.scala @@ -0,0 +1,34 @@ +package kyo.llm.thoughts.meta + +import kyo.llm.ais._ + +@desc( + p""" + The Collect thought focuses on assembling a comprehensive array of elements. + - Generates a complete array to fully satisfy the user's request. + - Determines the number of elements necessary for completeness. + - Each element is supported by a brief factual description. + """ +) +case class Collect[T]( + `Generate a complete array to satisfy the user's request`: Boolean, + `Determine the number of elements to generate`: Int, + elements: List[Collect.Element[T]] +) { + def list: List[T] = elements.map(_.elementValue) +} + +object Collect { + @desc( + p""" + Element within Collect represents an individual item in the collection. + - Each item is accompanied by a brief factual description. + - Decision to continue generating more elements is considered. + """ + ) + case class Element[T]( + `Provide factual description for the element`: List[String], + elementValue: T, + `Decide if more elements should be generated`: Boolean + ) +} diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Constrain.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Constrain.scala new file mode 100644 index 000000000..bd5c133ae --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Constrain.scala @@ -0,0 +1,15 @@ +package kyo.llm.thoughts.meta + +import kyo.llm.ais._ + +@desc( + p""" + The Constrain thought involves applying constraints to the reasoning process. + - Focuses on considering specific constraints for value generation. + - Ensures that the generated values adhere to defined constraints. + """ +) +case class Constrain[T, C <: String]( + `Apply specific constraints to the value generation`: C, + value: T +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Analysis.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Analysis.scala new file mode 100644 index 000000000..bc37cd7a7 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Analysis.scala @@ -0,0 +1,18 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Analysis thought breaks down the input into more manageable parts. + - Dissects the input into fundamental elements. + - Explores connections among elements. + - Critically assesses the validity and logic. + - Relevant techniques: Data Decomposition, Logical Analysis. + """ +) +case class Analysis( + `Dissect the input into fundamental elements for a detailed examination`: String, + `Explore connections and relationships among these elements`: String, + `Critically assess the validity and logic of the information presented`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Contextualization.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Contextualization.scala new file mode 100644 index 000000000..2d86f0486 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Contextualization.scala @@ -0,0 +1,18 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Contextualization thought involves placing the input within a broader framework. + - Assesses the relationship of input to previous discussions or knowledge. + - Identifies broader context relevant to the input. + - Considers implications of external factors. + - Relevant techniques: Context Analysis, Pattern Recognition. + """ +) +case class Contextualization( + `Assess how the current input relates to previous discussions or knowledge`: String, + `Identify the broader context or background relevant to the input`: String, + `Consider the implications of external factors or related concepts`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Creative.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Creative.scala new file mode 100644 index 000000000..69a7c32c3 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Creative.scala @@ -0,0 +1,34 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Creative thought encourages creative and divergent thinking in AI processes. + - Draws on concepts from creative problem solving and design thinking. + - Utilizes divergent thinking models from cognitive psychology. + - Applies ideation techniques and lateral thinking for novel idea generation. + - Relevant techniques: TRIZ, SCAMPER, Mind Mapping. + - Uses markdown format. + """ +) +case class Creative( + brainstormIdeas: BrainstormIdeas, + explorePossibilities: ExplorePossibilities, + synthesizeConcepts: SynthesizeConcepts +) + +case class BrainstormIdeas( + `Generate a list of creative ideas and concepts`: String, + `Apply lateral thinking to explore new perspectives`: String +) + +case class ExplorePossibilities( + `Consider alternative solutions and challenge existing assumptions`: String, + `Assess the feasibility and impact of different ideas`: String +) + +case class SynthesizeConcepts( + `Integrate diverse ideas into coherent concepts`: String, + `Create innovative approaches or solutions`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Critical.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Critical.scala new file mode 100644 index 000000000..13303d044 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Critical.scala @@ -0,0 +1,16 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Critical thought emphasizes skepticism and analysis. + - Engages in critical evaluation of information and assumptions. + - Relevant techniques: Logical Analysis, Bias Identification. + """ +) +case class Critical( + `Critically evaluate information and assumptions`: String, + `Identify and challenge potential biases and fallacies`: String, + `Reflect on reasoning process to identify areas for improvement`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Ecological.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Ecological.scala new file mode 100644 index 000000000..d9f5bdb9b --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Ecological.scala @@ -0,0 +1,16 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Ecological thought considers environmental and ecological factors. + - Focuses on understanding ecological interrelationships. + - Relevant techniques: Ecosystem Analysis, Sustainability Assessment. + """ +) +case class Ecological( + `Analyze ecological interrelationships and dependencies`: String, + `Assess environmental impacts and sustainability factors`: String, + `Explore ecological solutions and sustainable practices`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Emotional.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Emotional.scala new file mode 100644 index 000000000..8ab24d5a1 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Emotional.scala @@ -0,0 +1,27 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Emotional thought focuses on incorporating emotional and social intelligence in AI reasoning. + - Applies principles from affective computing to interpret emotional tones. + - Uses concepts from social psychology to analyze social contexts. + - Incorporates empathetic algorithms for generating responses. + - Relevant techniques: Sentiment Analysis, Social Network Analysis. + """ +) +case class EmotionalReasoning( + understandEmotions: UnderstandEmotions, + analyzeContext: AnalyzeContext +) + +case class UnderstandEmotions( + `Identify the emotional tone and sentiment in the text`: String, + `Recognize emotional cues and expressions`: String +) + +case class AnalyzeContext( + `Relate information to broader social and cultural settings`: String, + `Consider social norms and values relevant to the text`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Ethical.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Ethical.scala new file mode 100644 index 000000000..b1dbcc0d9 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Ethical.scala @@ -0,0 +1,16 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Ethical thought incorporates principles of ethics and morality. + - Analyzes ethical dimensions and moral considerations of scenarios. + - Relevant techniques: Ethical Analysis, Moral Deliberation. + """ +) +case class Ethical( + `Analyze ethical implications of different scenarios`: String, + `Deliberate on moral values and principles in context`: String, + `Consider ethical consequences in decision-making processes`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Evaluation.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Evaluation.scala new file mode 100644 index 000000000..c731240e2 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Evaluation.scala @@ -0,0 +1,18 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Evaluation thought involves critically judging the information processed. + - Assesses accuracy and reliability. + - Evaluates relevance and importance. + - Determines confidence in conclusions. + - Relevant techniques: Information Validation, Critical Assessment. + """ +) +case class Evaluation( + `Assess the accuracy and reliability of the synthesized information`: String, + `Evaluate the relevance and importance of the information to the query`: String, + `Determine the confidence level in the conclusions reached`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Existential.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Existential.scala new file mode 100644 index 000000000..621fa1449 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Existential.scala @@ -0,0 +1,16 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Existential thought explores deep philosophical questions. + - Engages with existential and philosophical concepts. + - Relevant techniques: Philosophical Inquiry, Conceptual Analysis. + """ +) +case class Existential( + `Explore existential themes and philosophical questions`: String, + `Analyze philosophical concepts and arguments`: String, + `Synthesize philosophical insights and perspectives`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Interpretation.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Interpretation.scala new file mode 100644 index 000000000..699cbd3cb --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Interpretation.scala @@ -0,0 +1,18 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Interpretation thought focuses on the initial understanding of the input. + - Determines the core message or question in the input. + - Identifies ambiguous aspects needing clarification. + - Extracts key terms for deeper analysis. + - Relevant techniques: Textual Analysis, Conceptual Clarification. + """ +) +case class Interpretation( + `Determine the core message or question in the input`: String, + `Identify any ambiguous or unclear aspects that need further clarification`: String, + `Extract key terms and concepts for deeper analysis`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Planning.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Planning.scala new file mode 100644 index 000000000..471fdcdcb --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Planning.scala @@ -0,0 +1,18 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Planning thought outlines strategic steps based on analysis. + - Develops a plan of action based on analysis. + - Outlines specific measures to address the task. + - Prepares for potential challenges in implementation. + - Relevant techniques: Strategic Planning, Action Formulation. + """ +) +case class ActionPlanning( + `Develop a strategic plan of action based on analysis`: String, + `Outline specific steps or measures to address the query or problem`: String, + `Prepare for potential challenges or obstacles in implementing the plan`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Prediction.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Prediction.scala new file mode 100644 index 000000000..eaa8d8ad5 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Prediction.scala @@ -0,0 +1,18 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Prediction thought involves forecasting future scenarios. + - Forecasts based on current understanding. + - Identifies trends for future developments. + - Considers impact of variables on outcomes. + - Relevant techniques: Forecasting Methods, Scenario Planning. + """ +) +case class Prediction( + `Forecast potential future scenarios based on current understanding`: String, + `Identify trends or patterns that could influence future developments`: String, + `Consider how different variables might impact future outcomes`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Reflection.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Reflection.scala new file mode 100644 index 000000000..b6bba4986 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Reflection.scala @@ -0,0 +1,17 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Reflection thought involves reviewing the reasoning process. + - Identifies errors or biases in reasoning. + - Considers ways to improve future responses. + - Relevant techniques: Reflective Practice, Bias Identification. + """ +) +case class Reflection( + `Review reasoning process for errors or biases`: String, + `Consider improvements for future reasoning`: String, + `Reflect on the effectiveness of the reasoning approach`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Synthesis.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Synthesis.scala new file mode 100644 index 000000000..82a383001 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Synthesis.scala @@ -0,0 +1,18 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Synthesis thought combines disparate elements into a coherent whole. + - Integrates information for unified understanding. + - Develops hypotheses based on integration. + - Creates comprehensive summaries. + - Relevant techniques: Idea Integration, Summary Creation. + """ +) +case class Synthesis( + `Integrate different pieces of information to form a unified understanding`: String, + `Develop hypotheses or theories based on the integrated information`: String, + `Create a comprehensive summary that encapsulates the essence of the input`: String +) diff --git a/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Systems.scala b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Systems.scala new file mode 100644 index 000000000..34e2088b0 --- /dev/null +++ b/kyo-llm/shared/src/main/scala/kyo/llm/thoughts/reasoning/Systems.scala @@ -0,0 +1,33 @@ +package kyo.llm.thoughts.reasoning + +import kyo.llm.ais._ + +@desc( + p""" + The Systems thought is designed to apply systems theory in AI reasoning. + - Utilizes principles from systems theory to analyze component interactions. + - Employs methods from complexity science for systemic dynamics evaluation. + - Integrates techniques like causal loop diagramming for predicting outcomes. + - Relevant techniques: Feedback Systems, Network Analysis. + """ +) +case class SystemsThinking( + identifyComponents: IdentifyComponents, + analyzeInteractions: AnalyzeInteractions, + predictOutcomes: PredictOutcomes +) + +case class IdentifyComponents( + `List major elements of the system and their roles`: String, + `Recognize relationships among system components`: String +) + +case class AnalyzeInteractions( + `Examine causal links within the system`: String, + `Evaluate feedback loops and systemic dynamics`: String +) + +case class PredictOutcomes( + `Anticipate possible changes within the system`: String, + `Propose potential interventions in the system`: String +)