Refactoring the structure a bit
This commit is contained in:
18
server/src/http/anthropic.rs
Normal file
18
server/src/http/anthropic.rs
Normal file
@@ -0,0 +1,18 @@
|
||||
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))
|
||||
}
|
||||
Reference in New Issue
Block a user