feat: add debug flag disable_prompt_rewrite (#545)
parent
1ad871e1ff
commit
1a87c99488
|
|
@ -35,8 +35,8 @@ pub struct CompletionRequest {
|
||||||
/// When segments are set, the `prompt` is ignored during the inference.
|
/// When segments are set, the `prompt` is ignored during the inference.
|
||||||
segments: Option<Segments>,
|
segments: Option<Segments>,
|
||||||
|
|
||||||
// A unique identifier representing your end-user, which can help Tabby to monitor & generating
|
/// A unique identifier representing your end-user, which can help Tabby to monitor & generating
|
||||||
// reports.
|
/// reports.
|
||||||
user: Option<String>,
|
user: Option<String>,
|
||||||
|
|
||||||
debug: Option<DebugRequest>,
|
debug: Option<DebugRequest>,
|
||||||
|
|
@ -44,8 +44,16 @@ pub struct CompletionRequest {
|
||||||
|
|
||||||
#[derive(Serialize, ToSchema, Deserialize, Clone, Debug)]
|
#[derive(Serialize, ToSchema, Deserialize, Clone, Debug)]
|
||||||
pub struct DebugRequest {
|
pub struct DebugRequest {
|
||||||
// When true, returns debug_data in completion response.
|
/// When true, returns debug_data in completion response.
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
|
|
||||||
|
/// When true, turn off prompt rewrite with source code index.
|
||||||
|
#[serde(default = "default_false")]
|
||||||
|
disable_prompt_rewrite: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
fn default_false() -> bool {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
|
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
|
||||||
|
|
@ -128,7 +136,15 @@ pub async fn completions(
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("PREFIX: {}, SUFFIX: {:?}", segments.prefix, segments.suffix);
|
debug!("PREFIX: {}, SUFFIX: {:?}", segments.prefix, segments.suffix);
|
||||||
let snippets = state.prompt_builder.collect(&language, &segments);
|
let snippets = if !request
|
||||||
|
.debug
|
||||||
|
.as_ref()
|
||||||
|
.is_some_and(|x| x.disable_prompt_rewrite)
|
||||||
|
{
|
||||||
|
state.prompt_builder.collect(&language, &segments)
|
||||||
|
} else {
|
||||||
|
vec![]
|
||||||
|
};
|
||||||
let prompt = state
|
let prompt = state
|
||||||
.prompt_builder
|
.prompt_builder
|
||||||
.build(&language, segments.clone(), &snippets);
|
.build(&language, segments.clone(), &snippets);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue