@ -11,7 +11,7 @@ import { Light } from "../comps/light";
import { useData } from "../util/useData" ;
import VoiceAnalysis from "../comps/voiceanalysis" ;
import { sendOsc , OSC _ADDRESS , updatePrompt } from "../util/osc" ;
import { DebugControl } from "../comps/debug" ;
import { DebugControl , TEST _PROMPT } from "../comps/debug" ;
const EmojiType = {
@ -27,6 +27,7 @@ const ChatStatus={
System : 'system' ,
User : 'user' ,
Processing : 'processing' ,
Clear : 'clear' ,
}
const Voice = {
@ -104,6 +105,24 @@ export function FreeFlow(){
if ( refCurrentCue . current ? . type != 'chat' ) onCueEnd ( ) ;
else {
setChatStatus ( ChatStatus . User ) ; / / R e s e t c h a t s t a t u s t o U s e r a f t e r a u d i o e n d s
/ / i f h i s t o r y c o n t a i n s u s e r i n p u t , s e n d i t
const user _input = history . find ( msg => msg . role === 'user' ) ;
if ( user _input && user _input . content . trim ( ) !== '' ) {
sendOsc ( OSC _ADDRESS . STATUS , 'go' ) ; / / S e n d O S C s t a t u s m e s s a g e
}
/ / s e n d p r o m p t
let raw _prompt = history [ history . length - 1 ] ? . prompt || '' ;
if ( raw _prompt && raw _prompt . trim ( ) !== '' ) {
const prompt = ` ${ data ? . sd _prompt _prefix || '' } ${ raw _prompt } ${ data ? . sd _prompt _suffix || '' } ` ;
updatePrompt ( prompt ) ;
sendOsc ( OSC _ADDRESS . PROMPT , prompt ) ;
}
}
}
@ -112,7 +131,8 @@ export function FreeFlow(){
if ( refCurrentCue . current ? . type != 'chat' && refCurrentCue . current ? . type != 'user_input' ) {
refTimer . current ? . restart ( audio . duration * 1000 || 0 ) ;
} else {
setChatStatus ( ( ) => ChatStatus . System ) ;
if ( refCurrentCue . current ? . type == 'chat' ) setChatStatus ( ( ) => ChatStatus . System ) ;
else setChatStatus ( ( ) => ChatStatus . Clear ) ;
}
} ) ;
}
@ -129,7 +149,7 @@ export function FreeFlow(){
console . log ( 'clear conversation...' ) ;
reset ( ) ;
const prompt = ` ${ data ? . sd _prompt _prefix || '' } ${ 'memory' } ${ data ? . sd _prompt _suffix || '' } ` ;
const prompt = ` ${ data ? . sd _prompt _prefix || '' } ${ TEST _PROMPT } ${ data ? . sd _prompt _suffix || '' } ` ;
updatePrompt ( prompt ) ;
}
@ -149,10 +169,12 @@ export function FreeFlow(){
console . log ( 'Ending conversation with message:' , message ) ;
sendMessage ( message , false , true , voice ) ;
setChatWelcome ( false ) ;
setChatStatus ( ChatStatus . Clear ) ;
break ;
case 'summary' :
console . log ( 'Getting summary...' ) ;
setChatStatus ( ChatStatus . Clear ) ; / / S e t c h a t s t a t u s t o P r o c e s s i n g
getSummary ( history . map ( el => ` ${ el . role } : ${ el . content } ` ) . join ( '\n' ) , data ) . then ( summary => {
console . log ( 'Summary:' , summary ) ;
@ -164,6 +186,7 @@ export function FreeFlow(){
} ) . catch ( error => {
console . error ( 'Error getting summary:' , error ) ;
} ) ;
break ;
case 'user_input' :
console . log ( 'User input cue, setting chat status to User' ) ;
@ -189,7 +212,7 @@ export function FreeFlow(){
/ / c o n t r o l u n i t y
if ( cue . status ) {
if ( cue . status && cue . status != 'go' ) {
sendOsc ( OSC _ADDRESS . STATUS , cue . status ) ; / / S e n d O S C s t a t u s m e s s a g e
if ( cue . status == 'reset' ) {
refLight . current . set ( 1 ) ;
@ -302,7 +325,7 @@ export function FreeFlow(){
}
useEffect ( ( ) => {
console . log ( 'Final transcript changed:' , finalTranscript ) ;
/ / c o n s o l e . l o g ( ' F i n a l t r a n s c r i p t c h a n g e d : ' , f i n a l T r a n s c r i p t ) ;
if ( finalTranscript . trim ( ) . length > 0 ) {
onSpeechEnd ( ) ;
}
@ -425,11 +448,11 @@ export function FreeFlow(){
< NumPad onSend = { onNumpad } / >
< Light ref = { refLight } / >
< VoiceAnalysis / >
< div className = "flex flex-col" >
{ / * < d i v c l a s s N a m e = " f l e x f l e x - c o l " >
< label className = "text-center" > Voice < / label >
< button className = { ` ${ voice == Voice . ONYX && 'bg-gray-300' } ` } onClick = { ( ) => setVoice ( Voice . ONYX ) } > Onyx < / button >
< button className = { ` ${ voice == Voice . SHIMMER && 'bg-gray-300' } ` } onClick = { ( ) => setVoice ( Voice . SHIMMER ) } > Shimmer < / button >
< / div >
< / div > * / }
< button className = "!bg-yellow-300" onClick = { ( ) => {
saveHistory ( history ) ;
} } > Save Log < / button >