text-generation-inference/backends/llamacpp/src/backend.rs

32 lines
960 B
Rust
Raw Normal View History

2024-10-24 07:56:40 +00:00
use crate::ffi::{create_llamacpp_backend, LlamaCppBackendImpl};
use cxx::UniquePtr;
use std::path::Path;
2024-10-04 08:42:31 +00:00
use text_generation_router::infer::{Backend, InferError, InferStreamResponse};
use text_generation_router::validation::ValidGenerateRequest;
use tokio_stream::wrappers::UnboundedReceiverStream;
2024-10-24 07:56:40 +00:00
pub struct TgiLlamaCppBakend {
backend: UniquePtr<LlamaCppBackendImpl>,
}
impl TgiLlamaCppBakend {
pub fn new<P: AsRef<Path>>(model_path: P) -> Result<Self, ()> {
Ok(Self {
backend: create_llamacpp_backend(model_path.as_ref().to_str().unwrap()),
})
}
}
2024-10-04 08:42:31 +00:00
impl Backend for TgiLlamaCppBakend {
fn schedule(
&self,
request: ValidGenerateRequest,
) -> Result<UnboundedReceiverStream<Result<InferStreamResponse, InferError>>, InferError> {
Err(InferError::GenerationError("Not implemented yet".into()))
}
async fn health(&self, current_health: bool) -> bool {
todo!()
}
}