replace OpenAIRequest with more generalized Box<dyn CompletionRequest>

This commit is contained in:
KCaverly 2023-10-22 14:33:19 +02:00
parent 05ae978cb7
commit d813ae8845
6 changed files with 58 additions and 23 deletions

View file

@ -1,11 +1,13 @@
use anyhow::Result;
use futures::{future::BoxFuture, stream::BoxStream};
use crate::providers::open_ai::completion::OpenAIRequest;
pub trait CompletionRequest: Send + Sync {
fn data(&self) -> serde_json::Result<String>;
}
pub trait CompletionProvider {
fn complete(
&self,
prompt: OpenAIRequest,
prompt: Box<dyn CompletionRequest>,
) -> BoxFuture<'static, Result<BoxStream<'static, Result<String>>>>;
}