feat: make --model optional (#668)
parent
7330d75de6
commit
c55e4481ba
|
|
@ -10,6 +10,7 @@
|
|||
* 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
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use utoipa::ToSchema;
|
|||
|
||||
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
|
||||
pub struct HealthState {
|
||||
model: String,
|
||||
model: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
chat_model: Option<String>,
|
||||
device: String,
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ impl Device {
|
|||
pub struct ServeArgs {
|
||||
/// Model id for `/completions` API endpoint.
|
||||
#[clap(long)]
|
||||
model: String,
|
||||
model: Option<String>,
|
||||
|
||||
/// Model id for `/chat/completions` API endpoints.
|
||||
#[clap(long)]
|
||||
|
|
@ -129,7 +129,9 @@ pub async fn main(config: &Config, args: &ServeArgs) {
|
|||
valid_args(args);
|
||||
|
||||
if args.device != Device::ExperimentalHttp {
|
||||
download_model(&args.model).await;
|
||||
if let Some(model) = &args.model {
|
||||
download_model(model).await;
|
||||
}
|
||||
if let Some(chat_model) = &args.chat_model {
|
||||
download_model(chat_model).await;
|
||||
}
|
||||
|
|
@ -171,20 +173,22 @@ 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 = {
|
||||
let completion_state = if let Some(model) = &args.model {
|
||||
let (
|
||||
engine,
|
||||
EngineInfo {
|
||||
prompt_template, ..
|
||||
},
|
||||
) = create_engine(&args.model, args);
|
||||
) = create_engine(model, args);
|
||||
let engine = Arc::new(engine);
|
||||
let state = completions::CompletionState::new(
|
||||
engine.clone(),
|
||||
index_server.clone(),
|
||||
prompt_template,
|
||||
);
|
||||
Arc::new(state)
|
||||
Some(Arc::new(state))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let chat_state = if let Some(chat_model) = &args.chat_model {
|
||||
|
|
@ -215,16 +219,18 @@ fn api_router(args: &ServeArgs, config: &Config) -> Router {
|
|||
)
|
||||
});
|
||||
|
||||
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(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,
|
||||
)))
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(chat_state) = chat_state {
|
||||
routers.push({
|
||||
|
|
@ -279,6 +285,19 @@ 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");
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +1,7 @@
|
|||
1:HL["/_next/static/media/86fdec36ddd9097e-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
||||
2:HL["/_next/static/media/c9a5bc6a7c948fb0-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
||||
3:HL["/_next/static/css/2b051a9b83c80bf9.css","style"]
|
||||
0:["QrHYrv6IM9fXxh7mpanWB",[[["",{"children":["api",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L4",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/2b051a9b83c80bf9.css","precedence":"next"}]],"$L5"]]]]
|
||||
0:["OqK3ih1CowLA0x8lARuCQ",[[["",{"children":["api",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L4",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/2b051a9b83c80bf9.css","precedence":"next"}]],"$L5"]]]]
|
||||
6:I{"id":5925,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","362:static/chunks/362-ae0994d279f3f3bb.js","563:static/chunks/563-52218f82bb9eb225.js","894:static/chunks/894-f0d1adefd8c6331e.js","185:static/chunks/app/layout-f087fba7a4279e51.js"],"name":"Toaster","async":false}
|
||||
7:I{"id":78495,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","362:static/chunks/362-ae0994d279f3f3bb.js","563:static/chunks/563-52218f82bb9eb225.js","894:static/chunks/894-f0d1adefd8c6331e.js","185:static/chunks/app/layout-f087fba7a4279e51.js"],"name":"Providers","async":false}
|
||||
8:I{"id":79446,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","362:static/chunks/362-ae0994d279f3f3bb.js","563:static/chunks/563-52218f82bb9eb225.js","894:static/chunks/894-f0d1adefd8c6331e.js","185:static/chunks/app/layout-f087fba7a4279e51.js"],"name":"Header","async":false}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,14 +1,14 @@
|
|||
1:HL["/_next/static/media/86fdec36ddd9097e-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
||||
2:HL["/_next/static/media/c9a5bc6a7c948fb0-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
||||
3:HL["/_next/static/css/2b051a9b83c80bf9.css","style"]
|
||||
0:["QrHYrv6IM9fXxh7mpanWB",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L4",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/2b051a9b83c80bf9.css","precedence":"next"}]],"$L5"]]]]
|
||||
0:["OqK3ih1CowLA0x8lARuCQ",[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],"$L4",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/2b051a9b83c80bf9.css","precedence":"next"}]],"$L5"]]]]
|
||||
6:I{"id":5925,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","362:static/chunks/362-ae0994d279f3f3bb.js","563:static/chunks/563-52218f82bb9eb225.js","894:static/chunks/894-f0d1adefd8c6331e.js","185:static/chunks/app/layout-f087fba7a4279e51.js"],"name":"Toaster","async":false}
|
||||
7:I{"id":78495,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","362:static/chunks/362-ae0994d279f3f3bb.js","563:static/chunks/563-52218f82bb9eb225.js","894:static/chunks/894-f0d1adefd8c6331e.js","185:static/chunks/app/layout-f087fba7a4279e51.js"],"name":"Providers","async":false}
|
||||
8:I{"id":79446,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","362:static/chunks/362-ae0994d279f3f3bb.js","563:static/chunks/563-52218f82bb9eb225.js","894:static/chunks/894-f0d1adefd8c6331e.js","185:static/chunks/app/layout-f087fba7a4279e51.js"],"name":"Header","async":false}
|
||||
9:I{"id":81443,"chunks":["272:static/chunks/webpack-04ed420267a761a9.js","971:static/chunks/fd9d1056-5dfc77aa37d8c76f.js","864:static/chunks/864-bf315a5307aba1d7.js"],"name":"","async":false}
|
||||
a:I{"id":18639,"chunks":["272:static/chunks/webpack-04ed420267a761a9.js","971:static/chunks/fd9d1056-5dfc77aa37d8c76f.js","864:static/chunks/864-bf315a5307aba1d7.js"],"name":"","async":false}
|
||||
c:I{"id":65146,"chunks":["272:static/chunks/webpack-04ed420267a761a9.js","971:static/chunks/fd9d1056-5dfc77aa37d8c76f.js","864:static/chunks/864-bf315a5307aba1d7.js"],"name":"","async":false}
|
||||
d:I{"id":25454,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","362:static/chunks/362-ae0994d279f3f3bb.js","703:static/chunks/703-35aa8c1eaf8df6ef.js","894:static/chunks/894-f0d1adefd8c6331e.js","931:static/chunks/app/page-478c8032840b58db.js"],"name":"","async":false}
|
||||
d:I{"id":25454,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","362:static/chunks/362-ae0994d279f3f3bb.js","703:static/chunks/703-35aa8c1eaf8df6ef.js","894:static/chunks/894-f0d1adefd8c6331e.js","931:static/chunks/app/page-11121665fe0055a9.js"],"name":"","async":false}
|
||||
4:[null,["$","html",null,{"lang":"en","suppressHydrationWarning":true,"children":[["$","head",null,{}],["$","body",null,{"className":"font-sans antialiased __variable_e66fe9 __variable_bd9c35","children":[["$","$L6",null,{}],["$","$L7",null,{"attribute":"class","defaultTheme":"system","enableSystem":true,"children":[["$","div",null,{"className":"flex min-h-screen flex-col","children":[["$","$L8",null,{}],["$","main",null,{"className":"flex flex-1 flex-col bg-muted/50","children":["$","$L9",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$La",null,{}],"templateStyles":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"childProp":{"current":["$Lb",["$","$Lc",null,{"propsForComponent":{"params":{}},"Component":"$d"}],null],"segment":"__PAGE__"},"styles":[]}]}]]}],null]}]]}]]}],null]
|
||||
5:[["$","meta","0",{"charSet":"utf-8"}],["$","title","1",{"children":"Tabby - Home"}],["$","meta","2",{"name":"description","content":"Tabby, an opensource, self-hosted AI coding assistant."}],["$","meta","3",{"name":"theme-color","media":"(prefers-color-scheme: light)","content":"white"}],["$","meta","4",{"name":"theme-color","media":"(prefers-color-scheme: dark)","content":"black"}],["$","meta","5",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","6",{"name":"next-size-adjust"}]]
|
||||
b:null
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -1,7 +1,7 @@
|
|||
1:HL["/_next/static/media/86fdec36ddd9097e-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
||||
2:HL["/_next/static/media/c9a5bc6a7c948fb0-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}]
|
||||
3:HL["/_next/static/css/2b051a9b83c80bf9.css","style"]
|
||||
0:["QrHYrv6IM9fXxh7mpanWB",[[["",{"children":["playground",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L4",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/2b051a9b83c80bf9.css","precedence":"next"}]],"$L5"]]]]
|
||||
0:["OqK3ih1CowLA0x8lARuCQ",[[["",{"children":["playground",{"children":["__PAGE__",{}]}]},"$undefined","$undefined",true],"$L4",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/2b051a9b83c80bf9.css","precedence":"next"}]],"$L5"]]]]
|
||||
6:I{"id":5925,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","362:static/chunks/362-ae0994d279f3f3bb.js","563:static/chunks/563-52218f82bb9eb225.js","894:static/chunks/894-f0d1adefd8c6331e.js","185:static/chunks/app/layout-f087fba7a4279e51.js"],"name":"Toaster","async":false}
|
||||
7:I{"id":78495,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","362:static/chunks/362-ae0994d279f3f3bb.js","563:static/chunks/563-52218f82bb9eb225.js","894:static/chunks/894-f0d1adefd8c6331e.js","185:static/chunks/app/layout-f087fba7a4279e51.js"],"name":"Providers","async":false}
|
||||
8:I{"id":79446,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","362:static/chunks/362-ae0994d279f3f3bb.js","563:static/chunks/563-52218f82bb9eb225.js","894:static/chunks/894-f0d1adefd8c6331e.js","185:static/chunks/app/layout-f087fba7a4279e51.js"],"name":"Header","async":false}
|
||||
|
|
@ -9,5 +9,5 @@
|
|||
a:I{"id":18639,"chunks":["272:static/chunks/webpack-04ed420267a761a9.js","971:static/chunks/fd9d1056-5dfc77aa37d8c76f.js","864:static/chunks/864-bf315a5307aba1d7.js"],"name":"","async":false}
|
||||
c:I{"id":12202,"chunks":["400:static/chunks/400-bab9e88e0219f9f5.js","406:static/chunks/406-35481e1b86c5b377.js","28:static/chunks/28-27d0fe8a88c4cbfb.js","894:static/chunks/894-f0d1adefd8c6331e.js","383:static/chunks/app/playground/page-b742820613e86585.js"],"name":"Chat","async":false}
|
||||
5:[["$","meta","0",{"charSet":"utf-8"}],["$","title","1",{"children":"Tabby - Playground"}],["$","meta","2",{"name":"description","content":"Tabby, an opensource, self-hosted AI coding assistant."}],["$","meta","3",{"name":"theme-color","media":"(prefers-color-scheme: light)","content":"white"}],["$","meta","4",{"name":"theme-color","media":"(prefers-color-scheme: dark)","content":"black"}],["$","meta","5",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","6",{"name":"next-size-adjust"}]]
|
||||
4:[null,["$","html",null,{"lang":"en","suppressHydrationWarning":true,"children":[["$","head",null,{}],["$","body",null,{"className":"font-sans antialiased __variable_e66fe9 __variable_bd9c35","children":[["$","$L6",null,{}],["$","$L7",null,{"attribute":"class","defaultTheme":"system","enableSystem":true,"children":[["$","div",null,{"className":"flex min-h-screen flex-col","children":[["$","$L8",null,{}],["$","main",null,{"className":"flex flex-1 flex-col bg-muted/50","children":["$","$L9",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$La",null,{}],"templateStyles":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"childProp":{"current":["$","$L9",null,{"parallelRouterKey":"children","segmentPath":["children","playground","children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$La",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$Lb",["$","$Lc",null,{"id":"GG5oy2I"}],null],"segment":"__PAGE__"},"styles":[]}],"segment":"playground"},"styles":[]}]}]]}],null]}]]}]]}],null]
|
||||
4:[null,["$","html",null,{"lang":"en","suppressHydrationWarning":true,"children":[["$","head",null,{}],["$","body",null,{"className":"font-sans antialiased __variable_e66fe9 __variable_bd9c35","children":[["$","$L6",null,{}],["$","$L7",null,{"attribute":"class","defaultTheme":"system","enableSystem":true,"children":[["$","div",null,{"className":"flex min-h-screen flex-col","children":[["$","$L8",null,{}],["$","main",null,{"className":"flex flex-1 flex-col bg-muted/50","children":["$","$L9",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$La",null,{}],"templateStyles":"$undefined","notFound":[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":"404"}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],"notFoundStyles":[],"childProp":{"current":["$","$L9",null,{"parallelRouterKey":"children","segmentPath":["children","playground","children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$La",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$Lb",["$","$Lc",null,{"id":"j07pYnp"}],null],"segment":"__PAGE__"},"styles":[]}],"segment":"playground"},"styles":[]}]}]]}],null]}]]}]]}],null]
|
||||
b:null
|
||||
|
|
|
|||
|
|
@ -95,11 +95,13 @@ function MainPanel() {
|
|||
<img
|
||||
src={`https://img.shields.io/badge/device-${healthInfo.device}-blue`}
|
||||
/>
|
||||
<img
|
||||
src={`https://img.shields.io/badge/model-${toBadgeString(
|
||||
healthInfo.model
|
||||
)}-red`}
|
||||
/>
|
||||
{healthInfo.model && (
|
||||
<img
|
||||
src={`https://img.shields.io/badge/model-${toBadgeString(
|
||||
healthInfo.model
|
||||
)}-red`}
|
||||
/>
|
||||
)}
|
||||
{healthInfo.chat_model && (
|
||||
<img
|
||||
src={`https://img.shields.io/badge/chat%20model-${toBadgeString(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import fetcher from '@/lib/tabby-fetcher'
|
|||
|
||||
export interface HealthInfo {
|
||||
device: string
|
||||
model: string
|
||||
model?: string
|
||||
chat_model?: string
|
||||
version: {
|
||||
build_date: string
|
||||
|
|
|
|||
Loading…
Reference in New Issue