-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Slash commands #5718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slash commands #5718
Changes from all commits
293e55c
60f3e8b
f55234b
c346a6d
02e85e4
6851680
a63733e
6b32d1d
80b2e78
e1ae3f0
8e84ca5
4f42b5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,7 @@ use goose::providers::pricing::{ | |||||||
| get_all_pricing, get_model_pricing, parse_model_id, refresh_pricing, | ||||||||
| }; | ||||||||
| use goose::providers::providers as get_providers; | ||||||||
| use goose::{agents::ExtensionConfig, config::permission::PermissionLevel}; | ||||||||
| use goose::{agents::ExtensionConfig, config::permission::PermissionLevel, slash_commands}; | ||||||||
| use http::StatusCode; | ||||||||
| use serde::{Deserialize, Serialize}; | ||||||||
| use serde_json::Value; | ||||||||
|
|
@@ -113,6 +113,23 @@ pub enum ConfigValueResponse { | |||||||
| MaskedValue(MaskedSecret), | ||||||||
| } | ||||||||
|
|
||||||||
| #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] | ||||||||
| pub enum CommandType { | ||||||||
| Builtin, | ||||||||
| Recipe, | ||||||||
| } | ||||||||
|
|
||||||||
| #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] | ||||||||
| pub struct SlashCommand { | ||||||||
| pub command: String, | ||||||||
| pub help: String, | ||||||||
| pub command_type: CommandType, | ||||||||
| } | ||||||||
| #[derive(Serialize, ToSchema)] | ||||||||
| pub struct SlashCommandsResponse { | ||||||||
| pub commands: Vec<SlashCommand>, | ||||||||
| } | ||||||||
|
|
||||||||
| #[utoipa::path( | ||||||||
| post, | ||||||||
| path = "/config/upsert", | ||||||||
|
|
@@ -390,6 +407,30 @@ pub async fn get_provider_models( | |||||||
| } | ||||||||
| } | ||||||||
|
|
||||||||
| #[utoipa::path( | ||||||||
| get, | ||||||||
| path = "/config/slash_commands", | ||||||||
| responses( | ||||||||
| (status = 200, description = "Slash commands retrieved successfully", body = SlashCommandsResponse) | ||||||||
| ) | ||||||||
| )] | ||||||||
| pub async fn get_slash_commands() -> Result<Json<SlashCommandsResponse>, StatusCode> { | ||||||||
| let mut commands: Vec<_> = slash_commands::list_commands() | ||||||||
| .iter() | ||||||||
| .map(|command| SlashCommand { | ||||||||
| command: command.command.clone(), | ||||||||
| help: command.recipe_path.clone(), | ||||||||
| command_type: CommandType::Recipe, | ||||||||
| }) | ||||||||
| .collect(); | ||||||||
| commands.push(SlashCommand { | ||||||||
| command: "compact".to_string(), | ||||||||
| help: "Compact the current conversation to save tokens".to_string(), | ||||||||
| command_type: CommandType::Builtin, | ||||||||
| }); | ||||||||
|
Comment on lines
+426
to
+430
|
||||||||
| Ok(Json(SlashCommandsResponse { commands })) | ||||||||
| } | ||||||||
|
|
||||||||
| #[derive(Serialize, ToSchema)] | ||||||||
| pub struct PricingData { | ||||||||
| pub provider: String, | ||||||||
|
|
@@ -408,8 +449,7 @@ pub struct PricingResponse { | |||||||
|
|
||||||||
| #[derive(Deserialize, ToSchema)] | ||||||||
| pub struct PricingQuery { | ||||||||
| /// If true, only return pricing for configured providers. If false, return all. | ||||||||
| pub configured_only: Option<bool>, | ||||||||
| pub configured_only: bool, | ||||||||
|
||||||||
| pub configured_only: bool, | |
| #[serde(default)] | |
| pub configured_only: Option<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this might be more natural to have its own set of routes vs being under
config. I think ofconfig_managment.rsroutes as just about changing settings, but with this change slash commands are becoming a feature of their own. Similar to how recipes have their own route file.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe? this does just write something into the settings though. it is more similar to extensions and providers; sure they are their own features, but in terms of routes here we expose how to change it in the config file.
recipes are stored in their own folder(s).