This commit is contained in:
+20
-5
@@ -1,6 +1,4 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{bot::Bot, gitea::WebhookType, state::AppState};
|
||||
use crate::{bot::Bot, gitea::{GiteaAPI, WebhookType}, open_router::OpenRouterClient, state::AppState};
|
||||
|
||||
use dotenvy::dotenv;
|
||||
use tokio::signal::unix::{SignalKind, signal};
|
||||
@@ -51,17 +49,34 @@ fn main() -> anyhow::Result<()> {
|
||||
async fn run() -> anyhow::Result<()> {
|
||||
let config = env::load_config()?;
|
||||
|
||||
let gitea_api = GiteaAPI::new(&config.gitea_url, &config.gitea_token, config.gitea_timeout)?;
|
||||
let gitea_user = gitea_api.get_authorized_user().await?;
|
||||
|
||||
info!(
|
||||
port = config.http_port,
|
||||
model = %config.open_router_model,
|
||||
gitea_url = %config.gitea_url,
|
||||
bot_name = %config.bot_name,
|
||||
bot_name = %gitea_user.login,
|
||||
"Starting Herald"
|
||||
);
|
||||
|
||||
let open_router_client = OpenRouterClient::new(
|
||||
&config.open_router_api_key,
|
||||
&config.open_router_model,
|
||||
config.open_router_timeout,
|
||||
)?;
|
||||
|
||||
let shutdown = CancellationToken::new();
|
||||
|
||||
let bot = Bot::new(config.clone())?;
|
||||
let bot = Bot::new(
|
||||
gitea_user.login,
|
||||
gitea_api,
|
||||
open_router_client,
|
||||
reqwest::Client::new(),
|
||||
config.bot_max_concurrent,
|
||||
config.open_router_model.clone(),
|
||||
);
|
||||
|
||||
let (tx, rx) = tokio::sync::mpsc::channel::<WebhookType>(config.bot_max_concurrent * 2);
|
||||
let app_state = AppState {
|
||||
bot_tx: tx,
|
||||
|
||||
Reference in New Issue
Block a user