Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "feat: make --model optional" #672

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Revert "feat: make --model optional (#668)"
This reverts commit c55e448.
  • Loading branch information
wsxiaoys authored Oct 30, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 9f85c0bd2309da391dee62caffd1f83e0ab00adc
1 change: 0 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
* Switch cpu backend to llama.cpp: https://github.com/TabbyML/tabby/pull/638
* add `server.completion_timeout` to control the code completion interface timeout: https://github.com/TabbyML/tabby/pull/637
* Switch cuda backend to llama.cpp: https://github.com/TabbyML/tabby/pull/656
* Make `--model` optional, so users can create a chat only instance.

# v0.4.0

2 changes: 1 addition & 1 deletion crates/tabby/src/serve/health.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ use utoipa::ToSchema;

#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
pub struct HealthState {
model: Option<String>,
model: String,
#[serde(skip_serializing_if = "Option::is_none")]
chat_model: Option<String>,
device: String,
49 changes: 15 additions & 34 deletions crates/tabby/src/serve/mod.rs
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ impl Device {
pub struct ServeArgs {
/// Model id for `/completions` API endpoint.
#[clap(long)]
model: Option<String>,
model: String,

/// Model id for `/chat/completions` API endpoints.
#[clap(long)]
@@ -129,9 +129,7 @@ pub async fn main(config: &Config, args: &ServeArgs) {
valid_args(args);

if args.device != Device::ExperimentalHttp {
if let Some(model) = &args.model {
download_model(model).await;
}
download_model(&args.model).await;
if let Some(chat_model) = &args.chat_model {
download_model(chat_model).await;
}
@@ -173,22 +171,20 @@ pub async fn main(config: &Config, args: &ServeArgs) {

fn api_router(args: &ServeArgs, config: &Config) -> Router {
let index_server = Arc::new(IndexServer::new());
let completion_state = if let Some(model) = &args.model {
let completion_state = {
let (
engine,
EngineInfo {
prompt_template, ..
},
) = create_engine(model, args);
) = create_engine(&args.model, args);
let engine = Arc::new(engine);
let state = completions::CompletionState::new(
engine.clone(),
index_server.clone(),
prompt_template,
);
Some(Arc::new(state))
} else {
None
Arc::new(state)
};

let chat_state = if let Some(chat_model) = &args.chat_model {
@@ -219,18 +215,16 @@ fn api_router(args: &ServeArgs, config: &Config) -> Router {
)
});

if let Some(completion_state) = completion_state {
routers.push({
Router::new()
.route(
"/v1/completions",
routing::post(completions::completions).with_state(completion_state),
)
.layer(TimeoutLayer::new(Duration::from_secs(
config.server.completion_timeout,
)))
});
}
routers.push({
Router::new()
.route(
"/v1/completions",
routing::post(completions::completions).with_state(completion_state),
)
.layer(TimeoutLayer::new(Duration::from_secs(
config.server.completion_timeout,
)))
});

if let Some(chat_state) = chat_state {
routers.push({
@@ -285,19 +279,6 @@ trait OpenApiOverride {

impl OpenApiOverride for utoipa::openapi::OpenApi {
fn override_doc(&mut self, args: &ServeArgs) {
if args.model.is_none() {
self.paths.paths.remove("/v1/completions");
if let Some(components) = self.components.as_mut() {
components.schemas.remove("CompletionRequest");
components.schemas.remove("CompletionResponse");
components.schemas.remove("Choice");
components.schemas.remove("DebugData");
components.schemas.remove("DebugOptions");
components.schemas.remove("Segments");
components.schemas.remove("Snippet");
}
}

if args.chat_model.is_none() {
self.paths.paths.remove("/v1beta/chat/completions");

2 changes: 1 addition & 1 deletion crates/tabby/ui/404.html

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading