refactor: move code api to tabby/serve (#771)
parent
3a9b4d9ef5
commit
febfa18e4a
|
|
@ -48,6 +48,9 @@ jobs:
|
|||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
|
||||
- name: Cargo Machete
|
||||
uses: bnjbvr/cargo-machete@main
|
||||
|
||||
- run: bash ./ci/prepare_build_environment.sh
|
||||
|
||||
- run: make fix
|
||||
|
|
|
|||
|
|
@ -4307,6 +4307,7 @@ dependencies = [
|
|||
"tabby-webserver",
|
||||
"tantivy",
|
||||
"textdistance",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tower-http 0.4.0",
|
||||
"tracing",
|
||||
|
|
@ -4323,7 +4324,6 @@ name = "tabby-common"
|
|||
version = "0.6.0-dev"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"chrono",
|
||||
"filenamify",
|
||||
"lazy_static",
|
||||
|
|
@ -4332,9 +4332,7 @@ dependencies = [
|
|||
"serde-jsonlines",
|
||||
"serdeconv",
|
||||
"tantivy",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"utoipa",
|
||||
"uuid 1.4.1",
|
||||
]
|
||||
|
||||
|
|
|
|||
4
Makefile
4
Makefile
|
|
@ -6,7 +6,9 @@ else
|
|||
endif
|
||||
|
||||
fix:
|
||||
cargo +nightly clippy --fix --allow-dirty --allow-staged && cargo +nightly fmt
|
||||
cargo machete --fix
|
||||
cargo +nightly fmt
|
||||
cargo +nightly clippy --fix --allow-dirty --allow-staged
|
||||
|
||||
fix-ui:
|
||||
cd ee/tabby-ui && yarn format:write && yarn lint:fix
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@ tokio = { workspace = true, features = ["rt", "macros"] }
|
|||
uuid = { version = "1.4.1", features = ["v4"] }
|
||||
tantivy.workspace = true
|
||||
anyhow.workspace = true
|
||||
async-trait.workspace = true
|
||||
thiserror.workspace = true
|
||||
utoipa = { workspace = true, features = ["axum_extras", "preserve_order"] }
|
||||
|
||||
[features]
|
||||
testutils = []
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
pub mod code;
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
pub mod api;
|
||||
pub mod config;
|
||||
pub mod events;
|
||||
pub mod index;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ llama-cpp-bindings = { path = "../llama-cpp-bindings" }
|
|||
futures.workspace = true
|
||||
async-trait.workspace = true
|
||||
tabby-webserver = { path = "../../ee/tabby-webserver" }
|
||||
thiserror.workspace = true
|
||||
|
||||
[dependencies.uuid]
|
||||
version = "1.3.3"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
mod code;
|
||||
|
||||
pub use code::*;
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
mod api;
|
||||
mod download;
|
||||
mod serve;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,13 @@ use std::sync::Arc;
|
|||
use axum::{extract::State, Json};
|
||||
use hyper::StatusCode;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tabby_common::{api::code::CodeSearch, events, languages::get_language};
|
||||
use tabby_common::{events, languages::get_language};
|
||||
use tabby_inference::{TextGeneration, TextGenerationOptionsBuilder};
|
||||
use tracing::{debug, instrument};
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use crate::api::CodeSearch;
|
||||
|
||||
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
|
||||
#[schema(example=json!({
|
||||
"language": "python",
|
||||
|
|
|
|||
|
|
@ -3,14 +3,12 @@ use std::sync::Arc;
|
|||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use strfmt::strfmt;
|
||||
use tabby_common::{
|
||||
api::code::{CodeSearch, CodeSearchError},
|
||||
languages::get_language,
|
||||
};
|
||||
use tabby_common::languages::get_language;
|
||||
use textdistance::Algorithm;
|
||||
use tracing::warn;
|
||||
|
||||
use super::{Segments, Snippet};
|
||||
use crate::api::{CodeSearch, CodeSearchError};
|
||||
|
||||
static MAX_SNIPPETS_TO_FETCH: usize = 20;
|
||||
static MAX_SNIPPET_CHARS_IN_PROMPT: usize = 768;
|
||||
|
|
|
|||
|
|
@ -15,11 +15,7 @@ use std::{
|
|||
use axum::{routing, Router, Server};
|
||||
use axum_tracing_opentelemetry::opentelemetry_tracing_layer;
|
||||
use clap::Args;
|
||||
use tabby_common::{
|
||||
api::code::{Hit, HitDocument, SearchResponse},
|
||||
config::Config,
|
||||
usage,
|
||||
};
|
||||
use tabby_common::{config::Config, usage};
|
||||
use tabby_download::download_model;
|
||||
use tabby_webserver::attach_webserver;
|
||||
use tokio::time::sleep;
|
||||
|
|
@ -32,7 +28,11 @@ use self::{
|
|||
engine::{create_engine, EngineInfo},
|
||||
health::HealthState,
|
||||
};
|
||||
use crate::{fatal, services::chat::ChatService};
|
||||
use crate::{
|
||||
api::{Hit, HitDocument, SearchResponse},
|
||||
fatal,
|
||||
services::chat::ChatService,
|
||||
};
|
||||
|
||||
#[derive(OpenApi)]
|
||||
#[openapi(
|
||||
|
|
|
|||
|
|
@ -7,10 +7,11 @@ use axum::{
|
|||
};
|
||||
use hyper::StatusCode;
|
||||
use serde::Deserialize;
|
||||
use tabby_common::api::code::{CodeSearch, CodeSearchError, SearchResponse};
|
||||
use tracing::{instrument, warn};
|
||||
use utoipa::IntoParams;
|
||||
|
||||
use crate::api::{CodeSearch, CodeSearchError, SearchResponse};
|
||||
|
||||
#[derive(Deserialize, IntoParams)]
|
||||
pub struct SearchQuery {
|
||||
#[param(default = "get")]
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ use std::{sync::Arc, time::Duration};
|
|||
use anyhow::Result;
|
||||
use async_trait::async_trait;
|
||||
use tabby_common::{
|
||||
api::code::{CodeSearch, CodeSearchError, Hit, HitDocument, SearchResponse},
|
||||
index::{self, register_tokenizers, CodeSearchSchema},
|
||||
path,
|
||||
};
|
||||
|
|
@ -17,6 +16,8 @@ use tantivy::{
|
|||
use tokio::{sync::Mutex, time::sleep};
|
||||
use tracing::{debug, log::info};
|
||||
|
||||
use crate::api::{CodeSearch, CodeSearchError, Hit, HitDocument, SearchResponse};
|
||||
|
||||
struct CodeSearchImpl {
|
||||
reader: IndexReader,
|
||||
query_parser: QueryParser,
|
||||
|
|
|
|||
Loading…
Reference in New Issue