@@ -136,12 +136,12 @@ func (c *Client) seed(request openai.ChatCompletionRequest) int {
136
136
return hash .Seed (newRequest )
137
137
}
138
138
139
- func (c * Client ) fromCache (ctx context. Context , messageRequest types.CompletionRequest , request openai.ChatCompletionRequest ) (result []openai.ChatCompletionStreamResponse , _ bool , _ error ) {
139
+ func (c * Client ) fromCache (messageRequest types.CompletionRequest , request openai.ChatCompletionRequest ) (result []openai.ChatCompletionStreamResponse , _ bool , _ error ) {
140
140
if messageRequest .Cache != nil && ! * messageRequest .Cache {
141
141
return nil , false , nil
142
142
}
143
143
144
- cache , found , err := c .cache .Get (ctx , c .cacheKey (request ))
144
+ cache , found , err := c .cache .Get (c .cacheKey (request ))
145
145
if err != nil {
146
146
return nil , false , err
147
147
} else if ! found {
@@ -167,10 +167,10 @@ func toToolCall(call types.CompletionToolCall) openai.ToolCall {
167
167
}
168
168
}
169
169
170
- func toMessages (ctx context. Context , cache * cache.Client , request types.CompletionRequest ) (result []openai.ChatCompletionMessage , err error ) {
170
+ func toMessages (cache * cache.Client , request types.CompletionRequest ) (result []openai.ChatCompletionMessage , err error ) {
171
171
for _ , message := range request .Messages {
172
172
if request .Vision {
173
- message , err = vision .ToVisionMessage (ctx , cache , message )
173
+ message , err = vision .ToVisionMessage (cache , message )
174
174
if err != nil {
175
175
return nil , err
176
176
}
@@ -189,7 +189,7 @@ func toMessages(ctx context.Context, cache *cache.Client, request types.Completi
189
189
chatMessage .ToolCalls = append (chatMessage .ToolCalls , toToolCall (* content .ToolCall ))
190
190
}
191
191
if content .Image != nil {
192
- url , err := vision .ImageToURL (ctx , cache , request .Vision , * content .Image )
192
+ url , err := vision .ImageToURL (cache , request .Vision , * content .Image )
193
193
if err != nil {
194
194
return nil , err
195
195
}
@@ -247,7 +247,7 @@ type Status struct {
247
247
}
248
248
249
249
func (c * Client ) Call (ctx context.Context , messageRequest types.CompletionRequest , status chan <- Status ) (* types.CompletionMessage , error ) {
250
- msgs , err := toMessages (ctx , c .cache , messageRequest )
250
+ msgs , err := toMessages (c .cache , messageRequest )
251
251
if err != nil {
252
252
return nil , err
253
253
}
@@ -298,7 +298,7 @@ func (c *Client) Call(ctx context.Context, messageRequest types.CompletionReques
298
298
299
299
var cacheResponse bool
300
300
request .Seed = ptr (c .seed (request ))
301
- response , ok , err := c .fromCache (ctx , messageRequest , request )
301
+ response , ok , err := c .fromCache (messageRequest , request )
302
302
if err != nil {
303
303
return nil , err
304
304
} else if ! ok {
@@ -390,7 +390,7 @@ func override(left, right string) string {
390
390
return left
391
391
}
392
392
393
- func (c * Client ) store (ctx context. Context , key string , responses []openai.ChatCompletionStreamResponse ) error {
393
+ func (c * Client ) store (key string , responses []openai.ChatCompletionStreamResponse ) error {
394
394
buf := & bytes.Buffer {}
395
395
gz := gzip .NewWriter (buf )
396
396
err := json .NewEncoder (gz ).Encode (responses )
@@ -400,7 +400,7 @@ func (c *Client) store(ctx context.Context, key string, responses []openai.ChatC
400
400
if err := gz .Close (); err != nil {
401
401
return err
402
402
}
403
- return c .cache .Store (ctx , key , buf .Bytes ())
403
+ return c .cache .Store (key , buf .Bytes ())
404
404
}
405
405
406
406
func (c * Client ) call (ctx context.Context , request openai.ChatCompletionRequest , transactionID string , partial chan <- Status ) (responses []openai.ChatCompletionStreamResponse , _ error ) {
@@ -426,7 +426,7 @@ func (c *Client) call(ctx context.Context, request openai.ChatCompletionRequest,
426
426
for {
427
427
response , err := stream .Recv ()
428
428
if err == io .EOF {
429
- return responses , c .store (ctx , cacheKey , responses )
429
+ return responses , c .store (cacheKey , responses )
430
430
} else if err != nil {
431
431
return nil , err
432
432
}
0 commit comments