refactor: remove useless SwaggerConfig
parent
65ac63343f
commit
d6296bb121
|
|
@ -12,14 +12,8 @@ use crate::path::{config_file, repositories_dir};
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub repositories: Vec<Repository>,
|
pub repositories: Vec<Repository>,
|
||||||
|
|
||||||
#[serde(default)]
|
|
||||||
pub swagger: SwaggerConfig,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Default)]
|
|
||||||
pub struct SwaggerConfig {}
|
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn load() -> Result<Self, Error> {
|
pub fn load() -> Result<Self, Error> {
|
||||||
let file = serdeconv::from_toml_file(crate::path::config_file().as_path());
|
let file = serdeconv::from_toml_file(crate::path::config_file().as_path());
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ mod tests {
|
||||||
use std::fs::create_dir_all;
|
use std::fs::create_dir_all;
|
||||||
|
|
||||||
use tabby_common::{
|
use tabby_common::{
|
||||||
config::{Config, Repository, SwaggerConfig},
|
config::{Config, Repository},
|
||||||
path::set_tabby_root,
|
path::set_tabby_root,
|
||||||
};
|
};
|
||||||
use temp_testdir::*;
|
use temp_testdir::*;
|
||||||
|
|
@ -20,7 +20,6 @@ mod tests {
|
||||||
repositories: vec![Repository {
|
repositories: vec![Repository {
|
||||||
git_url: "https://github.com/TabbyML/interview-questions".to_owned(),
|
git_url: "https://github.com/TabbyML/interview-questions".to_owned(),
|
||||||
}],
|
}],
|
||||||
swagger: SwaggerConfig {},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config.save();
|
config.save();
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,7 @@ use std::{
|
||||||
use axum::{routing, Router, Server};
|
use axum::{routing, Router, Server};
|
||||||
use axum_tracing_opentelemetry::opentelemetry_tracing_layer;
|
use axum_tracing_opentelemetry::opentelemetry_tracing_layer;
|
||||||
use clap::Args;
|
use clap::Args;
|
||||||
use tabby_common::{
|
use tabby_common::{config::Config, usage};
|
||||||
config::{Config, SwaggerConfig},
|
|
||||||
usage,
|
|
||||||
};
|
|
||||||
use tabby_download::Downloader;
|
use tabby_download::Downloader;
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use tower_http::{cors::CorsLayer, timeout::TimeoutLayer};
|
use tower_http::{cors::CorsLayer, timeout::TimeoutLayer};
|
||||||
|
|
@ -128,7 +125,7 @@ fn should_download_ggml_files(device: &Device) -> bool {
|
||||||
*device == Device::Metal
|
*device == Device::Metal
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn main(config: &Config, args: &ServeArgs) {
|
pub async fn main(_config: &Config, args: &ServeArgs) {
|
||||||
valid_args(args);
|
valid_args(args);
|
||||||
|
|
||||||
if args.device != Device::ExperimentalHttp {
|
if args.device != Device::ExperimentalHttp {
|
||||||
|
|
@ -143,7 +140,7 @@ pub async fn main(config: &Config, args: &ServeArgs) {
|
||||||
info!("Starting server, this might takes a few minutes...");
|
info!("Starting server, this might takes a few minutes...");
|
||||||
|
|
||||||
let mut doc = ApiDoc::openapi();
|
let mut doc = ApiDoc::openapi();
|
||||||
doc.override_doc(args, &config.swagger);
|
doc.override_doc(args);
|
||||||
|
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/", routing::get(playground::handler))
|
.route("/", routing::get(playground::handler))
|
||||||
|
|
@ -286,11 +283,11 @@ async fn download_model(model: &str, device: &Device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
trait OpenApiOverride {
|
trait OpenApiOverride {
|
||||||
fn override_doc(&mut self, args: &ServeArgs, config: &SwaggerConfig);
|
fn override_doc(&mut self, args: &ServeArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OpenApiOverride for utoipa::openapi::OpenApi {
|
impl OpenApiOverride for utoipa::openapi::OpenApi {
|
||||||
fn override_doc(&mut self, args: &ServeArgs, _config: &SwaggerConfig) {
|
fn override_doc(&mut self, args: &ServeArgs) {
|
||||||
if args.chat_model.is_none() {
|
if args.chat_model.is_none() {
|
||||||
self.paths.paths.remove("/v1beta/chat/completions");
|
self.paths.paths.remove("/v1beta/chat/completions");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue