refactor: hide sytem roles from repl tab-completion (#407)

pull/409/head
sigoden 2 months ago committed by GitHub
parent 9f19539c2c
commit 568e9a06db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -502,7 +502,12 @@ impl Config {
pub fn repl_complete(&self, cmd: &str, args: &[&str]) -> Vec<String> {
let (values, filter) = if args.len() == 1 {
let values = match cmd {
".role" => self.roles.iter().map(|v| v.name.clone()).collect(),
".role" => self
.roles
.iter()
.filter(|v| !v.is_system())
.map(|v| v.name.clone())
.collect(),
".model" => list_models(self).into_iter().map(|v| v.id()).collect(),
".session" => self.list_sessions(),
".set" => vec![

@ -46,8 +46,7 @@ impl Role {
r#"Provide only {shell} commands for {os} without any description.
Ensure the output is a valid {shell} command. {combine}
If there is a lack of details, provide most logical solution.
Provide only plain text without Markdown formatting.
Do not provide markdown formatting such as ```"#
Output plain text only, without any markdown formatting."#
),
temperature: None,
}
@ -68,17 +67,20 @@ APPLY MARKDOWN formatting when possible."#
pub fn for_code() -> Self {
Self {
name: Self::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')"."#
prompt: r#"Provide only code, without comments or explanations.
If there is a lack of details, provide most logical solution, without requesting further clarification."#
.into(),
temperature: None,
}
}
pub fn is_system(&self) -> bool {
matches!(
self.name.as_str(),
Self::EXECUTE | Self::DESCRIBE_COMMAND | Self::CODE
)
}
pub fn export(&self) -> Result<String> {
let output = serde_yaml::to_string(&self)
.with_context(|| format!("Unable to show info about role {}", &self.name))?;

Loading…
Cancel
Save