From 9c8e6fd26e92cb4e56074c0f87ee56b10e35a5c2 Mon Sep 17 00:00:00 2001 From: Meng Zhang Date: Thu, 31 Oct 2024 15:14:15 -0700 Subject: [PATCH] refactor(api): remove unused serde and utoipa attributes for CodeSearch / DocSearch --- crates/tabby-common/src/api/code.rs | 16 +++------------- crates/tabby-common/src/api/doc.rs | 5 +---- crates/tabby/src/serve.rs | 6 ------ 3 files changed, 4 insertions(+), 23 deletions(-) diff --git a/crates/tabby-common/src/api/code.rs b/crates/tabby-common/src/api/code.rs index 5c1a3c963d59..8a327ab4dcad 100644 --- a/crates/tabby-common/src/api/code.rs +++ b/crates/tabby-common/src/api/code.rs @@ -2,20 +2,18 @@ use async_trait::async_trait; use derive_builder::Builder; use serde::{Deserialize, Serialize}; use thiserror::Error; -use utoipa::ToSchema; -#[derive(Default, Serialize, Deserialize, Debug)] pub struct CodeSearchResponse { pub hits: Vec, } -#[derive(Serialize, Deserialize, Debug, Clone, Default, ToSchema)] +#[derive(Default, Clone)] pub struct CodeSearchHit { pub scores: CodeSearchScores, pub doc: CodeSearchDocument, } -#[derive(Serialize, Deserialize, Debug, Clone, Default, ToSchema)] +#[derive(Default, Clone)] pub struct CodeSearchScores { /// Reciprocal rank fusion score: https://www.elastic.co/guide/en/elasticsearch/reference/current/rrf.html pub rrf: f32, @@ -23,15 +21,10 @@ pub struct CodeSearchScores { pub embedding: f32, } -#[derive(Serialize, Deserialize, Debug, Builder, Clone, Default, ToSchema)] +#[derive(Builder, Default, Clone)] pub struct CodeSearchDocument { /// Unique identifier for the file in the repository, stringified SourceFileKey. - /// - /// Skipped in API responses. - #[serde(skip_serializing)] pub file_id: String, - - #[serde(skip_serializing)] pub chunk_id: String, pub body: String, @@ -56,13 +49,10 @@ pub enum CodeSearchError { Other(#[from] anyhow::Error), } -#[derive(Deserialize, ToSchema)] pub struct CodeSearchQuery { pub filepath: Option, pub language: Option, pub content: String, - - #[serde(skip)] pub source_id: String, } diff --git a/crates/tabby-common/src/api/doc.rs b/crates/tabby-common/src/api/doc.rs index a35e2d2e706f..379c0f7cba34 100644 --- a/crates/tabby-common/src/api/doc.rs +++ b/crates/tabby-common/src/api/doc.rs @@ -1,19 +1,16 @@ use async_trait::async_trait; -use serde::{Deserialize, Serialize}; use thiserror::Error; -use utoipa::ToSchema; pub struct DocSearchResponse { pub hits: Vec, } -#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)] pub struct DocSearchHit { pub score: f32, pub doc: DocSearchDocument, } -#[derive(Serialize, Deserialize, Debug, Clone, ToSchema)] +#[derive(Clone)] pub struct DocSearchDocument { pub title: String, pub link: String, diff --git a/crates/tabby/src/serve.rs b/crates/tabby/src/serve.rs index 9b20ffafd0a9..6fbab8ae136c 100644 --- a/crates/tabby/src/serve.rs +++ b/crates/tabby/src/serve.rs @@ -54,12 +54,6 @@ Install following IDE / Editor extensions to get started with [Tabby](https://gi ), paths(routes::log_event, routes::completions, routes::chat_completions_utoipa, routes::health, routes::setting), components(schemas( - api::code::CodeSearchHit, - api::code::CodeSearchQuery, - api::code::CodeSearchScores, - api::code::CodeSearchDocument, - api::doc::DocSearchHit, - api::doc::DocSearchDocument, api::event::LogEventRequest, completion::CompletionRequest, completion::CompletionResponse,