prediction: switch everything over to use log::*
This commit is contained in:
+11
-18
@@ -101,10 +101,11 @@ impl Session {
|
||||
|
||||
async fn tool_bandcamp_scan(&mut self, args: BandcampQueryArgs) -> ToolResults {
|
||||
let mut messages = vec![];
|
||||
messages.push(ConversationEntry::SystemMessage(format!("Fetching artifacts from Bandcamp with {:?}", args).into()));
|
||||
log::info!("Fetching artifacts from Bandcamp with {:?}", args);
|
||||
let mut json_results = vec![];
|
||||
if let Ok(results) = bandcamp::search(args.query.as_str()).await {
|
||||
for result in results {
|
||||
log::debug!("Result: {:?}", result);
|
||||
match result {
|
||||
SearchResultItem::Artist(data) => {
|
||||
let result = bandcamp::fetch_artist(data.artist_id).await.unwrap().into();
|
||||
@@ -211,7 +212,7 @@ impl Session {
|
||||
.build().unwrap()
|
||||
})
|
||||
];
|
||||
self.log("Sending request..");
|
||||
log::info!("Sending request..");
|
||||
let request = CreateChatCompletionRequestArgs::default()
|
||||
.messages(full_conversation)
|
||||
.model("gpt-5.4-mini")
|
||||
@@ -233,18 +234,18 @@ impl Session {
|
||||
|
||||
if let Some(usage) = response.usage {
|
||||
self.tokens_consumed += usage.total_tokens as usize;
|
||||
self.log(format!("{} tokens cast into the void", usage.total_tokens));
|
||||
log::info!("{} tokens cast into the void", usage.total_tokens);
|
||||
}
|
||||
|
||||
if let Some(message) = response.choices.first() {
|
||||
|
||||
match message.finish_reason {
|
||||
Some(FinishReason::ContentFilter) => {
|
||||
self.insert_conversation(ConversationEntry::SystemMessage("Content filter triggered.".into()));
|
||||
log::error!("Content filter triggered.");
|
||||
break;
|
||||
},
|
||||
Some(FinishReason::Length) => {
|
||||
self.insert_conversation(ConversationEntry::SystemMessage("Maximum token count exceeded!".into()));
|
||||
log::error!("Maximum token count exceeded!");
|
||||
break;
|
||||
},
|
||||
_ => ()
|
||||
@@ -292,11 +293,11 @@ impl Session {
|
||||
self.reply_options = options;
|
||||
break;
|
||||
} else {
|
||||
self.log("Received invalid JSON! Trying again.");
|
||||
log::info!("Received invalid JSON! Trying again.");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.log("No messages were received! Trying again.");
|
||||
log::info!("No messages were received! Trying again.");
|
||||
}
|
||||
}
|
||||
self.activity_notify.send_if_modified(|x| { if *x { *x = false; true } else { false }});
|
||||
@@ -308,10 +309,6 @@ impl Session {
|
||||
Scene::new(self.reply_options.clone(), self.conversation.clone(), self.scenery.clone(), self.tokens_consumed, self.direction.clone())
|
||||
}
|
||||
|
||||
fn log<T: Into<String>>(&mut self, msg: T) {
|
||||
self.insert_conversation(ConversationEntry::SystemMessage(msg.into()));
|
||||
}
|
||||
|
||||
fn insert_conversation(&mut self, entry: ConversationEntry) {
|
||||
self.conversation.push(entry.clone());
|
||||
|
||||
@@ -345,10 +342,6 @@ impl SessionControl {
|
||||
self.event_sink.send(action).await.unwrap();
|
||||
}
|
||||
|
||||
pub async fn log(&self, message: String) {
|
||||
self.insert(PredictionAction::ConversationAppend(ConversationEntry::SystemMessage(message))).await;
|
||||
}
|
||||
|
||||
pub async fn regenerate_options(&self) {
|
||||
self.insert(PredictionAction::GeneratePredictions).await;
|
||||
}
|
||||
@@ -404,7 +397,7 @@ pub async fn start_prediction(saved_session: SaveData, mut messages: tokio::sync
|
||||
PredictionAction::SetEpisodeNumber(num) => {
|
||||
session.direction.episode_number = num;
|
||||
match MixxxDB::load(num) {
|
||||
Err(err) => session.log(format!("Failed to load mixxx playlist: {:?}.", err)),
|
||||
Err(err) => log::info!("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 }) {
|
||||
@@ -414,7 +407,7 @@ pub async fn start_prediction(saved_session: SaveData, mut messages: tokio::sync
|
||||
}
|
||||
}
|
||||
session.scenery.current_playlist = playlist;
|
||||
session.log("Mixxx playlist reloaded.");
|
||||
log::info!("Mixxx playlist reloaded.");
|
||||
}
|
||||
}
|
||||
false
|
||||
@@ -424,7 +417,7 @@ pub async fn start_prediction(saved_session: SaveData, mut messages: tokio::sync
|
||||
},
|
||||
PredictionAction::SetNarrative(narrative) => {
|
||||
session.direction.narrative = narrative;
|
||||
session.log("Updated stage direction narrative");
|
||||
log::info!("Updated stage direction narrative");
|
||||
true
|
||||
},
|
||||
PredictionAction::SetShowEndTime(end_time) => {
|
||||
|
||||
Reference in New Issue
Block a user