mirror of
https://github.com/aljazceru/goose.git
synced 2025-12-19 07:04:21 +01:00
Don't require prompt in headless mode for recipes (#2403)
Co-authored-by: Douwe Osinga <douwe@squareup.com>
This commit is contained in:
@@ -504,7 +504,7 @@ pub async fn cli() -> Result<()> {
|
|||||||
InputConfig {
|
InputConfig {
|
||||||
contents: recipe.prompt,
|
contents: recipe.prompt,
|
||||||
extensions_override: recipe.extensions,
|
extensions_override: recipe.extensions,
|
||||||
additional_system_prompt: Some(recipe.instructions),
|
additional_system_prompt: recipe.instructions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(None, None, None) => {
|
(None, None, None) => {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ fn default_version() -> String {
|
|||||||
/// version: "1.0.0".to_string(),
|
/// version: "1.0.0".to_string(),
|
||||||
/// title: "Example Agent".to_string(),
|
/// title: "Example Agent".to_string(),
|
||||||
/// description: "An example Recipe configuration".to_string(),
|
/// description: "An example Recipe configuration".to_string(),
|
||||||
/// instructions: "Act as a helpful assistant".to_string(),
|
/// instructions: Some("Act as a helpful assistant".to_string()),
|
||||||
/// prompt: None,
|
/// prompt: None,
|
||||||
/// extensions: None,
|
/// extensions: None,
|
||||||
/// context: None,
|
/// context: None,
|
||||||
@@ -59,9 +59,11 @@ pub struct Recipe {
|
|||||||
|
|
||||||
pub description: String, // a longer description of the recipe
|
pub description: String, // a longer description of the recipe
|
||||||
|
|
||||||
pub instructions: String, // the instructions for the model
|
|
||||||
|
|
||||||
// Optional fields
|
// Optional fields
|
||||||
|
// Note: at least one of instructions or prompt need to be set
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub instructions: Option<String>, // the instructions for the model
|
||||||
|
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub prompt: Option<String>, // the prompt to start the session with
|
pub prompt: Option<String>, // the prompt to start the session with
|
||||||
|
|
||||||
@@ -193,13 +195,16 @@ impl RecipeBuilder {
|
|||||||
pub fn build(self) -> Result<Recipe, &'static str> {
|
pub fn build(self) -> Result<Recipe, &'static str> {
|
||||||
let title = self.title.ok_or("Title is required")?;
|
let title = self.title.ok_or("Title is required")?;
|
||||||
let description = self.description.ok_or("Description is required")?;
|
let description = self.description.ok_or("Description is required")?;
|
||||||
let instructions = self.instructions.ok_or("Instructions are required")?;
|
|
||||||
|
if self.instructions.is_none() && self.prompt.is_none() {
|
||||||
|
return Err("At least one of 'prompt' or 'instructions' is required");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Recipe {
|
Ok(Recipe {
|
||||||
version: self.version,
|
version: self.version,
|
||||||
title,
|
title,
|
||||||
description,
|
description,
|
||||||
instructions,
|
instructions: self.instructions,
|
||||||
prompt: self.prompt,
|
prompt: self.prompt,
|
||||||
extensions: self.extensions,
|
extensions: self.extensions,
|
||||||
context: self.context,
|
context: self.context,
|
||||||
|
|||||||
Reference in New Issue
Block a user