mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
V6
This commit is contained in:
@@ -26,6 +26,7 @@ pub use crate::prompt::Prompt;
|
||||
pub use crate::responses::ResponsesApiClient;
|
||||
pub use crate::responses::ResponsesApiClientConfig;
|
||||
pub use crate::responses::stream_from_fixture;
|
||||
pub use crate::stream::EventStream;
|
||||
pub use crate::stream::Reasoning;
|
||||
pub use crate::stream::ResponseEvent;
|
||||
pub use crate::stream::ResponseStream;
|
||||
|
||||
@@ -61,14 +61,23 @@ pub enum ResponseEvent {
|
||||
RateLimits(RateLimitSnapshot),
|
||||
}
|
||||
|
||||
pub struct ResponseStream {
|
||||
pub(crate) rx_event: mpsc::Receiver<Result<ResponseEvent>>,
|
||||
#[derive(Debug)]
|
||||
pub struct EventStream<T> {
|
||||
pub(crate) rx_event: mpsc::Receiver<T>,
|
||||
}
|
||||
|
||||
impl Stream for ResponseStream {
|
||||
type Item = Result<ResponseEvent>;
|
||||
impl<T> EventStream<T> {
|
||||
pub fn from_receiver(rx_event: mpsc::Receiver<T>) -> Self {
|
||||
Self { rx_event }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Stream for EventStream<T> {
|
||||
type Item = T;
|
||||
|
||||
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
self.rx_event.poll_recv(cx)
|
||||
}
|
||||
}
|
||||
|
||||
pub type ResponseStream = EventStream<Result<ResponseEvent>>;
|
||||
|
||||
Reference in New Issue
Block a user