artifacts: rewrite the artifacts model to be source agnostic for now
This commit is contained in:
+21
-6
@@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Serializer, ser::CompactFormatter};
|
||||
use tokio::sync::{RwLock, mpsc, watch};
|
||||
|
||||
use crate::{SaveData, archive::BeatsQueryArgs, artifacts::BandcampQueryArgs, scene::{PredictionAction, Scene, Scenery, StageDirection, conversation::ConversationEntry}};
|
||||
use crate::{SaveData, archive::BeatsQueryArgs, artifacts::{Artifact, Artist, BandcampQueryArgs, MixxxDB}, scene::{PredictionAction, Scene, Scenery, StageDirection, conversation::ConversationEntry}};
|
||||
|
||||
|
||||
const SYSTEM_PROMPT: &str = include_str!("system-prompt.txt");
|
||||
@@ -110,7 +110,13 @@ impl Session {
|
||||
let artifact_count = json_results.len();
|
||||
messages.push(ConversationEntry::ShipComputer(format!("Relay scan for '{}' complete. {} artifacts added to the archive.", args.query, artifact_count).into()));
|
||||
|
||||
self.scenery.artifacts.append(&mut json_results);
|
||||
for track in &json_results {
|
||||
if let Some(merge_target) = self.scenery.artifacts.iter_mut().find(|a| { *a == track }) {
|
||||
merge_target.merge(track);
|
||||
} else {
|
||||
self.scenery.artifacts.push(track.clone());
|
||||
}
|
||||
}
|
||||
|
||||
ToolResults {
|
||||
result: Some(format!("{} artifacts were added to the archive.", artifact_count)),
|
||||
@@ -379,10 +385,19 @@ pub async fn start_prediction(saved_session: SaveData, mut messages: tokio::sync
|
||||
},
|
||||
PredictionAction::SetEpisodeNumber(num) => {
|
||||
session.direction.episode_number = num;
|
||||
if let Err(err) = session.direction.reload_mixxx_playlist() {
|
||||
session.log(format!("Failed to load mixxx playlist: {:?}.", err));
|
||||
} else {
|
||||
session.log("Mixxx playlist reloaded.");
|
||||
match MixxxDB::load(num) {
|
||||
Err(err) => session.log(format!("Failed to load mixxx playlist: {:?}.", err)),
|
||||
Ok(playlist) => {
|
||||
for track in &playlist {
|
||||
if let Some(merge_target) = session.scenery.artifacts.iter_mut().find(|a| { *a == track }) {
|
||||
merge_target.merge(track);
|
||||
} else {
|
||||
session.scenery.artifacts.push(track.clone());
|
||||
}
|
||||
}
|
||||
session.scenery.current_playlist = playlist;
|
||||
session.log("Mixxx playlist reloaded.");
|
||||
}
|
||||
}
|
||||
false
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user