From d0eb4b7468c9a319bfd3c45072ce440258c7b03d Mon Sep 17 00:00:00 2001 From: Mason Payne Date: Sun, 2 Feb 2025 02:26:59 -0700 Subject: [PATCH] extend context size and write to an output file --- .gitignore | 4 +++- cmd/chat/chat.go | 13 +++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) 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)