Strange Plugin Bug with Enum Query Param

I have a strange bug that fails consistently.

I am using FastAPI to develop my plugin and making extensive use of Enums to hopefully “guide” ChatGPT as much as possible. (The system works great for the most part)

Here is my plugin working, note how it calls my localhost API and passes in Stage III:


If I change that field from a str to an Enum like this:

Working:

    stage: str = Query(
        None,
        description=desc.FILTER_PRE + desc.THERAPY_DISEASE_STAGE,
    ),

Broken:

    stage: schemas.enums.DiseaseStage = Query(
        None,
        description=desc.FILTER_PRE + desc.THERAPY_DISEASE_STAGE,
    ),

Where Disease Stage is:

class DiseaseStage(str, BaseEnum):
    STAGE_0 = "Stage 0"
    STAGE_I = "Stage I"
    STAGE_II = "Stage II"
    STAGE_III = "Stage III"
    STAGE_IV = "Stage IV"

Note that Enums as lists in parameters work fine regardless:

    responses: List[schemas.enums.Response] = Query(
        None, description=desc.FILTER_PRE + desc.THERAPY_RESPONSE
    ),

When the Enum param is in place, there is no traffic to my API. I validated this by watching the network traffic:


I have tried multiple times, switching back and forth between str and the Enum, uninstalling/re-installing, switching localhost ports to make sure it isn’t caching and I get a very consistent error.

Explanation of what my plugin does here if that helps:
https://twitter.com/imaurer/status/1670937391354241029

Thanks for any help…
Ian

1 Like

One more point…

I proved (to myself at least) that it is an OpenAPI Spec/Plugin issue and not with my code. If I have the system working (with str) and then switch it to an Enum, but DO NOT refresh the plugin then everything still works.

Here is the delta on the OpenAPI spec.

str working version:

          {
            "description": "Filter: Disease Stage (e.g. Stage 0, Stage I, Stage II, Stage III, Stage IV)",
            "required": false,
            "schema": {
              "title": "Stage",
              "type": "string",
              "description": "Filter: Disease Stage (e.g. Stage 0, Stage I, Stage II, Stage III, Stage IV)"
            },
            "name": "stage",
            "in": "query"
          },

Enum, not working version:

          {
            "description": "Filter: Disease Stage (e.g. Stage 0, Stage I, Stage II, Stage III, Stage IV)",
            "required": false,
            "schema": {
              "allOf": [
                {
                  "$ref": "#/components/schemas/DiseaseStage"
                }
              ],
              "description": "Filter: Disease Stage (e.g. Stage 0, Stage I, Stage II, Stage III, Stage IV)"
            },
            "name": "stage",
            "in": "query"
          },
      "DiseaseStage": {
        "title": "DiseaseStage",
        "enum": [
          "Stage 0",
          "Stage I",
          "Stage II",
          "Stage III",
          "Stage IV"
        ],
        "type": "string",
        "description": "An enumeration."
      },
1 Like

I am hitting an identical problem with an enum field. It’s not just you. But I don’t have a solution either.

1 Like

Enums are still broken for me. The best workaround so far I’ve found is to define the param as a string and list the possible inputs in the description. This is less than ideal from a code perspective since we lose FastAPI’s automatic input validation and it’s not even 100% guaranteed that ChatGPT will give the right inputs.

1 Like

Yeah, I firmly believe it will be fixed at some point silently. Hard to complain based on how productive the OpenAI team is. Just is what it is given their team size (350 people?) and their market size.

1 Like