-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
154 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Desc.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package kyo.llm.thoughts.meta | ||
|
||
import kyo.llm.ais._ | ||
|
||
@desc( | ||
p""" | ||
The Desc thought is designed to encapsulate a thought along with a user-defined description. | ||
- 'desc' is a string literal type that acts as a label or a brief explanation of the thought process. | ||
- 'value' is the actual thought or process that needs to be generated or executed. | ||
- This class guides the LLM to focus on generating the 'value' based on the context provided by 'desc'. | ||
- Example user code that generates this thought Desc["brainstorm something", Chain[Creative, Critical]] indicates | ||
that the LLM should engage in a creative and critical thought chain under the theme of 'brainstorm something'. | ||
""" | ||
) | ||
case class Desc[D <: String, T](desc: D, value: T) |
17 changes: 17 additions & 0 deletions
17
kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Gen.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package kyo.llm.thoughts.meta | ||
|
||
import kyo.llm.ais._ | ||
|
||
@desc( | ||
p""" | ||
The Gen thought is structured to facilitate the generation of a specific outcome based on a given thought process. | ||
- The 'thought' field represents the thought process or reasoning approach that the AI should use. | ||
- The 'value' field is the specific outcome or result that should be generated using the specified thought process. | ||
- This thought encourages the AI to apply a particular reasoning method (as defined in 'thought') to produce a desired output (as specified in 'value'). | ||
- Example: Gen[Analysis, "Potential solutions to a problem"] would direct the AI to use analytical reasoning to generate potential solutions to the given problem. | ||
""" | ||
) | ||
case class Gen[T, U]( | ||
thought: T, | ||
value: U | ||
) |
26 changes: 26 additions & 0 deletions
26
kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Init.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package kyo.llm.thoughts.meta | ||
|
||
import kyo.llm.ais._ | ||
|
||
@desc( | ||
p""" | ||
The Init thought sets foundational guidelines for the LLM's reasoning process, especially in adhering to the JSON schema. | ||
- **Crucially, the LLM must never generate arbitrary fields and should strictly follow the provided JSON schema.** | ||
- This thought ensures that 'value' represents specific, predefined thoughts or reasoning steps. | ||
- Acts as a blueprint for integrating thoughts into a logical and schema-compliant reasoning pathway. | ||
- Aims for well-structured responses that align with the user's intent and adhere to JSON formatting rules. | ||
- Fields focus on reflecting upon past errors and strategizing to avoid them, especially in maintaining JSON schema integrity. | ||
- Example: A 'value' containing Chain[Analysis, Synthesis] should be elaborated in accordance with the schema, without adding extraneous fields. | ||
- **The LLM is required to ensure compliance with the JSON schema at all times.** | ||
""" | ||
) | ||
case class Init[T]( | ||
`Have you failed at previous attempts to generate this json`: Boolean, | ||
`Analysis of the previous failures`: String, | ||
`Strategy to avoid another failure`: String, | ||
`Elaborate on the strategy to avoid failures`: String, | ||
`The generated json can't have new line characters`: Boolean, | ||
`I understand I can't use new lines`: Boolean, | ||
`Strictly adhere to the provided JSON schema without adding arbitrary fields`: Boolean, | ||
value: T | ||
) |
46 changes: 46 additions & 0 deletions
46
kyo-llm/shared/src/main/scala/kyo/llm/thoughts/meta/Select.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package kyo.llm.thoughts.meta | ||
|
||
import kyo.llm.ais._ | ||
|
||
object Select { | ||
|
||
val SelectDesc = | ||
p""" | ||
The Select thought facilitates the LLM's choice in focusing on particular reasoning processes. | ||
- Enables selective expansion on specific thoughts based on relevance and significance. | ||
- Provides flexibility in the reasoning pathway, allowing the LLM to prioritize and delve deeper into chosen thoughts. | ||
- Encourages a targeted approach to reasoning, ensuring a more efficient and relevant output. | ||
- The use of 'Option' in each thought or process allows for dynamic selection based on the context of the conversation. | ||
""" | ||
} | ||
import Select._ | ||
|
||
@desc(SelectDesc) | ||
case class Select[A, B]( | ||
`First thought or process`: Option[A], | ||
`Second thought or process`: Option[B] | ||
) | ||
|
||
@desc(SelectDesc) | ||
case class Select3[A, B, C]( | ||
`First thought or process`: Option[A], | ||
`Second thought or process`: Option[B], | ||
`Third thought or process`: Option[C] | ||
) | ||
|
||
@desc(SelectDesc) | ||
case class Select4[A, B, C, D]( | ||
`First thought or process`: Option[A], | ||
`Second thought or process`: Option[B], | ||
`Third thought or process`: Option[C], | ||
`Fourth thought or process`: Option[D] | ||
) | ||
|
||
@desc(SelectDesc) | ||
case class Select5[A, B, C, D, E]( | ||
`First thought or process`: Option[A], | ||
`Second thought or process`: Option[B], | ||
`Third thought or process`: Option[C], | ||
`Fourth thought or process`: Option[D], | ||
`Fifth thought or process`: Option[E] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters