diff --git a/crates/tabby-common/src/config.rs b/crates/tabby-common/src/config.rs index c1cd255..7e77db7 100644 --- a/crates/tabby-common/src/config.rs +++ b/crates/tabby-common/src/config.rs @@ -18,9 +18,7 @@ pub struct Config { } #[derive(Serialize, Deserialize, Default)] -pub struct SwaggerConfig { - pub server_url: Option, -} +pub struct SwaggerConfig {} impl Config { pub fn load() -> Result { diff --git a/crates/tabby-scheduler/tests/integration_test.rs b/crates/tabby-scheduler/tests/integration_test.rs index d4522f1..7bb23b9 100644 --- a/crates/tabby-scheduler/tests/integration_test.rs +++ b/crates/tabby-scheduler/tests/integration_test.rs @@ -20,7 +20,7 @@ mod tests { repositories: vec![Repository { git_url: "https://github.com/TabbyML/interview-questions".to_owned(), }], - swagger: SwaggerConfig { server_url: None }, + swagger: SwaggerConfig {}, }; config.save(); diff --git a/crates/tabby/src/serve/completions.rs b/crates/tabby/src/serve/completions.rs index f3964ad..6dc5e20 100644 --- a/crates/tabby/src/serve/completions.rs +++ b/crates/tabby/src/serve/completions.rs @@ -39,21 +39,13 @@ pub struct CompletionRequest { /// reports. user: Option, - debug: Option, + debug_options: Option, } -#[derive(Serialize, ToSchema, Deserialize, Clone, Debug)] -pub struct DebugRequest { +#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)] +pub struct DebugOptions { /// When true, returns debug_data in completion response. enabled: bool, - - /// When true, turn off prompt rewrite with source code index. - #[serde(default = "default_false")] - disable_prompt_rewrite: bool, -} - -fn default_false() -> bool { - false } #[derive(Serialize, Deserialize, ToSchema, Clone, Debug)] @@ -136,15 +128,7 @@ pub async fn completions( }; debug!("PREFIX: {}, SUFFIX: {:?}", segments.prefix, segments.suffix); - let snippets = if !request - .debug - .as_ref() - .is_some_and(|x| x.disable_prompt_rewrite) - { - state.prompt_builder.collect(&language, &segments) - } else { - vec![] - }; + let snippets = state.prompt_builder.collect(&language, &segments); let prompt = state .prompt_builder .build(&language, segments.clone(), &snippets); @@ -173,7 +157,7 @@ pub async fn completions( Ok(Json(CompletionResponse { id: completion_id, choices: vec![Choice { index: 0, text }], - debug_data: if request.debug.is_some_and(|x| x.enabled) { + debug_data: if request.debug_options.is_some_and(|x| x.enabled) { Some(debug_data) } else { None diff --git a/crates/tabby/src/serve/mod.rs b/crates/tabby/src/serve/mod.rs index 655d395..9398c1f 100644 --- a/crates/tabby/src/serve/mod.rs +++ b/crates/tabby/src/serve/mod.rs @@ -23,7 +23,7 @@ use tabby_download::Downloader; use tokio::time::sleep; use tower_http::{cors::CorsLayer, timeout::TimeoutLayer}; use tracing::{info, warn}; -use utoipa::{openapi::ServerBuilder, OpenApi}; +use utoipa::OpenApi; use utoipa_swagger_ui::SwaggerUi; use self::{ @@ -57,9 +57,9 @@ Install following IDE / Editor extensions to get started with [Tabby](https://gi completions::CompletionResponse, completions::Segments, completions::Choice, - completions::DebugRequest, - completions::DebugData, completions::Snippet, + completions::DebugOptions, + completions::DebugData, chat::ChatCompletionRequest, chat::Message, chat::ChatCompletionChunk, @@ -292,18 +292,7 @@ trait OpenApiOverride { } impl OpenApiOverride for utoipa::openapi::OpenApi { - fn override_doc(&mut self, args: &ServeArgs, config: &SwaggerConfig) { - if let Some(servers) = self.servers.as_mut() { - if let Some(server_url) = &config.server_url { - servers.push( - ServerBuilder::new() - .url(server_url) - .description(Some("Swagger Server")) - .build(), - ); - } - } - + fn override_doc(&mut self, args: &ServeArgs, _config: &SwaggerConfig) { if args.chat_model.is_none() { self.paths.paths.remove("/v1beta/chat/completions");