Skip to content

Commit

Permalink
fix: summarize return info
Browse files Browse the repository at this point in the history
  • Loading branch information
ivynya committed Dec 31, 2023
1 parent 4a29b03 commit a49e831
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions client/summarize.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package main

import (
"encoding/json"
"strconv"

"github.com/gorilla/websocket"
"github.com/ivynya/illm/internal"
"github.com/ivynya/illm/ollama"
"github.com/kkdai/youtube/v2"
)

Expand All @@ -22,13 +24,22 @@ func summarize(c *websocket.Conn, req *internal.Request) (bool, error) {
return false, err
}

resp, err := encodeRequest(req.Tag, "response", "Video: "+video.Title+"\nTranscript length: "+strconv.Itoa(len(transcript.String()))+"\n\n")
info := &ollama.GenerateResponse{
Model: req.Generate.Model,
Response: "Video: `" + video.Title + "`\nTranscript length: `" + strconv.Itoa(len(transcript.String())) + "`\n\n",
Done: false,
}
infoJson, err := json.Marshal(info)
if err != nil {
return false, err
}
infoResp, err := encodeRequest(req.Tag, "response", string(infoJson))
if err != nil {
return false, err
}
c.WriteMessage(websocket.TextMessage, resp)
c.WriteMessage(websocket.TextMessage, infoResp)

req.Generate.Prompt = "Summarize the following video: " + video.Title + "\n\n" + transcript.String() + "\n\nSummary:"
req.Generate.Prompt = "Summarize the following video. Only include information from the video in your response. Video: " + video.Title + "\n\n" + transcript.String() + "\n\nSummary:"
req.Generate.Context = []int{}

complete, err := generate(c, req)
Expand Down

0 comments on commit a49e831

Please sign in to comment.