Skip to content

Commit

Permalink
put crack-gpt stuff behind feature
Browse files Browse the repository at this point in the history
  • Loading branch information
cycle-five committed May 30, 2024
1 parent 793b8df commit a5b5214
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crack-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ use crate::handlers::event_log::LogEntry;
use chrono::{DateTime, Utc};
use commands::play_utils::TrackReadyData;
use commands::MyAuxMetadata;
#[cfg(feature = "crack-gpt")]
use crack_gpt::GptContext;
use db::worker_pool::MetadataMsg;
use db::{PlayLog, TrackReaction};
use errors::CrackedError;
Expand All @@ -24,10 +26,7 @@ use std::{
path::Path,
sync::{Arc, Mutex as SyncMutex, RwLock as SyncRwLock},
};
use tokio::sync::{Mutex, RwLock};
// Channel for sending queries to the database write worke pool.
use crack_gpt::GptContext;
use tokio::sync::mpsc::Sender;
use tokio::sync::{mpsc::Sender, Mutex, RwLock};

pub mod commands;
pub mod connection;
Expand Down Expand Up @@ -320,6 +319,7 @@ pub struct DataInner {
#[serde(skip)]
pub guild_cache_map: Arc<Mutex<HashMap<GuildId, guild::cache::GuildCache>>>,
#[serde(skip)]
#[cfg(feature = "crack-gpt")]
pub gpt_ctx: Arc<RwLock<Option<GptContext>>>,
}

Expand All @@ -346,6 +346,7 @@ impl std::fmt::Debug for DataInner {
result.push_str(&format!("guild_cache_map: {:?}\n", self.guild_cache_map));
result.push_str(&format!("event_log: {:?}\n", self.event_log));
result.push_str(&format!("database_pool: {:?}\n", self.database_pool));
#[cfg(feature = "crack-gpt")]
result.push_str(&format!("gpt_context: {:?}\n", self.gpt_ctx));
result.push_str(&format!("http_client: {:?}\n", self.http_client));
result.push_str("topgg_client: <skipped>\n");
Expand Down Expand Up @@ -379,6 +380,7 @@ impl DataInner {
}

/// Set the GPT context for the data.
#[cfg(feature = "crack-gpt")]
pub fn with_gpt_ctx(&self, gpt_ctx: GptContext) -> Self {
Self {
gpt_ctx: Arc::new(RwLock::new(Some(gpt_ctx))),
Expand Down Expand Up @@ -600,6 +602,7 @@ impl Default for DataInner {
database_pool: None,
http_client: http_utils::get_client().clone(),
db_channel: None,
#[cfg(feature = "crack-gpt")]
gpt_ctx: Arc::new(RwLock::new(None)),
// topgg_client: topgg::Client::new(topgg_token),
}
Expand Down

0 comments on commit a5b5214

Please sign in to comment.