extend context size and write to an output file

This commit is contained in:
2025-02-02 02:26:59 -07:00
parent b926215e94
commit d0eb4b7468
2 changed files with 14 additions and 3 deletions

2
.gitignore vendored
View File

@ -3,3 +3,5 @@ context.db
context.db-shm
context.db-wal
data.ms
/output.txt
/ctxGPT.exe

View File

@ -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)