@@ -17,6 +17,7 @@ limitations under the License.
1717package common
1818
1919import (
20+ "fmt"
2021 "math/rand"
2122 "regexp"
2223 "sync"
@@ -53,13 +54,18 @@ func ValidateContextWindow(promptTokens int, maxCompletionTokens *int64, maxMode
5354type Random struct {
5455 randomGenerator * rand.Rand
5556 randMutex sync.Mutex
57+ uuidNamespace uuid.UUID
58+ uuidName string
59+ uuidCount int
5660}
5761
58- func NewRandom (seed int64 ) * Random {
62+ func NewRandom (seed int64 , port int ) * Random {
5963 src := rand .NewSource (seed )
6064 randomGenerator := rand .New (src )
61- uuid .SetRand (rand .New (rand .NewSource (seed )))
62- return & Random {randomGenerator : randomGenerator }
65+ return & Random {randomGenerator : randomGenerator ,
66+ uuidNamespace : uuid .NameSpaceURL ,
67+ uuidName : fmt .Sprintf ("%d-%d" , seed , port ),
68+ }
6369}
6470
6571// Returns an integer between min and max (included)
@@ -122,7 +128,9 @@ func (r *Random) RandomNormTruncated(mean int, stddev int) int {
122128func (r * Random ) GenerateUUIDString () string {
123129 r .randMutex .Lock ()
124130 defer r .randMutex .Unlock ()
125- return uuid .NewString ()
131+ name := fmt .Sprintf ("%s-%d" , r .uuidName , r .uuidCount )
132+ r .uuidCount ++
133+ return uuid .NewSHA1 (r .uuidNamespace , []byte (name )).String ()
126134}
127135
128136func (r * Random ) RandomNumericString (length int ) string {
0 commit comments