Skip to content

feat(plotting): add data plotting capabilities with Plotly.js#25

Merged
jdhoffa merged 4 commits intomainfrom
add_plotting
Apr 18, 2025
Merged

feat(plotting): add data plotting capabilities with Plotly.js#25
jdhoffa merged 4 commits intomainfrom
add_plotting

Conversation

@jdhoffa
Copy link
Collaborator

@jdhoffa jdhoffa commented Apr 18, 2025

This PR adds data visualization capabilities to the project, allowing users to generate interactive Plotly.js visualizations from query results.

Features Added

  • New /generate endpoint in the LLM engine to create visualizations from data and queries
  • New /visualize endpoint in the query router to handle visualization requests
  • Visualization generation using Plotly.js with neobrutalist styling
  • Interactive charts with zoom, pan, and hover tooltips
  • Client-ready HTML/JS output that can be directly rendered in a browser
  • Error handling and fallback for visualization parsing

Technical Details

  • Added new request/response models for visualization data
  • Implemented specialized LLM prompting for chart generation
  • Added HTML/JS code extraction from LLM responses
  • Applied consistent styling guidelines for generated visualizations

Testing

Manual testing has been performed to verify the visualization generation workflow.

@jdhoffa jdhoffa requested a review from Copilot April 18, 2025 14:01
@jdhoffa jdhoffa marked this pull request as ready for review April 18, 2025 14:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request implements visualization generation functionality for plotting data from natural language queries while also addressing an HTML index slicing issue and updating styling guidelines.

  • Added new request and response models for visualization in both query_router and llm_engine.
  • Created new endpoints to process visualization generation using LLM APIs.
  • Updated styling guidelines embedded in the prompt for visualization generation.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
query_router/src/main.rs Added visualization request/response models and a new endpoint to generate visualizations.
llm_engine/src/main.rs Implemented visualization generation logic including prompt construction and LLM API integration.

struct VisualizationRequest {
natural_query: String,
results: Value,
#[serde(default = "default_model")]
Copy link

Copilot AI Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default model value returned by default_model ('gpt-3.5-turbo') is inconsistent with the default ('gpt-4') used in the llm_engine endpoint. Consider harmonizing these defaults to prevent unexpected behavior.

Copilot uses AI. Check for mistakes.
info!("Generating visualization for query: {}", request.query);

// Get the model name from the request or use a default
let model = request.model.unwrap_or_else(|| "gpt-4".to_string());
Copy link

Copilot AI Apr 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default model ('gpt-4') differs from the default used in the query_router module. Aligning the default model values across endpoints would improve consistency.

Copilot uses AI. Check for mistakes.
@jdhoffa jdhoffa changed the title add plotting feat(plotting): add data plotting capabilities with Plotly.js Apr 18, 2025
@jdhoffa jdhoffa merged commit bdb83ca into main Apr 18, 2025
6 checks passed
@jdhoffa jdhoffa deleted the add_plotting branch April 18, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants