-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Ktlint to spotless * Formatting * trimMargin instead of trimIndent --------- Co-authored-by: Niels Simonides <[email protected]>
- Loading branch information
Showing
37 changed files
with
1,405 additions
and
1,098 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
max_line_length = 140 | ||
|
||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{java,kt,kts,scala,rs,xml,kt.spec,kts.spec}] | ||
indent_size = 4 | ||
|
||
[*.{kt,kts}] | ||
ktlint_code_style = ktlint_official | ||
ktlint_ignore_back_ticked_identifier = true | ||
|
||
ktlint_standard = enabled | ||
ktlint_standard_property-naming = disabled | ||
|
||
# Experimental rules run by default run on the ktlint code base itself. Experimental rules should not be released if | ||
# we are not pleased ourselves with the results on the ktlint code base. | ||
ktlint_experimental = enabled | ||
|
||
# Don't allow any wildcard imports | ||
ij_kotlin_packages_to_use_import_on_demand = unset | ||
|
||
# Prevent wildcard imports | ||
ij_kotlin_name_count_to_use_star_import = 99 | ||
ij_kotlin_name_count_to_use_star_import_for_members = 99 | ||
|
||
|
||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
max_line_length = unset | ||
|
||
[gradle/verification-metadata.xml] | ||
indent_size = 3 | ||
|
||
[*.yml] | ||
ij_yaml_spaces_within_brackets = false |
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 |
---|---|---|
|
@@ -18,6 +18,7 @@ subprojects { | |
target("**/*.kt") | ||
trimTrailingWhitespace() | ||
endWithNewline() | ||
ktlint() | ||
} | ||
} | ||
} | ||
|
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
34 changes: 17 additions & 17 deletions
34
src/core/src/commonMain/kotlin/community/flock/aigentic/core/agent/prompt/SystemPrompt.kt
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 |
---|---|---|
@@ -1,42 +1,42 @@ | ||
package community.flock.aigentic.core.agent.prompt | ||
|
||
import community.flock.aigentic.core.message.Message | ||
import community.flock.aigentic.core.agent.Agent | ||
import community.flock.aigentic.core.agent.tool.finishOrStuckTool | ||
import community.flock.aigentic.core.message.Message | ||
|
||
interface SystemPromptBuilder { | ||
fun buildSystemPrompt(agent: Agent): Message.SystemPrompt | ||
} | ||
|
||
data object DefaultSystemPromptBuilder : SystemPromptBuilder { | ||
|
||
override fun buildSystemPrompt(agent: Agent): Message.SystemPrompt = | ||
agent.createSystemPrompt() | ||
override fun buildSystemPrompt(agent: Agent): Message.SystemPrompt = agent.createSystemPrompt() | ||
} | ||
|
||
private fun Agent.createSystemPrompt(): Message.SystemPrompt { | ||
|
||
val baseInstruction = | ||
"You are an agent which helps the user to accomplish different tasks. These tasks are outlined by the user below. The user has defined a set of tools which are available to achieve those tasks. The user also gives you information which gives you context, these are the first messages. Please execute one of these tools and the given context to fulfil these tasks. Don't send any text messages only use tools" | ||
""" | ||
|You are an agent which helps the user to accomplish different tasks. These tasks are outlined by the user below. | ||
|The user also gives you information which gives you context, these are the first messages. | ||
|Please execute one of these tools and the given context to fulfil these tasks. Don't send any text messages only use tools | ||
""".trimMargin() | ||
|
||
val instructions = task.instructions.joinToString(separator = "\n\n") | ||
|
||
val finishConditionDescription = | ||
"""You are finished when the task is executed successfully: ${task.description} | ||
If you meet this condition, call the ${finishOrStuckTool.name} tool to indicate that you are done and have finished all tasks. | ||
When you don't know what to do also call the ${finishOrStuckTool.name} tool to indicate that you are stuck and need help. | ||
""".trimIndent() | ||
""" | ||
|You are finished when the task is executed successfully: ${task.description} | ||
|If you meet this condition, call the ${finishOrStuckTool.name.value} tool to indicate that you are done and have finished all tasks. | ||
|When you don't know what to do also call the ${finishOrStuckTool.name.value} tool to indicate that you are stuck and need help. | ||
""".trimMargin() | ||
|
||
return Message.SystemPrompt( | ||
""" | ||
$baseInstruction | ||
|$baseInstruction | ||
Instructions: | ||
$instructions | ||
|Instructions: | ||
|$instructions | ||
$finishConditionDescription | ||
""".trimIndent() | ||
|$finishConditionDescription | ||
""".trimMargin(), | ||
) | ||
} |
Oops, something went wrong.