feat: OpenAI-kompatible API mit Keys, Registry und serve-Befehl (M2.3)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 17:27:46 +01:00
parent ada5745c53
commit 4d53d5afa3
35 changed files with 3434 additions and 21 deletions

View File

@ -0,0 +1,31 @@
use std::sync::{Arc, Mutex, MutexGuard};
use nexus_store::Store;
use crate::runtime::Runtime;
/// Gemeinsamer Zustand aller Anfragen.
pub struct AppState {
store: Mutex<Store>,
pub runtime: Runtime,
pub http: reqwest::Client,
}
impl AppState {
pub fn new(store: Store, runtime: Runtime) -> Arc<Self> {
let http = reqwest::Client::builder()
.connect_timeout(std::time::Duration::from_secs(5))
.build()
.expect("HTTP-Client konnte nicht gebaut werden");
Arc::new(Self {
store: Mutex::new(store),
runtime,
http,
})
}
/// Zugriff auf die Datenbank. Nie über ein `await` hinweg halten.
pub fn store(&self) -> MutexGuard<'_, Store> {
self.store.lock().unwrap_or_else(|e| e.into_inner())
}
}