update to latest gpt model
This commit is contained in:
@ -17,6 +17,7 @@ func main() {
|
||||
fmt.Println("---------------------")
|
||||
|
||||
systemPrompt := ""
|
||||
//systemPrompt := "You are Mixtral, a locally hosted AI assistant."
|
||||
|
||||
messages := []openai.ChatCompletionMessage{
|
||||
{
|
||||
@ -52,13 +53,12 @@ func main() {
|
||||
}
|
||||
|
||||
fmt.Println("AI: ", resp.Choices[0].Message.Content)
|
||||
//fmt.Println("Finish Reason: ", resp.Choices[0].FinishReason)
|
||||
messages = append(messages, resp.Choices[0].Message)
|
||||
|
||||
currLength := estimateTokenCount(messages)
|
||||
|
||||
if currLength > 3000 {
|
||||
fmt.Println("Token count exceeded 3000, summarizing context")
|
||||
if currLength > 2000 {
|
||||
fmt.Println("Token count exceeded 2000, summarizing context")
|
||||
summarized, err := summarizeChatSoFar(messages)
|
||||
if err != nil {
|
||||
fmt.Printf("error summarizing chat so far | %v\n", err)
|
||||
|
31
cmd/rateTest/rate.go
Normal file
31
cmd/rateTest/rate.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Rate struct {
|
||||
RPM int
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func main() {
|
||||
r := Rate{RPM: 10}
|
||||
for i := 0; i < 10; i++ {
|
||||
go func(j int) {
|
||||
r.RateLimit()
|
||||
fmt.Println("Rate limiting")
|
||||
}(i)
|
||||
}
|
||||
time.Sleep(time.Minute)
|
||||
}
|
||||
|
||||
func (r *Rate) RateLimit() {
|
||||
// Lock for the fraction of a minute based on RPM
|
||||
r.mu.Lock()
|
||||
// Unlock after the fraction of a minute
|
||||
time.Sleep(time.Minute / time.Duration(r.RPM))
|
||||
r.mu.Unlock()
|
||||
}
|
Reference in New Issue
Block a user