summaryrefslogtreecommitdiffstats
path: root/src/config/role.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2024-03-02 21:11:28 +0800
committerGitHub <noreply@github.com>2024-03-02 21:11:28 +0800
commit3c16aff59145134885f32056fa3be9bd6bed2cce (patch)
treef285ee126374b8815840815c7334e1d48fae2791 /src/config/role.rs
parentd275c33632271bf9cdbc01ef005deb9ff851370b (diff)
downloadaichat-3c16aff59145134885f32056fa3be9bd6bed2cce.tar.gz
feat: add `-c/--code` to generate only code (#327)
Diffstat (limited to 'src/config/role.rs')
-rw-r--r--src/config/role.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/config/role.rs b/src/config/role.rs
index a63877b..39f0f17 100644
--- a/src/config/role.rs
+++ b/src/config/role.rs
@@ -29,7 +29,7 @@ impl Role {
_ => "&&",
};
Self {
- name: "__for_execute__".into(),
+ name: "__execute__".into(),
prompt: format!(
r#"Provide only {shell} commands for {os} without any description.
If there is a lack of details, provide most logical solution.
@@ -44,7 +44,7 @@ Do not provide markdown formatting such as ```"#
pub fn for_describe() -> Self {
Self {
- name: "__for_describe__".into(),
+ name: "__describe__".into(),
prompt: r#"Provide a terse, single sentence description of the given shell command.
Describe each argument and option of the command.
Provide short responses in about 80 words.
@@ -54,6 +54,20 @@ APPLY MARKDOWN formatting when possible."#
}
}
+ pub fn for_code() -> Self {
+ Self {
+ name: "__code__".into(),
+ prompt: r#"Provide only code as output without any description.
+Provide only code in plain text format without Markdown formatting.
+Do not include symbols such as ``` or ```python.
+If there is a lack of details, provide most logical solution.
+You are not allowed to ask for more details.
+For example if the prompt is "Hello world Python", you should return "print('Hello world')"."#
+ .into(),
+ temperature: None,
+ }
+ }
+
pub fn info(&self) -> Result<String> {
let output = serde_yaml::to_string(&self)
.with_context(|| format!("Unable to show info about role {}", &self.name))?;