@@ -25,59 +25,18 @@ import com.embabel.agent.core.all
2525import com.embabel.agent.core.hitl.ConfirmationRequest
2626import com.embabel.agent.domain.io.UserInput
2727import com.embabel.agent.domain.library.HasContent
28- import com.embabel.agent.domain.library.Person
2928import com.embabel.agent.domain.library.RelevantNewsStories
3029import com.embabel.agent.event.ProgressUpdateEvent
3130import com.embabel.agent.prompt.persona.Persona
3231import com.embabel.common.ai.model.LlmOptions
3332import com.embabel.common.ai.model.ModelSelectionCriteria.Companion.byName
34- import jakarta.persistence.*
3533import org.slf4j.LoggerFactory
3634import org.springframework.boot.context.properties.ConfigurationProperties
3735import org.springframework.context.annotation.Profile
38- import org.springframework.data.jpa.repository.JpaRepository
39- import org.springframework.stereotype.Service
40- import org.springframework.transaction.annotation.Transactional
36+ import kotlin.math.min
4137
4238typealias OneThroughTen = Int
4339
44- @Entity
45- data class MovieBuff (
46- @Id
47- @GeneratedValue(strategy = GenerationType .UUID )
48- val id : String? = null ,
49- override val name : String ,
50- @OneToMany(fetch = FetchType .EAGER , cascade = [CascadeType .ALL ])
51- val movieRatings : List <MovieRating >,
52- val countryCode : String ,
53- @ElementCollection(fetch = FetchType .EAGER )
54- @CollectionTable(
55- name = " movie_buff_hobbies" ,
56- joinColumns = [JoinColumn (name = " movie_buff_id" )],
57- )
58- @Column(name = " hobby" )
59- val hobbies : List <String >,
60- val about : String ,
61- val streamingServices : List <String >,
62- ) : Person {
63-
64- /* *
65- * We use this so we don't overwhelm the prompt
66- */
67- fun randomRatings (n : Int ): List <MovieRating > {
68- return movieRatings.shuffled().take(n)
69- }
70- }
71-
72- @Entity
73- data class MovieRating (
74- @Id
75- @GeneratedValue(strategy = GenerationType .UUID )
76- private val id : String? = null ,
77- val rating : OneThroughTen ,
78- val title : String ,
79- )
80-
8140data class DecoratedMovieBuff (
8241 val movieBuff : MovieBuff ,
8342 val tasteProfile : String ,
@@ -112,36 +71,14 @@ data class SuggestionWriteup(
11271) : HasContent
11372
11473
115- interface MovieBuffRepository : JpaRepository <MovieBuff , String > {
116-
117- fun findByName (name : String ): MovieBuff ?
118-
119- }
120-
121- @Service
122- class MovieBuffService (
123- private val movieBuffRepository : MovieBuffRepository ,
124- ) {
125-
126- @Transactional
127- fun save (movieBuff : MovieBuff ): MovieBuff {
128- return movieBuffRepository.save(movieBuff)
129- }
130-
131- @Transactional(readOnly = true )
132- fun findAll (): List <MovieBuff > {
133- return movieBuffRepository.findAll()
134- }
135- }
136-
13774val Roger = Persona (
13875 name = " Roger" ,
13976 persona = " A creative movie critic who channels the famous movie critic Roger Ebert" ,
14077 voice = " You write like Roger Ebert" ,
14178 objective =
14279 """
14380 Suggest movies that will extend as well as entertain the user.
144- Share the love of cinema and inspire the user to watch, learn and think.
81+ Share your love of cinema and inspire the user to watch, learn and think.
14582 """ .trimIndent(),
14683)
14784
@@ -251,6 +188,7 @@ class MovieFinderAgent(
251188 Return a summary of their taste profile as you understand it,
252189 in ${config.tasteProfileWordCount} words or less. Cover what they like and don't like.
253190 """ .trimIndent()
191+ logger.info(" Analyzed taste profile for {}:\n {}" , movieBuff.name, tasteProfile)
254192 return DecoratedMovieBuff (
255193 movieBuff = movieBuff,
256194 tasteProfile = tasteProfile,
@@ -417,7 +355,7 @@ class MovieFinderAgent(
417355 val availableToUser = allStreamingOptions.filter {
418356 (it.service.name.lowercase() in movieBuff.streamingServices.map { it.lowercase() }) // || it.type == "free"
419357 }
420- logger.info (
358+ logger.debug (
421359 " Movie {} available in [{}] on {}: {} can watch it free on {}" ,
422360 movie.Title ,
423361 movieBuff.countryCode,
@@ -494,7 +432,7 @@ class MovieFinderAgent(
494432 ProgressUpdateEvent (
495433 agentProcess = context.processContext.agentProcess,
496434 name = " Streamable movies" ,
497- current = streamableMovies.size,
435+ current = min( streamableMovies.size, config.suggestionCount) ,
498436 total = config.suggestionCount,
499437 )
500438 )
0 commit comments