continueous worker
This commit is contained in:
parent
414043480d
commit
86d0991138
|
@ -5,6 +5,8 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
|
||||||
"ewintr.nl/emdb/client"
|
"ewintr.nl/emdb/client"
|
||||||
"github.com/tmc/langchaingo/chains"
|
"github.com/tmc/langchaingo/chains"
|
||||||
|
@ -19,24 +21,25 @@ const (
|
||||||
{{.review}}
|
{{.review}}
|
||||||
----
|
----
|
||||||
|
|
||||||
If you found any movie titles other than {{.title}}, list them below in a JSON array. If there are other titles, like TV shows, books or games, separate them according to the following schema:
|
If you found any movie titles other than {{.title}}, list them below in a JSON array. If there are other titles, like TV shows, books or games, ignore them. The format is as follows:
|
||||||
|
|
||||||
{
|
["movie title 1", "movie title 2"]
|
||||||
"movies": ["movie title 1", "movie title 2"],
|
|
||||||
"tvShows": ["tv series 1"],
|
|
||||||
"games": ["game 1", "game 2"],
|
|
||||||
"books": ["book"]
|
|
||||||
}
|
|
||||||
|
|
||||||
Just answer with the JSON and nothing else. When in doubt about whether a title is a movie or another category, don't put it in movies, but in the other category. `
|
Just answer with the JSON and nothing else. If you don't see any other movie titles, just answer with an empty array.`
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
//movieID := "c313ffa9-1cec-4d37-be6e-a4e18c247a0f" // night train
|
|
||||||
//movieID := "07fb2a59-24ec-442e-aa9e-eb7e4fb002db" // battle royale
|
|
||||||
//movieID := "2fce2f8f-a048-4e39-8ffe-82df09a29d32" // shadows in paradise
|
|
||||||
|
|
||||||
emdb := client.NewEMDB(os.Getenv("EMDB_BASE_URL"), os.Getenv("EMDB_API_KEY"))
|
emdb := client.NewEMDB(os.Getenv("EMDB_BASE_URL"), os.Getenv("EMDB_API_KEY"))
|
||||||
|
|
||||||
|
go Work(emdb)
|
||||||
|
|
||||||
|
c := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
<-c
|
||||||
|
}
|
||||||
|
|
||||||
|
func Work(emdb *client.EMDB) {
|
||||||
|
for {
|
||||||
j, err := emdb.GetNextAIJob()
|
j, err := emdb.GetNextAIJob()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
@ -67,10 +70,15 @@ func main() {
|
||||||
)
|
)
|
||||||
llmChain := chains.NewLLMChain(llm, prompt)
|
llmChain := chains.NewLLMChain(llm, prompt)
|
||||||
|
|
||||||
fmt.Printf("Processing review for movie: %s\n", movie.Title)
|
movieTitle := movie.Title
|
||||||
|
if movie.EnglishTitle != "" && movie.EnglishTitle != movie.Title {
|
||||||
|
movieTitle = fmt.Sprintf("%s (English title: %s)", movieTitle, movie.EnglishTitle)
|
||||||
|
}
|
||||||
|
fmt.Printf("Processing review for movie: %s\n", movieTitle)
|
||||||
fmt.Printf("Review: %s\n", review.Review)
|
fmt.Printf("Review: %s\n", review.Review)
|
||||||
|
|
||||||
outputValues, err := chains.Call(ctx, llmChain, map[string]any{
|
outputValues, err := chains.Call(ctx, llmChain, map[string]any{
|
||||||
"title": movie.Title,
|
"title": movieTitle,
|
||||||
"review": review.Review,
|
"review": review.Review,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -101,4 +109,5 @@ func main() {
|
||||||
fmt.Printf("could not update review: %s\n", err)
|
fmt.Printf("could not update review: %s\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue