Helicone Community Page

Updated 6 months ago

Troubleshooting Timeout Errors with Filters

Hello, any ideas on why when I add
Plain Text
            "properties": {"type": {"equals": "chat"}}
to filters, i get a timeout error, but if i exclude it, it works?
J
y
32 comments
Can you share the full curl?
yup,

Plain Text
url = "https://api.helicone.ai/v1/request/query"


payload = {"filter": {"properties": {"type": {"equals": "chat"}}}}

payload = {
    "filter": {
            "feedback": {
                "created_at": {
                    "gt": '2024-04-01T00:00:00', #start_time_dt.isoformat()
                }}, 
            "properties": {"type": {"equals": "chat"}}
    },
    "limit": 10,    
    "offset": 0,
    "sort": {"created_at": "desc"},
    "isCached": False
}

        
headers = {
    "authorization": os.getenv("HELICONE_API_KEY"), 
    "Content-Type": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)
sorry! Looking now
I am surprised you did not get a 400 error
the filter will need to be anded
are you using Node btw?
oh nvm I see it's python
the quick fix is here:

Plain Text
{
            "left": {
              "feedback": {
                "created_at": {
                    "gt": '2024-04-01T00:00:00', #start_time_dt.isoformat()
                }
               }, 
             },
            "right": {
              "properties": {"type": {"equals": "chat"}}
            },
            "operator": "and"
    }
You need to nest them
within "right" and "left"
Change filter to Option 2
Attachment
Screenshot_2024-06-01_at_4.26.36_PM.png
These docs might be easier to read
ah i see, thank you. is there a way to have more than 2 filters?
Yeah you can just keep nesting them like a full AST
if you give me an example I can show you
We should make a GPT to help here lol
lmao that would be awesome
"properties": {"billing_key": {"equals": "test"}}
something like this

Plain Text
 {
        left: {
          left: {
            properties: { billing_key: { equals: "test" } },
          },
          right: {
            properties: { type: { equals: "chat" } },
          },
          operator: "or",
        },
        right: {
          feedback: {
            created_at: {
              gt: "2024-04-01T00:00:00",
            },
          },
        },
        operator: "and",
      }
We dont have an index on created at
so it will be faster if you do something like this
Plain Text
 {
        left: {
          left: {
            properties: { billing_key: { equals: "test" } },
          },
          right: {
            properties: { type: { equals: "chat" } },
          },
          operator: "or",
        },
        right: {
          request: {
            created_at: {
              gt: "2024-04-01T00:00:00",
            },
          },
        },
        operator: "and",
      },
This will build a query something like

"Request created at > 4/01" AND (type == "chat" OR billing_key == "test")
I am going to create the GPT for you lol
this is very helpful man. Thank you so much!
ugh creating a GPT require gpt plus... BOOO
Add a reply
Sign up and join the conversation on Discord