refactor: remove useless SwaggerConfig

add-llama-model-converter
Meng Zhang 2023-10-25 13:45:24 -07:00
parent 65ac63343f
commit d6296bb121
3 changed files with 6 additions and 16 deletions

View File

@ -12,14 +12,8 @@ use crate::path::{config_file, repositories_dir};
pub struct Config {
#[serde(default)]
pub repositories: Vec<Repository>,
#[serde(default)]
pub swagger: SwaggerConfig,
}
#[derive(Serialize, Deserialize, Default)]
pub struct SwaggerConfig {}
impl Config {
pub fn load() -> Result<Self, Error> {
let file = serdeconv::from_toml_file(crate::path::config_file().as_path());

View File

@ -3,7 +3,7 @@ mod tests {
use std::fs::create_dir_all;
use tabby_common::{
config::{Config, Repository, SwaggerConfig},
config::{Config, Repository},
path::set_tabby_root,
};
use temp_testdir::*;
@ -20,7 +20,6 @@ mod tests {
repositories: vec![Repository {
git_url: "https://github.com/TabbyML/interview-questions".to_owned(),
}],
swagger: SwaggerConfig {},
};
config.save();

View File

@ -15,10 +15,7 @@ use std::{
use axum::{routing, Router, Server};
use axum_tracing_opentelemetry::opentelemetry_tracing_layer;
use clap::Args;
use tabby_common::{
config::{Config, SwaggerConfig},
usage,
};
use tabby_common::{config::Config, usage};
use tabby_download::Downloader;
use tokio::time::sleep;
use tower_http::{cors::CorsLayer, timeout::TimeoutLayer};
@ -128,7 +125,7 @@ fn should_download_ggml_files(device: &Device) -> bool {
*device == Device::Metal
}
pub async fn main(config: &Config, args: &ServeArgs) {
pub async fn main(_config: &Config, args: &ServeArgs) {
valid_args(args);
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...");
let mut doc = ApiDoc::openapi();
doc.override_doc(args, &config.swagger);
doc.override_doc(args);
let app = Router::new()
.route("/", routing::get(playground::handler))
@ -286,11 +283,11 @@ async fn download_model(model: &str, device: &Device) {
}
trait OpenApiOverride {
fn override_doc(&mut self, args: &ServeArgs, config: &SwaggerConfig);
fn override_doc(&mut self, args: &ServeArgs);
}
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() {
self.paths.paths.remove("/v1beta/chat/completions");