Add prefix / suffix

add-prefix-suffix
Meng Zhang 2023-05-29 18:09:53 -07:00
parent 8956056120
commit 9a488e21f5
2 changed files with 15 additions and 2 deletions

View File

@ -11,12 +11,24 @@ mod languages;
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)] #[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
pub struct CompletionRequest { pub struct CompletionRequest {
#[schema(example = "def fib(n):")]
prompt: String,
/// https://code.visualstudio.com/docs/languages/identifiers /// https://code.visualstudio.com/docs/languages/identifiers
#[schema(example = "python")] #[schema(example = "python")]
language: Option<String>, language: Option<String>,
#[schema(example = "def fib(n):")] /// When segments are set, the `prompt` is ignored during the inference.
prompt: String, segments: Option<Segments>,
}
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
pub struct Segments {
/// Content that appears before the cursor in the editor window.
prefix: String,
/// Content that appears after the cursor in the editor window.
suffix: String
} }
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)] #[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]

View File

@ -21,6 +21,7 @@ use utoipa_swagger_ui::SwaggerUi;
events::LogEventRequest, events::LogEventRequest,
completions::CompletionRequest, completions::CompletionRequest,
completions::CompletionResponse, completions::CompletionResponse,
completions::Segments,
completions::Choice completions::Choice
)) ))
)] )]