19 lines
628 B
Rust
19 lines
628 B
Rust
use crate::http::context::{AppContext, OpenApiResult, bad_request};
|
|
use crate::http::payloads::ApiKeyPayload;
|
|
use crate::llm;
|
|
use poem_openapi::payload::Json;
|
|
|
|
pub async fn get_anthropic_api_key_exists(ctx: &AppContext) -> OpenApiResult<Json<bool>> {
|
|
let exists =
|
|
llm::chat::get_anthropic_api_key_exists(ctx.store.as_ref()).map_err(bad_request)?;
|
|
Ok(Json(exists))
|
|
}
|
|
|
|
pub async fn set_anthropic_api_key(
|
|
payload: Json<ApiKeyPayload>,
|
|
ctx: &AppContext,
|
|
) -> OpenApiResult<Json<bool>> {
|
|
llm::chat::set_anthropic_api_key(ctx.store.as_ref(), payload.0.api_key).map_err(bad_request)?;
|
|
Ok(Json(true))
|
|
}
|