prediction: move actions into prediction mod
This commit is contained in:
+5
-5
@@ -1,4 +1,4 @@
|
|||||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use async_openai::types::chat::ChatCompletionRequestMessage;
|
use async_openai::types::chat::ChatCompletionRequestMessage;
|
||||||
use chrono::{Duration, Utc};
|
use chrono::{Duration, Utc};
|
||||||
@@ -9,14 +9,14 @@ use ratatui::{Frame, layout::{Constraint, Direction, Layout}, widgets::{Block, B
|
|||||||
use static_cell::StaticCell;
|
use static_cell::StaticCell;
|
||||||
use throbber_widgets_tui::{Throbber, ThrobberState};
|
use throbber_widgets_tui::{Throbber, ThrobberState};
|
||||||
use crossterm::{event::{self, EventStream, KeyCode, KeyModifiers}};
|
use crossterm::{event::{self, EventStream, KeyCode, KeyModifiers}};
|
||||||
use tokio::{sync::RwLock, time::Instant};
|
use tokio::time::Instant;
|
||||||
use tui_input::{Input, backend::crossterm::EventHandler};
|
use tui_input::{Input, backend::crossterm::EventHandler};
|
||||||
use futures::{StreamExt, future::FutureExt};
|
use futures::{StreamExt, future::FutureExt};
|
||||||
|
|
||||||
use ratatui::prelude::*;
|
use ratatui::prelude::*;
|
||||||
use tui_skeleton::{AnimationMode, SkeletonText};
|
use tui_skeleton::{AnimationMode, SkeletonText};
|
||||||
|
|
||||||
use crate::{audio::{AudioInputControl, start_audio_input}, prediction::{SessionControl, SessionUpdate}, scene::{PredictionAction, Scene, Scenery, StageDirection, conversation::ConversationEntry}, transcription::TranscriptionControl, tts::{TtsControl, start_tts}};
|
use crate::{audio::{AudioInputControl, start_audio_input}, prediction::{PredictionAction, SessionControl, SessionUpdate}, scene::{Scene, Scenery, StageDirection, conversation::ConversationEntry}, transcription::TranscriptionControl, tts::{TtsControl, start_tts}};
|
||||||
|
|
||||||
mod scene;
|
mod scene;
|
||||||
mod events;
|
mod events;
|
||||||
@@ -380,7 +380,7 @@ impl App {
|
|||||||
// FIXME: Need some new kind of /bandcamp command to force loading of specific urls
|
// FIXME: Need some new kind of /bandcamp command to force loading of specific urls
|
||||||
"/episode" => {
|
"/episode" => {
|
||||||
if let Ok(episode_number) = arg.trim().parse() {
|
if let Ok(episode_number) = arg.trim().parse() {
|
||||||
self.predictions.insert(scene::PredictionAction::SetEpisodeNumber(episode_number)).await;
|
self.predictions.insert(PredictionAction::SetEpisodeNumber(episode_number)).await;
|
||||||
} else {
|
} else {
|
||||||
self.predictions.log("Invalid episode number format. Use /episode [number]".into()).await;
|
self.predictions.log("Invalid episode number format. Use /episode [number]".into()).await;
|
||||||
return;
|
return;
|
||||||
@@ -498,7 +498,7 @@ impl SaveData {
|
|||||||
struct SysMessageLogger(Arc<tokio::sync::mpsc::UnboundedSender<String>>);
|
struct SysMessageLogger(Arc<tokio::sync::mpsc::UnboundedSender<String>>);
|
||||||
|
|
||||||
impl log::Log for SysMessageLogger {
|
impl log::Log for SysMessageLogger {
|
||||||
fn enabled(&self, metadata: &log::Metadata) -> bool {
|
fn enabled(&self, _metadata: &log::Metadata) -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-3
@@ -2,16 +2,27 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use async_openai::{Client, config::OpenAIConfig, types::chat::{ChatCompletionMessageToolCalls, ChatCompletionRequestAssistantMessageArgs, ChatCompletionRequestMessage, ChatCompletionRequestSystemMessageArgs, ChatCompletionRequestToolMessageArgs, ChatCompletionTool, ChatCompletionTools, CreateChatCompletionRequestArgs, FinishReason, FunctionObjectArgs, ResponseFormat, ResponseFormatJsonSchema}};
|
use async_openai::{Client, config::OpenAIConfig, types::chat::{ChatCompletionMessageToolCalls, ChatCompletionRequestAssistantMessageArgs, ChatCompletionRequestMessage, ChatCompletionRequestSystemMessageArgs, ChatCompletionRequestToolMessageArgs, ChatCompletionTool, ChatCompletionTools, CreateChatCompletionRequestArgs, FinishReason, FunctionObjectArgs, ResponseFormat, ResponseFormatJsonSchema}};
|
||||||
use bandcamp::SearchResultItem;
|
use bandcamp::SearchResultItem;
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
use schemars::{JsonSchema, schema_for};
|
use schemars::{JsonSchema, schema_for};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::{Serializer, ser::CompactFormatter};
|
use serde_json::{Serializer, ser::CompactFormatter};
|
||||||
use tokio::sync::{RwLock, mpsc, watch};
|
use tokio::sync::{RwLock, mpsc, watch};
|
||||||
|
|
||||||
use crate::{SaveData, archive::BeatsQueryArgs, artifacts::{Artifact, Artist, BandcampQueryArgs, MixxxDB}, scene::{PredictionAction, Scene, Scenery, StageDirection, conversation::ConversationEntry}};
|
use crate::{SaveData, archive::BeatsQueryArgs, artifacts::{BandcampQueryArgs, MixxxDB}, scene::{Scene, Scenery, StageDirection, conversation::ConversationEntry}};
|
||||||
|
|
||||||
|
|
||||||
const SYSTEM_PROMPT: &str = include_str!("system-prompt.txt");
|
const SYSTEM_PROMPT: &str = include_str!("system-prompt.txt");
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum PredictionAction {
|
||||||
|
ConversationAppend(ConversationEntry),
|
||||||
|
SetEpisodeNumber(u32),
|
||||||
|
GeneratePredictions,
|
||||||
|
SetNarrative(String),
|
||||||
|
SetShowEndTime(DateTime<Utc>)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(JsonSchema, Deserialize, Serialize, Debug, Clone)]
|
#[derive(JsonSchema, Deserialize, Serialize, Debug, Clone)]
|
||||||
pub struct PossibleResponse {
|
pub struct PossibleResponse {
|
||||||
pub text: String,
|
pub text: String,
|
||||||
@@ -112,7 +123,7 @@ impl Session {
|
|||||||
|
|
||||||
for track in &json_results {
|
for track in &json_results {
|
||||||
if let Some(merge_target) = self.scenery.artifacts.iter_mut().find(|a| { *a == track }) {
|
if let Some(merge_target) = self.scenery.artifacts.iter_mut().find(|a| { *a == track }) {
|
||||||
merge_target.merge(track);
|
merge_target.merge(track.clone());
|
||||||
} else {
|
} else {
|
||||||
self.scenery.artifacts.push(track.clone());
|
self.scenery.artifacts.push(track.clone());
|
||||||
}
|
}
|
||||||
@@ -390,7 +401,7 @@ pub async fn start_prediction(saved_session: SaveData, mut messages: tokio::sync
|
|||||||
Ok(playlist) => {
|
Ok(playlist) => {
|
||||||
for track in &playlist {
|
for track in &playlist {
|
||||||
if let Some(merge_target) = session.scenery.artifacts.iter_mut().find(|a| { *a == track }) {
|
if let Some(merge_target) = session.scenery.artifacts.iter_mut().find(|a| { *a == track }) {
|
||||||
merge_target.merge(track);
|
merge_target.merge(track.clone());
|
||||||
} else {
|
} else {
|
||||||
session.scenery.artifacts.push(track.clone());
|
session.scenery.artifacts.push(track.clone());
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-10
@@ -1,7 +1,7 @@
|
|||||||
use chrono::{DateTime, Duration, Utc};
|
use chrono::{DateTime, Duration, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::{artifacts::{Artifact, MixxxDB, MixxxError}, prediction::{GeneratedResponses, PossibleResponse}, scene::conversation::ConversationEntry};
|
use crate::{artifacts::Artifact, prediction::{GeneratedResponses, PossibleResponse}, scene::conversation::ConversationEntry};
|
||||||
|
|
||||||
pub mod conversation;
|
pub mod conversation;
|
||||||
|
|
||||||
@@ -35,15 +35,6 @@ pub struct Scenery {
|
|||||||
pub current_playlist: Vec<Artifact>
|
pub current_playlist: Vec<Artifact>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
|
||||||
pub enum PredictionAction {
|
|
||||||
ConversationAppend(ConversationEntry),
|
|
||||||
SetEpisodeNumber(u32),
|
|
||||||
GeneratePredictions,
|
|
||||||
SetNarrative(String),
|
|
||||||
SetShowEndTime(DateTime<Utc>)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
pub struct Scene {
|
pub struct Scene {
|
||||||
reply_options: GeneratedResponses,
|
reply_options: GeneratedResponses,
|
||||||
|
|||||||
Reference in New Issue
Block a user