extend context size and write to an output file
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@ -2,4 +2,6 @@ cache/
|
|||||||
context.db
|
context.db
|
||||||
context.db-shm
|
context.db-shm
|
||||||
context.db-wal
|
context.db-wal
|
||||||
data.ms
|
data.ms
|
||||||
|
/output.txt
|
||||||
|
/ctxGPT.exe
|
||||||
|
@ -53,12 +53,21 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("AI: ", resp.Choices[0].Message.Content)
|
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)
|
messages = append(messages, resp.Choices[0].Message)
|
||||||
|
|
||||||
currLength := estimateTokenCount(messages)
|
currLength := estimateTokenCount(messages)
|
||||||
|
|
||||||
if currLength > 2000 {
|
if currLength > 95000 {
|
||||||
fmt.Println("Token count exceeded 2000, summarizing context")
|
fmt.Println("Token count exceeded 95000, summarizing context")
|
||||||
summarized, err := summarizeChatSoFar(messages)
|
summarized, err := summarizeChatSoFar(messages)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error summarizing chat so far | %v\n", err)
|
fmt.Printf("error summarizing chat so far | %v\n", err)
|
||||||
|
Reference in New Issue
Block a user