Skip to content

Commit

Permalink
refactor(api): remove unused serde and utoipa attributes for CodeSear…
Browse files Browse the repository at this point in the history
…ch / DocSearch
  • Loading branch information
wsxiaoys committed Oct 31, 2024
1 parent bb53869 commit 9c8e6fd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 23 deletions.
16 changes: 3 additions & 13 deletions crates/tabby-common/src/api/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,29 @@ 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<CodeSearchHit>,
}

#[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,
pub bm25: f32,
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,
Expand All @@ -56,13 +49,10 @@ pub enum CodeSearchError {
Other(#[from] anyhow::Error),
}

#[derive(Deserialize, ToSchema)]
pub struct CodeSearchQuery {
pub filepath: Option<String>,
pub language: Option<String>,
pub content: String,

#[serde(skip)]
pub source_id: String,
}

Expand Down
5 changes: 1 addition & 4 deletions crates/tabby-common/src/api/doc.rs
Original file line number Diff line number Diff line change
@@ -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<DocSearchHit>,
}

#[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,
Expand Down
6 changes: 0 additions & 6 deletions crates/tabby/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 9c8e6fd

Please sign in to comment.