chore: groundwork for embeddings
This commit is contained in:
36
src/server/models.rs
Normal file
36
src/server/models.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use crate::openai;
|
||||
use axum::Json;
|
||||
use axum_extra::routing::TypedPath;
|
||||
use itertools::iproduct;
|
||||
use serde::Deserialize;
|
||||
use strum::VariantArray;
|
||||
|
||||
#[derive(Deserialize, TypedPath)]
|
||||
#[typed_path("/v1/models")]
|
||||
pub struct V1ModelsPath;
|
||||
|
||||
#[tracing::instrument]
|
||||
pub async fn list_models(_: V1ModelsPath) -> Json<openai::models::ListModelsResponse<String>> {
|
||||
let shortcuts = super::chat::completions::Shortcut::VARIANTS.iter().cloned();
|
||||
let reasoning_efforts = openai::chat::completion::ReasoningEffort::VARIANTS
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(Some)
|
||||
.chain(None);
|
||||
|
||||
let models = iproduct!(shortcuts, reasoning_efforts).map(|(shortcut, reasoning)| {
|
||||
openai::models::Model {
|
||||
id: super::chat::completions::ShortcutAndMaybeReasoning(shortcut, reasoning)
|
||||
.to_string(),
|
||||
created: 0,
|
||||
object: openai::models::ModelObject::Model,
|
||||
owned_by: "nobody".into(),
|
||||
shutdown_date: None,
|
||||
}
|
||||
});
|
||||
|
||||
Json(openai::models::ListModelsResponse {
|
||||
data: models.collect(),
|
||||
object: openai::models::ListObject::List,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user