Debugging action API calls - params not being sent

Hi,

I’ve created a GPT to search a dataset we host on Algolia. I’ve created an openapi spec and an instruction set. At first I was having issues getting it to pass on certain headers, such as X-Algolia-Application-Id so I decided to route the API requests via a proxy. This allows me to override or add certain headers, and is also useful in that I can log the requests to see what’s going on.

Using GET requests appears to work, but I noticed the GPT was often including a params array in the body when attempting to filter results. This is only supported in POST requests to Algolia, and so I’d like to get these working.

I can see params being set in the debug info, but these don’t appear in my proxy logs. The content of the request appears empty.

[debug] Calling HTTP endpoint information

{
  "domain": "[PROXY_DOMAIN]",
  "method": "post",
  "path": "/",
  "operation": "search",
  "operation_hash": "[OPERATION_HASH]",
  "is_consequential": true,
  "params": {
    "query": "",
    "hitsPerPage": 5,
    "attributesToRetrieve": [
      "name",
      "location",
      "languages"
    ],
    "attributesToHighlight": [],
    "facetFilters": []
  }
}

Here’s the log in my proxy:

2023-11-29 13:29:03 - Received Request:

Method: POST

Headers: {"Host":"[PROXY_DOMAIN]","content-type":"application\/json","user-agent":"Mozilla\/5.0 AppleWebKit\/537.36 (KHTML, like Gecko); compatible; ChatGPT-User\/1.0; +https:\/\/openai.com\/bot","openai-ephemeral-user-id":"[REMOVED]","openai-conversation-id":"[REMOVED]","openai-gpt-id":"[REMOVED]","x-algolia-api-key":"[REMOVED]","x-datadog-trace-id":"[REMOVED]","x-datadog-parent-id":"[REMOVED]","x-datadog-sampling-priority":"0","traceparent":"[REMOVED]","tracestate":"dd=s:0","Accept":"*\/*","Accept-Encoding":"gzip, deflate","Content-Length":2,"X-Algolia-Application-Id":"[REMOVED]"}

Content: {}

So my questions are…

  1. Why are the params not being sent in the body content of the POST request?
  2. Is there any way to get further debug information on the API request being sent?

Thanks,

Paul

With the new UI we cannot see the request/response for API endpoints. What I did is to use AWs API Gateway and “front” my endpoints. It has decent logging capability.

1 Like

If it’s saying that it’s sending the parameters in the editor, and you’re receiving the requests, then it’s pretty likely that it’s sending those parameters in some form (once they show in the UI like that it gets handed over to a request function so there’s no chance it’s hallucinating them out of the actual call).

I’d triple-check your OpenAPI spec, and I’d triple-check your requests. In particular, see if it’s accidentally sending the parameters in the search params or even the URL path instead of the body. There are also directives in the spec that will validate correctly, but ChatGPT doesn’t actually use—to rule those out just make sure you’re using very simple types and no components/refs (not that you can’t use those, but it’s worth ruling out for debugging).

If you can post a screenshot of the ChatGPT UI and then the full URL and body of the associated request you’re seeing, that will go a long way. Also your spec, if possible, obviously with whatever redactions you need.

Thanks for your replies.

@huwsername I expanded my logging to include the full URL for post requests, and your theory was correct, it was sending the params in the URL despite it being a POST request.

Screenshot of GPT Debug Output

Example request URL in my proxy logs…

PROXY-URL/?query=&hitsPerPage=5&attributesToRetrieve=name&attributesToRetrieve=content&attributesToRetrieve=_geoloc&attributesToRetrieve=availability_status&attributesToRetrieve=costs&attributesToRetrieve=location

I will try updating the instructions to get it to send the params in the body of the request.

It turns out my schema was wrong. I had switched the path to use the POST method without updating the parameters from query parameters to requestBody properties.

I had this…

paths:
 /:
    post:
      summary: Search for x
      operationId: search
      parameters:
        - name: query
          in: query
          description: The search query
          required: true
          schema:
            type: string
        - name: hitsPerPage
          in: query
          description: Number of results to return per page
          required: false
          schema:
            type: integer
            default: 5

I have now updated the “/” POST schema to use requestBody properties instead:

paths:
  /:
    post:
      summary: Search for x
      operationId: search
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  description: The search query
                hitsPerPage:
                  type: integer
                  description: Number of results to return per page
                  default: 5
1 Like