refactor: extract events api

extract-routes
Meng Zhang 2023-11-12 21:03:46 -08:00
parent 98c50f8050
commit f45c62af36
6 changed files with 27 additions and 20 deletions

View File

@ -0,0 +1,19 @@
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
pub struct LogEventRequest {
/// Event type, should be `view` or `select`.
#[schema(example = "view")]
#[serde(rename = "type")]
pub event_type: String,
pub completion_id: String,
pub choice_index: u32,
}

View File

@ -1,3 +1,5 @@
mod code;
mod event;
pub use code::*;
pub use event::*;

View File

@ -2,21 +2,11 @@ use std::collections::HashMap;
use axum::{extract::Query, Json};
use hyper::StatusCode;
use serde::{Deserialize, Serialize};
use tabby_common::events::{self, SelectKind};
use utoipa::ToSchema;
#[derive(Serialize, Deserialize, ToSchema, Clone, Debug)]
pub struct LogEventRequest {
/// Event type, should be `view` or `select`.
#[schema(example = "view")]
#[serde(rename = "type")]
event_type: String,
completion_id: String,
choice_index: u32,
}
use crate::api::LogEventRequest;
#[utoipa::path(
post,

View File

@ -1,10 +1,7 @@
use std::{sync::Arc};
use std::sync::Arc;
use axum::{extract::State, Json};
use sysinfo::{SystemExt};
use sysinfo::SystemExt;
use utoipa::ToSchema;
use crate::services::health;

View File

@ -41,7 +41,7 @@ Install following IDE / Editor extensions to get started with [Tabby](https://gi
),
paths(routes::log_event, routes::completions, routes::completions, routes::health, routes::search),
components(schemas(
routes::LogEventRequest,
api::LogEventRequest,
completions::CompletionRequest,
completions::CompletionResponse,
completions::Segments,

View File

@ -1,7 +1,6 @@
use std::{env::consts::ARCH};
use std::env::consts::ARCH;
use anyhow::Result;
use nvml_wrapper::Nvml;
use serde::{Deserialize, Serialize};
use sysinfo::{CpuExt, System, SystemExt};