openai-go icon indicating copy to clipboard operation
openai-go copied to clipboard

Cannot nest response.CompoundFilter

Open mariuswilms opened this issue 6 months ago • 0 comments

I'm trying to create a filter that uses nested compound filters, similar to what is described in the docs:

{
  "type": "or",
  "filters": [
    {
      "type": "and",
      "filters": [
        {
          "type": "or",
          "filters": [
            {
              "type": "eq",
              "property": "project_code",
              "value": "X123"
            },
            {
              "type": "eq",
              "property": "project_code",
              "value": "X999"
            }
          ]
        },
        {
          "type": "eq",
          "property": "confidentiality",
          "value": "top_secret"
        }
      ]
    },
    {
      "type": "eq",
      "property": "language",
      "value": "en"
    }
  ]
}

However, the CompoundFilter is defined to allow only a slice of ComparisonFilter, although the comment rightfully assumes both Compound and ComparisonFilter should be acceptable:

type CompoundFilter struct {
	// Array of filters to combine. Items can be `ComparisonFilter` or
	// `CompoundFilter`.
	Filters []ComparisonFilter
	// Type of operation: `and` or `or`.
	//
	// Any of "and", "or".
	Type CompoundFilterType
}

This prevents me from nesting CompoundFilter and create complex conditions. Thanks for reviewing this issue and your work to provide this API client to the Go community.

mariuswilms avatar Jun 06 '25 14:06 mariuswilms