extend context size and write to an output file
This commit is contained in:
@ -53,12 +53,21 @@ func main() {
|
||||
}
|
||||
|
||||
fmt.Println("AI: ", resp.Choices[0].Message.Content)
|
||||
file, err := os.OpenFile("output.txt", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
fmt.Println("Error opening file:", err)
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
if _, err := file.WriteString(resp.Choices[0].Message.Content + "\n"); err != nil {
|
||||
fmt.Println("Error writing to file:", err)
|
||||
}
|
||||
messages = append(messages, resp.Choices[0].Message)
|
||||
|
||||
currLength := estimateTokenCount(messages)
|
||||
|
||||
if currLength > 2000 {
|
||||
fmt.Println("Token count exceeded 2000, summarizing context")
|
||||
if currLength > 95000 {
|
||||
fmt.Println("Token count exceeded 95000, summarizing context")
|
||||
summarized, err := summarizeChatSoFar(messages)
|
||||
if err != nil {
|
||||
fmt.Printf("error summarizing chat so far | %v\n", err)
|
||||
|
Reference in New Issue
Block a user