api: add user field in completion api
parent
a15ca5d0b0
commit
d572cf7d6d
|
|
@ -49,6 +49,7 @@ pub enum Event<'a> {
|
||||||
language: &'a str,
|
language: &'a str,
|
||||||
prompt: &'a str,
|
prompt: &'a str,
|
||||||
choices: Vec<Choice<'a>>,
|
choices: Vec<Choice<'a>>,
|
||||||
|
user: Option<&'a str>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,15 @@ use crate::fatal;
|
||||||
mod languages;
|
mod languages;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
|
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
|
||||||
|
#[schema(example=json!({
|
||||||
|
"language": "python",
|
||||||
|
"segments": {
|
||||||
|
"prefix": "def fib(n)\n ",
|
||||||
|
"suffix": "\n return fib(n - 1) + fib(n - 2)"
|
||||||
|
}
|
||||||
|
}))]
|
||||||
pub struct CompletionRequest {
|
pub struct CompletionRequest {
|
||||||
#[schema(example = "def fib(n):")]
|
#[schema(example = "def fib(n):")]
|
||||||
#[deprecated]
|
|
||||||
prompt: Option<String>,
|
prompt: Option<String>,
|
||||||
|
|
||||||
/// Language identifier, full list is maintained at
|
/// Language identifier, full list is maintained at
|
||||||
|
|
@ -29,16 +35,18 @@ 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
|
||||||
|
// reports.
|
||||||
|
user: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
|
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
|
||||||
pub struct Segments {
|
pub struct Segments {
|
||||||
/// Content that appears before the cursor in the editor window.
|
/// Content that appears before the cursor in the editor window.
|
||||||
#[schema(example = "def fib(n):\n ")]
|
|
||||||
prefix: String,
|
prefix: String,
|
||||||
|
|
||||||
/// Content that appears after the cursor in the editor window.
|
/// Content that appears after the cursor in the editor window.
|
||||||
#[schema(example = "\n return fib(n - 1) + fib(n - 2)")]
|
|
||||||
suffix: Option<String>,
|
suffix: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,6 +115,7 @@ pub async fn completion(
|
||||||
index: 0,
|
index: 0,
|
||||||
text: &text,
|
text: &text,
|
||||||
}],
|
}],
|
||||||
|
user: request.user.as_deref(),
|
||||||
}
|
}
|
||||||
.log();
|
.log();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue