pub enum Client {
Openai(Box<Model<Responses>>, String),
Chat(Box<Model<Chat>>, String),
Anthropic(Box<Model<Messages>>, String),
Gemini(Box<Model<GenerateContent>>, String),
Codex(Codex),
}Expand description
A backend’s client for one review. The API-key backends keep the key they send (empty for an endpoint without one): a provider error may echo it, and every error leaves through the shared rule for server text.
Variants§
Openai(Box<Model<Responses>>, String)
Chat(Box<Model<Chat>>, String)
Anthropic(Box<Model<Messages>>, String)
Gemini(Box<Model<GenerateContent>>, String)
Codex(Codex)
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(
backend: &Backend,
model: &ModelId,
state: &Path,
repo: &Path,
) -> Result<Self, Failure>
pub fn new( backend: &Backend, model: &ModelId, state: &Path, repo: &Path, ) -> Result<Self, Failure>
state holds saved keys, custom providers and Codex credentials; repo keeps them
outside the reviewed repository.
Sourcepub fn parameters(
api: Api,
reasoning: Option<&str>,
session: &SessionId,
) -> Result<Value, String>
pub fn parameters( api: Api, reasoning: Option<&str>, session: &SessionId, ) -> Result<Value, String>
The provider parameters of every request of one review. The Responses backends key
their prompt cache on the review’s session id; Anthropic, Gemini and Chat
Completions cache by prefix alone.
Sourcepub fn output_format(api: Api, parameters: &mut Value, schema: Value)
pub fn output_format(api: Api, parameters: &mut Value, schema: Value)
Structured output constrains the final answer only; tool calls keep their contract. Merge Anthropic’s format with the reasoning effort already in output_config, and Gemini’s with the thinking level already in generationConfig.
Sourcepub async fn turn(
&self,
request: &CompletionRequest,
context: Turn<'_>,
attempts: &mut Vec<Attempt>,
) -> Result<CompletionResponse, Failure>
pub async fn turn( &self, request: &CompletionRequest, context: Turn<'_>, attempts: &mut Vec<Attempt>, ) -> Result<CompletionResponse, Failure>
One turn, sent again while an attempt fails with a rate limit or a transient error
before producing any output or usage, or with a failure of the provider’s output
(Failure::output_failed): at any turn, since every request replays the whole
conversation up to its last tool results. A retry waits as long as the provider’s
Retry-After asks, or a short backoff, within the review’s deadline. Every attempt
keeps its counters, and its tokens count against the review’s maxTokens: an output
failure is not sent again once they reach it. A delivered response that fails
[validate_response] for another reason fails its attempt and is not retried.
Sourcepub async fn turn_observed(
&self,
request: &CompletionRequest,
context: Turn<'_>,
attempts: &mut Vec<Attempt>,
observe: &mut impl FnMut(Delivery),
) -> Result<CompletionResponse, Failure>
pub async fn turn_observed( &self, request: &CompletionRequest, context: Turn<'_>, attempts: &mut Vec<Attempt>, observe: &mut impl FnMut(Delivery), ) -> Result<CompletionResponse, Failure>
Optional display delivery leaves the provider/retry/budget contract unchanged.