Repository navigation
Staging #246
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
Merged
Staging #246
Changes from 51 commits
Commits
Show all changes
70 commits
Select commit
Hold shift + click to select a range
5fd292a
break the code to core and api
gkorland 1848e0d
refactor load steps
gkorland 383d303
Bump litellm from 1.76.2 to 1.76.3
dependabot[bot] b76bca5
Bump pytest from 8.4.1 to 8.4.2
dependabot[bot] 285ace8
Bump pytest-playwright from 0.7.0 to 0.7.1
dependabot[bot] 432afb0
Bump @typescript-eslint/parser from 8.40.0 to 8.42.0 in /app
dependabot[bot] 45a5e13
Bump eslint from 9.34.0 to 9.35.0 in /app
dependabot[bot] d1cca0e
Merge branch 'staging' into lib
galshubeli f9aa51b
lint
galshubeli 2e0c5fd
Merge pull request #226 from FalkorDB/lib
gkorland edf15d1
Merge branch 'staging' into dependabot/npm_and_yarn/app/staging/types…
gkorland 97f9825
Merge pull request #236 from FalkorDB/dependabot/npm_and_yarn/app/sta…
gkorland ef4939b
Merge branch 'staging' into dependabot/npm_and_yarn/app/staging/eslin…
gkorland e7d1c96
Merge pull request #237 from FalkorDB/dependabot/npm_and_yarn/app/sta…
gkorland df57d54
Merge branch 'staging' into dependabot/pip/staging/pytest-playwright-…
gkorland 3bb1279
Merge pull request #234 from FalkorDB/dependabot/pip/staging/pytest-p…
gkorland 85142f5
Merge branch 'staging' into dependabot/pip/staging/pytest-8.4.2
gkorland 960d15d
Merge pull request #233 from FalkorDB/dependabot/pip/staging/pytest-8…
gkorland 0b09b47
Merge branch 'staging' into dependabot/pip/staging/litellm-1.76.3
gkorland f883112
Merge pull request #232 from FalkorDB/dependabot/pip/staging/litellm-…
gkorland 9dea5e1
Bump @typescript-eslint/eslint-plugin from 8.40.0 to 8.42.0 in /app
dependabot[bot] fb07508
Bump playwright from 1.54.0 to 1.55.0
dependabot[bot] d88b4d0
Merge branch 'staging' into dependabot/pip/staging/playwright-1.55.0
gkorland 46faf48
Merge pull request #231 from FalkorDB/dependabot/pip/staging/playwrig…
gkorland 6b0bb3b
Merge branch 'staging' into dependabot/npm_and_yarn/app/staging/types…
gkorland 684d8c2
Merge pull request #235 from FalkorDB/dependabot/npm_and_yarn/app/sta…
gkorland 945f187
add mcp registry
gkorland 9a5bf2f
Merge pull request #247 from FalkorDB/mcp-reg
gkorland 8edc9a6
add url
gkorland b421f11
Merge branch 'staging' into mcp-reg
gkorland 3cd62e6
Merge pull request #248 from FalkorDB/mcp-reg
gkorland 54d84c1
update server
gkorland fdaabcb
fix graphs_list
gkorland 18f74ee
Fix: Convert null to boolean in dropdown isDemo parameter
guglielmo 5d9e35e
Bump pytest-asyncio from 1.1.0 to 1.2.0
dependabot[bot] 699d0da
Bump litellm from 1.76.3 to 1.77.1
dependabot[bot] 14d4d99
Merge pull request #251 from FalkorDB/dependabot/pip/staging/litellm-…
gkorland 5e2e7cb
Merge branch 'staging' into dependabot/pip/staging/pytest-asyncio-1.2.0
gkorland 2bdde8f
Merge pull request #250 from FalkorDB/dependabot/pip/staging/pytest-a…
gkorland 7f73509
Merge branch 'staging' into fix/dropdown-isDemo-null-error
gkorland 7c387e4
Merge pull request #249 from guglielmo/fix/dropdown-isDemo-null-error
galshubeli 21e1f75
Bump authlib from 1.6.3 to 1.6.4
dependabot[bot] 7ef3ba6
Add Contributor Covenant Code of Conduct
gkorland 81d52b1
Merge pull request #255 from FalkorDB/dependabot/pip/staging/authlib-…
gkorland b57fd0c
Update wordlist.txt
gkorland 7841d05
Delete wordlist.dic
gkorland 67a5430
update deps
gkorland 7f4782e
Merge pull request #264 from FalkorDB/update-deps
gkorland 30e16bb
Bump uvicorn from 0.35.0 to 0.36.0
dependabot[bot] 5b95777
fix docker build
gkorland 1d6f768
Merge branch 'staging' into update-deps
gkorland 79135a1
Merge pull request #265 from FalkorDB/update-deps
gkorland be80120
Merge branch 'staging' into dependabot/pip/staging/uvicorn-0.36.0
gkorland 2a5779b
Merge pull request #261 from FalkorDB/dependabot/pip/staging/uvicorn-…
gkorland 4ae9ff0
Merge branch 'staging' into gkorland-patch-2
gkorland 4b1dc37
Merge pull request #263 from FalkorDB/gkorland-patch-2
gkorland 99b5354
update all files to python12
gkorland 0d2f346
Merge pull request #270 from FalkorDB/python12
gkorland d8f6011
Bump fastapi from 0.117.1 to 0.118.0
dependabot[bot] 63608c5
Merge pull request #267 from FalkorDB/dependabot/pip/staging/fastapi-…
gkorland 0a2b47e
move to fastmcp
gkorland caf4ad7
move the route and mcp init to start
gkorland f7b8cf3
set tags
gkorland 8a47af9
fix lint
gkorland 44c942e
all should be tools
gkorland db3b9db
Apply suggestion from @Copilot
gkorland 8c6bd17
make sure tags are set
gkorland 4c1d717
fix lint
gkorland 71bfe07
Merge pull request #280 from FalkorDB/fastmcp
gkorland 0b41046
Update api/core/text2sql.py
gkorland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
|
|
||
| """ | ||
| Core module for QueryWeaver. | ||
|
|
||
| This module provides the core functionality for QueryWeaver including | ||
| error handling, database schema loading, and text-to-SQL processing. | ||
| """ | ||
|
|
||
| from .errors import InternalError, GraphNotFoundError, InvalidArgumentError | ||
| from .schema_loader import load_database, list_databases | ||
| from .text2sql import MESSAGE_DELIMITER | ||
|
|
||
| __all__ = [ | ||
| "InternalError", | ||
| "GraphNotFoundError", | ||
| "InvalidArgumentError", | ||
| "load_database", | ||
| "list_databases", | ||
| "MESSAGE_DELIMITER", | ||
| ] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| """Custom exceptions for the text2sql API.""" | ||
|
|
||
| # Interal Error Exception | ||
| class InternalError(Exception): | ||
| """Custom exception for internal errors.""" | ||
|
|
||
| # Graph not found Exception | ||
| class GraphNotFoundError(Exception): | ||
| """Custom exception for graph not found errors.""" | ||
|
|
||
| # Wrong argument Exception | ||
| class InvalidArgumentError(Exception): | ||
| """Custom exception for invalid argument errors.""" |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| """Database connection routes for the text2sql API.""" | ||
|
|
||
| import logging | ||
| import json | ||
| import time | ||
| from typing import AsyncGenerator | ||
|
|
||
| from pydantic import BaseModel | ||
|
|
||
| from api.extensions import db | ||
|
|
||
| from api.core.errors import InvalidArgumentError | ||
| from api.loaders.base_loader import BaseLoader | ||
| from api.loaders.postgres_loader import PostgresLoader | ||
| from api.loaders.mysql_loader import MySQLLoader | ||
|
|
||
| # Use the same delimiter as in the JavaScript frontend for streaming chunks | ||
| MESSAGE_DELIMITER = "|||FALKORDB_MESSAGE_BOUNDARY|||" | ||
|
|
||
|
|
||
| class DatabaseConnectionRequest(BaseModel): | ||
| """Database connection request model. | ||
|
|
||
| Args: | ||
| BaseModel (_type_): _description_ | ||
| """ | ||
|
|
||
| url: str | ||
|
|
||
| def _step_start(steps_counter: int) -> dict[str, str]: | ||
| """Yield the starting step message.""" | ||
| return { | ||
| "type": "reasoning_step", | ||
| "message": f"Step {steps_counter}: Starting database connection", | ||
| } | ||
|
|
||
| def _step_detect_db_type(steps_counter: int, url: str) -> tuple[type[BaseLoader], dict[str, str]]: | ||
| """Yield the database type detection step message.""" | ||
| db_type = None | ||
| loader: type[BaseLoader] = BaseLoader # type: ignore | ||
| if url.startswith("postgres://") or url.startswith("postgresql://"): | ||
| db_type = "postgresql" | ||
| loader = PostgresLoader | ||
| elif url.startswith("mysql://"): | ||
| db_type = "mysql" | ||
| loader = MySQLLoader | ||
| else: | ||
| raise InvalidArgumentError("Invalid database URL format") | ||
|
|
||
| return loader, { | ||
| "type": "reasoning_step", | ||
| "message": f"Step {steps_counter}: Detected database type: {db_type}. " | ||
| "Attempting to load schema...", | ||
| } | ||
|
|
||
|
|
||
| async def _step_attempt_load( | ||
| steps_counter: int, loader: type[BaseLoader], user_id: str, url: str | ||
| ) -> AsyncGenerator[dict[str, str | bool], None]: | ||
| """Yield the attempt to load schema step message.""" | ||
| success, result = [False, ""] | ||
| try: | ||
| load_start = time.perf_counter() | ||
| async for progress in loader.load(user_id, url): | ||
| success, result = progress | ||
| if success: | ||
| steps_counter += 1 | ||
| yield { | ||
| "type": "reasoning_step", | ||
| "message": f"Step {steps_counter}: {result}", | ||
| } | ||
| else: | ||
| break | ||
|
|
||
| load_elapsed = time.perf_counter() - load_start | ||
| logging.info("Database load attempt finished in %.2f seconds", load_elapsed) | ||
|
|
||
| if success: | ||
| yield { | ||
| "type": "final_result", | ||
| "success": True, | ||
| "message": "Database connected and schema loaded successfully", | ||
| } | ||
| else: | ||
| # Don't stream the full internal result; give higher-level error | ||
| logging.error("Database loader failed: %s", str(result)) # nosemgrep | ||
| yield {"type": "error", "message": "Failed to load database schema"} | ||
| except Exception as e: # pylint: disable=broad-exception-caught | ||
| logging.exception("Error while loading database schema: %s", str(e)) | ||
| yield {"type": "error", "message": "Error connecting to database"} | ||
|
|
||
|
|
||
| def _step_result(result) -> str: | ||
| """Yield the final result message.""" | ||
| return json.dumps(result) + MESSAGE_DELIMITER | ||
|
|
||
|
|
||
| async def load_database(url: str, user_id: str): | ||
| """ | ||
| Accepts a JSON payload with a database URL and attempts to connect. | ||
| Supports both PostgreSQL and MySQL databases. | ||
| Streams progress steps as a sequence of JSON messages separated by MESSAGE_DELIMITER. | ||
| """ | ||
|
|
||
| # Validate URL format | ||
| if len(url.strip()) == 0: | ||
| raise InvalidArgumentError("Invalid URL format") | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| async def generate(): | ||
| overall_start = time.perf_counter() | ||
| steps_counter = 0 | ||
| try: | ||
| # Step 1: Start | ||
| steps_counter += 1 | ||
| result = _step_start(steps_counter) | ||
| yield _step_result(result) | ||
|
|
||
| # Step 2: Determine type | ||
| steps_counter += 1 | ||
| loader, result = _step_detect_db_type(steps_counter, url) | ||
| yield _step_result(result) | ||
|
|
||
| # Step 3: Attempt to load schema using the loader | ||
| async for progress in _step_attempt_load( | ||
| steps_counter, loader, user_id, url | ||
| ): | ||
| yield _step_result(progress) | ||
|
|
||
| except InvalidArgumentError as ia: | ||
| yield _step_result({"type": "error", "message": str(ia)}) | ||
| except Exception as e: # pylint: disable=broad-exception-caught | ||
| logging.exception("Unexpected error in connect_database stream: %s", str(e)) | ||
| yield _step_result({"type": "error", "message": "Internal server error"}) | ||
| finally: | ||
| overall_elapsed = time.perf_counter() - overall_start | ||
| logging.info( | ||
| "connect_database processing completed - Total time: %.2f seconds", | ||
| overall_elapsed, | ||
| ) | ||
|
|
||
| return generate() | ||
|
|
||
|
|
||
| async def list_databases(user_id: str, general_prefix: str) -> list[str]: | ||
| """ | ||
| This route is used to list all the graphs (databases names) that are available in the database. | ||
| """ | ||
| user_graphs = await db.list_graphs() | ||
|
|
||
| # Only include graphs that start with user_id + '_', and strip the prefix | ||
| filtered_graphs = [ | ||
| graph[len(f"{user_id}_") :] | ||
| for graph in user_graphs | ||
| if graph.startswith(f"{user_id}_") | ||
| ] | ||
|
|
||
| if general_prefix: | ||
| demo_graphs = [ | ||
| graph for graph in user_graphs if graph.startswith(general_prefix) | ||
| ] | ||
| filtered_graphs = filtered_graphs + demo_graphs | ||
|
|
||
| return filtered_graphs | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid litellm 1.77.3 due to known startup OOM
Line [9] pins to LiteLLM 1.77.3, but that release’s own notes flag a Kubernetes startup OOM regression; we should hold at 1.76.x or skip forward once a patched build (e.g., 1.77.4) is validated.
(docs.litellm.ai)
🤖 Prompt for AI Agents