Use reqwest 0.12 with rustls-tls and add timeouts
Also improve review prompt with line calculation instructions, switch feedback to French, and enable reasoning for OpenRouter.
This commit is contained in:
+9
-1
@@ -1,3 +1,5 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use openrouter_rs::{Message, api::chat::ChatCompletionRequest};
|
||||
|
||||
pub struct OpenRouterClient {
|
||||
@@ -6,10 +8,15 @@ pub struct OpenRouterClient {
|
||||
}
|
||||
|
||||
impl OpenRouterClient {
|
||||
pub fn new(token: &str, model: &str) -> anyhow::Result<Self> {
|
||||
pub fn new(token: &str, model: &str, timeout: u64) -> anyhow::Result<Self> {
|
||||
Ok(Self {
|
||||
client: openrouter_rs::OpenRouterClient::builder()
|
||||
.api_key(token)
|
||||
.http_client(
|
||||
reqwest::Client::builder()
|
||||
.timeout(Duration::from_secs(timeout))
|
||||
.build()?,
|
||||
)
|
||||
.build()?,
|
||||
model: String::from(model),
|
||||
})
|
||||
@@ -18,6 +25,7 @@ impl OpenRouterClient {
|
||||
pub async fn chat(&self, msg: &str) -> anyhow::Result<String> {
|
||||
let request = ChatCompletionRequest::builder()
|
||||
.model(&self.model)
|
||||
.enable_reasoning()
|
||||
.messages(vec![Message::new(
|
||||
openrouter_rs::types::Role::Developer,
|
||||
msg,
|
||||
|
||||
Reference in New Issue
Block a user