-
Notifications
You must be signed in to change notification settings - Fork 164
Add Local Ollama NLP Backend for Natural-Language Computed Fields #491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kkhatke
wants to merge
545
commits into
Kanaries:main
Choose a base branch
from
kkhatke:feature/nlp-custom-field
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…es#171) * fix: modal height * feat: color palette * fix: didnot fetch data in sometimes * feat: range scale
* feat: delete chart * feat: add slider and menu
* fix: typo * feat: fold new version * fix: remove console * fix: fold with computed fields
* fix: remove props from pure renderer * fix: show map when geoData is not set
* refactor: store * feat: add schema json * fix: setLayout * fix: methods for external use * feat: add slider and menu * fix: fix filter * fix: merge error * fix: export get computation * feat: add code export & import * fix: add fold Fields * fix: error panels * fix: props * fix: config desc * fix: change layout not to fire computation
* fix: make map center effective * fix: manual upload topojson
* fix: enter visSegment after import csv * fix: react-vega render deps * fix: properities * fix: default segment * chore: tabs behaivor * fix: pivottable reactive * fix: chart name idx * fix: props * fix: ux * fix: fold menu z-index * fix: add channel limit * chore: change getTemporalRange * fix: hook deps * fix: menu in dark mode
* feat: pivot sorting * fix: sorting when data is incomplete * fix: pivottable reactive
* fix: inner field cannot move to filter & meta * fix: field stat with computed field * feat: workflow with computed field * fix: computed filter not in graph
* feat: add new dataset * feat: force semantic for geo field
* fix: map mark with color, size, opacity scales * fix: size & opacity
* feat: add component and hooks * fix: filter * chore: add dataSource for filter mod * chore: code readabilty update * fix: count field id
* fix: absolute ele cause page hight wrong * feat: optimize misc config
* feat(tablewalker): add options to disable filter sorting and semantic type * doc: add showcase in storybook * chore: remove code review action
* fix: height style * fix: field height * chore: gallery page style
* chore: report event when edited * chore: add disposer for reactions
* fix: paint info * fix: container export * fix: paintmap is null
Co-authored-by: GitHub Action <action@github.com>
* feat: select all when have keyword * fix: copilot * Update packages/graphic-walker/src/fields/filterField/tabs.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Elwynn Chen <270001151@qq.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* feat: workable poc for observable plot * fix: facet and repeat * fix: axis title * fix: single var view * fix:automark + tick color * fix: ts err * fix: temporal fix for export * feat(for dev): renderer switch * fix: stack direction * fix: temporal field crash * feat: stack for most marks * fix: mark directions * fix: support boxplot * feat(observable-plot): add color legend support (Kanaries#464) * fix(renderer): differentiate point and circle in observable plot (Kanaries#465) * feat(core): allow setting default renderer (Kanaries#466) * feat(renderer): default to vega-lite (Kanaries#467) * test: add observable plot transform cases (Kanaries#468)
* chore: add props of hide profiling in the main component * chore: update testing * fix: playground
Co-authored-by: GitHub Action <action@github.com>
* fix: vlSpec import and export * fix: map chart name
* feat: upgrade to react-19 * fix: Restore styled-components global * fix: command
Co-authored-by: GitHub Action <action@github.com>
|
@kkhatke is attempting to deploy a commit to the kanaries Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Hi! This PR is ready for review. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds a complete local LLM-powered backend service for generating SQL expressions for custom computed fields in Graphic Walker using Ollama. The service runs entirely on-premises with no external API dependencies, ensuring privacy, cost-efficiency, and offline capability.
📹 Includes demonstration video: NLP-Based Compute Field
Purpose
Enable users to generate SQL computed field expressions from natural language descriptions using their local Ollama installation, providing a seamless integration between Graphic Walker's UI and local language models.
Key Features Implemented
1. Natural Language to SQL Conversion
2. Advanced SQL Processing
sql_processor.py):3. Robust Service Architecture
Ollama client (
ollama_client.py):Service layer (
ollama_service.py):Model management (
model_manager.py):4. Health Monitoring & Observability
Health monitoring (
health_monitor.py):Metrics collection (
metrics_collector.py):Monitoring dashboard (
monitoring_dashboard.py):5. Enterprise-Grade Logging
logging_config.py):6. FastAPI Integration
app.py):Technical Implementation Details
API Endpoints
Primary Endpoints
POST /api/ollama-text2sql- Basic SQL generation from natural languagePOST /api/ollama-text2sql/detailed- SQL generation with detailed processing informationPOST /api/sql/process- Process raw SQL responses for testing/debuggingHealth & Monitoring Endpoints
GET /api/health- Basic health checkGET /api/health/detailed- Comprehensive health statusGET /api/health/metrics- Health metrics and statisticsGET /api/health/history- Recent health check historyGET /api/service-info- Service configuration and statusGET /api/models- Available models from OllamaMonitoring & Analytics Endpoints
GET /api/monitoring/dashboard- Full monitoring dashboard dataGET /api/monitoring/real-time- Real-time metricsGET /api/monitoring/health-status- Health status for monitoring systemsGET /api/monitoring/performance-trends- Performance trends (configurable period)GET /api/monitoring/report/{report_type}- Comprehensive reportsGET /api/metrics/summary- Metrics summaryGET /api/metrics/export?format=json|prometheus- Metrics exportGET /api/metrics/time-series/{metric_name}- Time series dataGET /api/metrics/requests- Request historyConfiguration
Environment variables for flexibility:
OLLAMA_BASE_URL- Ollama server URL (default: http://localhost:11434)OLLAMA_MODEL- Primary model (default: codellama:7b-instruct)OLLAMA_FALLBACK_MODEL- Fallback model (default: llama3.2:latest)OLLAMA_TIMEOUT- Request timeout in seconds (default: 90)LOG_LEVEL- Logging level (default: INFO)LOG_FORMAT- Log format: json or text (default: json)LOG_FILE- Optional log file pathMETRICS_RETENTION_HOURS- Metrics retention period (default: 24)MAX_POINTS_PER_METRIC- Maximum metrics data points (default: 10000)SQL Processing Pipeline
Error Handling Strategy
Error Categories:
TIMEOUT_ERROR- Request exceeded timeoutCONNECTION_ERROR- Cannot connect to OllamaMODEL_ERROR- Model unavailable or generation failedVALIDATION_ERROR- Invalid inputCONFIGURATION_ERROR- Configuration issuesUNKNOWN_ERROR- Other errorsFallback Mechanism:
Files Added
Core Service Files
app.py- FastAPI application with all endpointsconfig.py- Configuration managementollama_client.py- Ollama integration clientollama_service.py- Service layerProcessing & Validation
sql_processor.py- Advanced SQL processing and cleaningmodel_manager.py- Model selection and validationMonitoring & Observability
health_monitor.py- Health checking and monitoringmetrics_collector.py- Metrics collection and analyticsmonitoring_dashboard.py- Dashboard data aggregationlogging_config.py- Structured logging configurationDocumentation & Configuration
requirements.txt- Python dependenciesREADME.md- Quick start guideOLLAMA_NLP_BACKEND_GUIDE.md- Comprehensive guide.env.example- Environment configuration templateDependencies
Testing
The implementation includes comprehensive testing capabilities:
Deployment Considerations
Prerequisites
Quick Start
cd packages/nlp-backend pip install -r requirements.txt uvicorn app:app --reload --port 3002Production Deployment
Performance Characteristics
Security Considerations
SQL Injection Prevention:
Local Processing:
Input Validation:
Backward Compatibility
Documentation Provided
Demonstration
Video Walkthrough
A comprehensive demonstration of the Ollama NLP Backend for Custom Computed Fields:
📹 Download: NLP-Based Compute Field (Right-click → Save link as... to download)
The video covers:
Example Conversions
Example 1: Conditional Logic
Example 2: Mathematical Operation
Example 3: Complex Condition
Example 4: Multi-field Logic
Related Issues
Testing Checklist
Notes for Reviewers