Switch to vscode + fetch bot_name with token
ci/woodpecker/push/tests Pipeline failed

This commit is contained in:
2026-06-30 20:44:25 +00:00
parent 7f24d7657c
commit 743b6b33c9
10 changed files with 75 additions and 154 deletions
+24 -21
View File
@@ -1,10 +1,9 @@
use crate::{
env::EnvConfig,
gitea::{GiteaAPI, WebhookType},
open_router::OpenRouterClient,
};
use serde::Deserialize;
use std::{collections::HashSet, sync::Arc, time::Duration};
use std::{collections::HashSet, sync::Arc};
use tokio::sync::Mutex;
use tokio_util::sync::CancellationToken;
use tracing::{error, info, instrument};
@@ -26,33 +25,37 @@ pub struct ReviewItem {
#[derive(Clone)]
pub struct Bot {
config: EnvConfig,
bot_name: String,
gitea_api: GiteaAPI,
open_router_client: OpenRouterClient,
http_client: reqwest::Client,
max_concurrent: usize,
open_router_model: String,
actions_handled: Arc<Mutex<HashSet<u64>>>,
}
impl Bot {
pub fn new(config: EnvConfig) -> anyhow::Result<Self> {
let gitea_timeout = config.gitea_timeout;
let open_router_timeout = config.open_router_timeout;
Ok(Self {
gitea_api: GiteaAPI::new(&config.gitea_url, &config.gitea_token, gitea_timeout)?,
open_router_client: OpenRouterClient::new(
&config.open_router_api_key,
&config.open_router_model,
open_router_timeout,
)?,
max_concurrent: config.bot_max_concurrent,
config,
pub fn new(
bot_name: String,
gitea_api: GiteaAPI,
open_router_client: OpenRouterClient,
http_client: reqwest::Client,
max_concurrent: usize,
open_router_model: String,
) -> Self {
Self {
bot_name,
gitea_api,
open_router_client,
http_client,
max_concurrent,
open_router_model,
actions_handled: Arc::new(Mutex::new(HashSet::new())),
http_client: reqwest::Client::builder()
.timeout(Duration::from_secs(gitea_timeout))
.build()?,
})
}
}
pub fn name(&self) -> String {
self.bot_name.clone()
}
pub async fn start(
@@ -111,7 +114,7 @@ impl Bot {
&self.gitea_api,
&self.open_router_client,
&self.http_client,
&self.config.open_router_model,
&self.open_router_model,
review_payload,
),
}