Hi! Is it possible to limit the timespan of the data fetched by the UI? We've observed that the container crashes with a large amount of tokens when opening the UI (about 160 million tokens). To mitigate we do 'Clear Data' from the UI but it would be ideal to specify how much data the container and UI will attempt to fetch on load
Yes, it is possible to limit the timespan of the data fetched by the UI in Phoenix. You can specify a time range using the start_time and end_time parameters when querying spans. This can help mitigate issues with large amounts of data.LBKSimport phoenix as px from datetime import datetime, timedeltaLBKS# Initiate Phoenix client px_client = px.Client()LBKS# Define the time range start = datetime.now() - timedelta(days=7) # Last 7 days end = datetime.now() - timedelta(days=1) # Exclude the last 24 hoursLBKS# Query spans within the specified time range phoenix_df = px_client.query_spans(start_time=start, end_time=end)LBKSWould you like more detail on this?Sources:
- Extract Data from Spans
๐กย Hint: Mention RunLLM in the thread for followups.
To limit the query when the UI is opened in the web browser for a Phoenix Docker container, you would need to modify the backend code that handles the data fetching for the UI. Specifically, you can implement time range filtering in the API endpoints that the UI calls to fetch data.1. Modify the Backend Code: Update the API endpoint to include start_time and end_time parameters in the query logic. This will ensure that only data within the specified time range is fetched.2. Update the Docker Container: Rebuild and redeploy the Docker container with the updated backend code.Here is a general approach to modifying the backend code: 1. Locate the API Endpoint: Find the API endpoint in the Phoenix backend code that handles the data fetching for the UI.2. Add Time Range Filtering: Modify the query logic to include start_time and end_time parameters.Example modification in Python: LBKSfrom datetime import datetime, timedeltaLBKS# Define the time range start = datetime.now() - timedelta(days=7) # Last 7 days end = datetime.now() - timedelta(days=1) # Exclude the last 24 hoursLBKS# Modify the query to include time range filtering query = SpanQuery().where( "span_kind == 'RETRIEVER'" ).select( input="input.value" ).time_range( start_time=start, end_time=end )LBKS# Fetch the data with the specified time range px_client = px.Client() phoenix_df = px_client.query_spans(query)LBKSWould you like more detailed steps on how to implement this in your Docker setup?Sources:
- Extract Data from Spans
๐กย Hint: Mention RunLLM in the thread for followups.
Yes, forking the Arize Phoenix repository and building a custom Docker image is a viable approach to implement custom logic, such as limiting the timespan of data fetched by the UI.Here are the general steps to achieve this: 1. Fork the Repository: Fork the Arize Phoenix repository on GitHub.2. Modify the Backend Code: Update the backend code to include time range filtering in the API endpoints that fetch data for the UI. You can add start_time and end_time parameters to the query logic.3. Build the Custom Docker Image: After making the necessary changes, build a new Docker image from your forked repository.4. Deploy the Custom Docker Image: Run the custom Docker image to deploy your modified version of Phoenix.Example steps to build and run the custom Docker image: LBKS# Clone your forked repository git clone [https://github.com/your-username/phoenix.git](https://github.com/your-username/phoenix.git) cd phoenixLBKS# Make your code changesLBKS# Build the Docker image docker build -t your-custom-phoenix .LBKS# Run the custom Docker image docker run -p 6006:6006 -p 4317:4317 -i -t your-custom-phoenixLBKSWould you like more detailed instructions on any of these steps?Sources:
- https://arize-ai.slack.com/archives/C04R3GXC8HK/p1720763791.977129
- https://github.com/Arize-ai/phoenix/issues/3094
๐กย Hint: Mention RunLLM in the thread for followups.
Hey Mikyo, 100+ million tokens can occur in less than 2 hours in one of our environments
I can add a last hour option to unblock you for now until we get retention policies in place?
That'd be awesome. Any chance you could do trace count instead of time frame? Even a single call to one of our endpoints can generate 11 million tokens. I apologize, I imagine we're a bit of an oddball in this regard.
I think its a fairly recent image version but I'm getting the image ID to double check
Sg - it might take me a bit more work to get the page size configurable. Let me get a quick fix out for the time range and will try to unblock you on load
awesome!
Just released an update. Hopefully it unblocks you for the time being https://github.com/Arize-ai/phoenix/releases/tag/arize-phoenix-v4.34.0
