mirror of
https://github.com/openai/codex.git
synced 2026-04-30 17:36:40 +00:00
V9
This commit is contained in:
39
codex-rs/api-client/src/client/mod.rs
Normal file
39
codex-rs/api-client/src/client/mod.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use async_trait::async_trait;
|
||||
use codex_otel::otel_event_manager::OtelEventManager;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
use crate::error::Result;
|
||||
use crate::prompt::Prompt;
|
||||
use crate::stream::ResponseEvent;
|
||||
|
||||
pub mod fixtures;
|
||||
pub mod http;
|
||||
pub mod rate_limits;
|
||||
pub mod sse;
|
||||
|
||||
/// Builds provider-specific JSON payloads from a Prompt.
|
||||
pub trait PayloadBuilder {
|
||||
fn build(&self, prompt: &Prompt) -> Result<serde_json::Value>;
|
||||
}
|
||||
|
||||
/// Decodes framed SSE JSON into ResponseEvent(s).
|
||||
/// Implementations may keep state across frames (e.g., Chat function-call state).
|
||||
#[async_trait]
|
||||
pub trait ResponseDecoder {
|
||||
async fn on_frame(
|
||||
&mut self,
|
||||
json: &str,
|
||||
tx: &mpsc::Sender<Result<ResponseEvent>>,
|
||||
otel: &OtelEventManager,
|
||||
) -> Result<()>;
|
||||
}
|
||||
|
||||
/// Optional trait to expose rate limit parsing where needed.
|
||||
pub trait RateLimitProvider {
|
||||
fn parse(
|
||||
&self,
|
||||
_headers: &reqwest::header::HeaderMap,
|
||||
) -> Option<codex_protocol::protocol::RateLimitSnapshot> {
|
||||
None
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user