X-Git-Url: http://git.giacomolli.uk/onechat/blobdiff_plain/6f7eda727e519ae43d7d35195cbe412a2725abd7..ba9faee0cd6c35020997794ef7bf134e8db12e96:/responses.go?ds=inline diff --git a/responses.go b/responses.go index cdc1558..096439f 100644 --- a/responses.go +++ b/responses.go @@ -48,8 +48,10 @@ type apiKey string // Client sends model calls to a Responses endpoint for one agent. The ChatGPT // backend and the OpenAI API take the same request body and differ only in the // URL and the credentials. Every call sends the fixed cache key of the agent, -// so the turns and the compactions of the agent share one prompt cache. Every -// call is recorded in the usage file. +// so the turns and the compactions of the agent share one prompt cache. The +// ChatGPT backend caches only with the key in the session_id header, so a call +// to it sends the key there and in the body. Every call is recorded in the +// usage file. // // The request never holds max_output_tokens or metadata, because the ChatGPT // backend refuses them. It sets store to false, so the client sends the whole @@ -217,6 +219,11 @@ func (c *Client) Create(ctx context.Context, request Request) (Response, error) return Response{}, fmt.Errorf("authorize model call: %w", err) } + _, chatgpt := c.auth.(*chatgptAuth) + if chatgpt { + httpRequest.Header.Set("session_id", c.cacheKey) + } + record := usageRecord{ Date: time.Now().Format(time.RFC3339Nano), Model: request.Model,