88 lines
2.2 KiB
Rust
88 lines
2.2 KiB
Rust
use chrono::{DateTime, Duration, Utc};
|
|
use serde::{Deserialize, Serialize};
|
|
use sqlite::OpenFlags;
|
|
|
|
use crate::{artifacts::{Artifact, MixxxDB, MixxxError, MixxxTrack}, prediction::{GeneratedResponses, PossibleResponse}, scene::conversation::ConversationEntry};
|
|
|
|
pub mod conversation;
|
|
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
pub struct StageDirection {
|
|
pub episode_number: u32,
|
|
#[serde(skip)]
|
|
pub end_time: DateTime<Utc>,
|
|
pub narrative: String,
|
|
pub current_playlist: Vec<MixxxTrack>
|
|
}
|
|
|
|
impl StageDirection {
|
|
pub fn time_remaining(&self) -> Duration {
|
|
self.end_time.signed_duration_since(Utc::now())
|
|
}
|
|
}
|
|
|
|
impl Default for StageDirection {
|
|
fn default() -> Self {
|
|
Self {
|
|
episode_number: 0,
|
|
end_time: Utc::now() + Duration::hours(2),
|
|
narrative: Default::default(),
|
|
current_playlist: Default::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
|
|
pub struct Scenery {
|
|
pub artifacts: Vec<Artifact>
|
|
}
|
|
|
|
impl StageDirection {
|
|
pub fn reload_mixxx_playlist(&mut self) -> Result<(), MixxxError> {
|
|
self.current_playlist = MixxxDB::load(self.episode_number)?;
|
|
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, Clone)]
|
|
pub enum PredictionAction {
|
|
ConversationAppend(ConversationEntry),
|
|
SetEpisodeNumber(u32),
|
|
GeneratePredictions,
|
|
SetNarrative(String),
|
|
SetShowEndTime(DateTime<Utc>)
|
|
}
|
|
|
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
|
pub struct Scene {
|
|
reply_options: GeneratedResponses,
|
|
conversation: Vec<ConversationEntry>,
|
|
pub direction: StageDirection,
|
|
pub tokens_consumed: usize,
|
|
scenery: Scenery
|
|
}
|
|
|
|
impl Scene {
|
|
pub fn new(reply_options: GeneratedResponses, conversation: Vec<ConversationEntry>, scenery: Scenery, tokens_consumed: usize, direction: StageDirection) -> Self {
|
|
Self {
|
|
reply_options,
|
|
conversation,
|
|
scenery,
|
|
tokens_consumed,
|
|
direction
|
|
}
|
|
}
|
|
|
|
pub fn scenery(&self) -> &Scenery {
|
|
&self.scenery
|
|
}
|
|
|
|
pub fn conversation(&self) -> &Vec<ConversationEntry> {
|
|
&self.conversation
|
|
}
|
|
|
|
pub fn reply_options(&self) -> &Vec<PossibleResponse> {
|
|
&self.reply_options.responses
|
|
}
|
|
} |