fix: cors in /, stop words removal (#171)
parent
f3b37b253b
commit
b8d67770ee
|
|
@ -37,7 +37,7 @@ pub enum Event<'a> {
|
|||
completion_id: &'a str,
|
||||
choice_index: u32,
|
||||
},
|
||||
Selected {
|
||||
Select {
|
||||
completion_id: &'a str,
|
||||
choice_index: u32,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@ use regex::Regex;
|
|||
use std::collections::HashMap;
|
||||
|
||||
lazy_static! {
|
||||
static ref DEFAULT: Regex = Regex::new(r"(?m)^\n\n").unwrap();
|
||||
static ref DEFAULT: Regex = Regex::new(r"(?m)\n\n").unwrap();
|
||||
static ref LANGUAGES: HashMap<&'static str, Regex> = {
|
||||
let mut map = HashMap::new();
|
||||
map.insert("unknown", Regex::new(r"(?m)^(\n\n)").unwrap());
|
||||
map.insert(
|
||||
"python",
|
||||
Regex::new(r"(?m)^(\n\n|def|#|from|class)").unwrap(),
|
||||
Regex::new(r"(?m)(\n\n|^def|^#|^from|^class)").unwrap(),
|
||||
);
|
||||
map
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ pub async fn log_event(Json(request): Json<LogEventRequest>) -> StatusCode {
|
|||
}
|
||||
.log();
|
||||
StatusCode::OK
|
||||
} else if request.event_type == "selected" {
|
||||
events::Event::Selected {
|
||||
} else if request.event_type == "select" {
|
||||
events::Event::Select {
|
||||
completion_id: &request.completion_id,
|
||||
choice_index: request.choice_index,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,8 @@ pub async fn main(args: &ServeArgs) -> Result<(), Error> {
|
|||
let app = Router::new()
|
||||
.merge(SwaggerUi::new("/swagger-ui").url("/api-docs/openapi.json", ApiDoc::openapi()))
|
||||
.nest("/v1", api_router(args))
|
||||
.fallback(fallback(args.experimental_admin_panel));
|
||||
.fallback(fallback(args.experimental_admin_panel))
|
||||
.layer(CorsLayer::permissive());
|
||||
|
||||
let address = SocketAddr::from((Ipv4Addr::UNSPECIFIED, args.port));
|
||||
println!("Listening at {}", address);
|
||||
|
|
@ -81,7 +82,6 @@ fn api_router(args: &ServeArgs) -> Router {
|
|||
routing::post(completions::completion)
|
||||
.with_state(Arc::new(completions::CompletionState::new(args))),
|
||||
)
|
||||
.layer(CorsLayer::permissive())
|
||||
}
|
||||
|
||||
fn fallback(experimental_admin_panel: bool) -> routing::MethodRouter {
|
||||
|
|
|
|||
Loading…
Reference in New Issue