diff --git a/.gitignore b/.gitignore index d0e26af..1989a2d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ cache/ context.db context.db-shm context.db-wal -data.ms \ No newline at end of file +data.ms +/output.txt +/ctxGPT.exe diff --git a/cmd/chat/chat.go b/cmd/chat/chat.go index 2e0e859..cff18c4 100644 --- a/cmd/chat/chat.go +++ b/cmd/chat/chat.go @@ -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)