-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore(wren-ai-service): improve text2sql #1844
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
Conversation
WalkthroughA new utility function, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant WebService
participant Configuration
participant SQLAnswerPipeline
participant PromptBuilder
participant Utility
User->>WebService: Request SQL answer
WebService->>Configuration: Get current time (show_current_time)
Configuration-->>WebService: Current time string
WebService->>SQLAnswerPipeline: run(query, sql, sql_data, language, current_time, ...)
SQLAnswerPipeline->>PromptBuilder: run(...)
PromptBuilder-->>SQLAnswerPipeline: { "prompt": raw_prompt }
SQLAnswerPipeline->>Utility: clean_up_new_lines(raw_prompt)
Utility-->>SQLAnswerPipeline: cleaned_prompt
SQLAnswerPipeline-->>WebService: { "prompt": cleaned_prompt }
WebService-->>User: Response with cleaned prompt
Estimated code review effort3 (~45 minutes) Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (24)
wren-ai-service/src/pipelines/common.py(2 hunks)wren-ai-service/src/pipelines/generation/chart_adjustment.py(3 hunks)wren-ai-service/src/pipelines/generation/chart_generation.py(2 hunks)wren-ai-service/src/pipelines/generation/data_assistance.py(2 hunks)wren-ai-service/src/pipelines/generation/followup_sql_generation.py(3 hunks)wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py(3 hunks)wren-ai-service/src/pipelines/generation/intent_classification.py(3 hunks)wren-ai-service/src/pipelines/generation/misleading_assistance.py(2 hunks)wren-ai-service/src/pipelines/generation/question_recommendation.py(2 hunks)wren-ai-service/src/pipelines/generation/relationship_recommendation.py(2 hunks)wren-ai-service/src/pipelines/generation/semantics_description.py(2 hunks)wren-ai-service/src/pipelines/generation/sql_answer.py(5 hunks)wren-ai-service/src/pipelines/generation/sql_correction.py(2 hunks)wren-ai-service/src/pipelines/generation/sql_generation.py(3 hunks)wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py(3 hunks)wren-ai-service/src/pipelines/generation/sql_question.py(2 hunks)wren-ai-service/src/pipelines/generation/sql_regeneration.py(3 hunks)wren-ai-service/src/pipelines/generation/sql_tables_extraction.py(2 hunks)wren-ai-service/src/pipelines/generation/user_guide_assistance.py(2 hunks)wren-ai-service/src/pipelines/generation/utils/sql.py(4 hunks)wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py(2 hunks)wren-ai-service/src/pipelines/retrieval/sql_functions.py(0 hunks)wren-ai-service/src/web/v1/services/__init__.py(2 hunks)wren-ai-service/src/web/v1/services/sql_answer.py(1 hunks)
🧠 Learnings (16)
📓 Common learnings
Learnt from: wwwy3y3
PR: Canner/WrenAI#1585
File: wren-ui/src/pages/api/v1/generate_sql.ts:98-106
Timestamp: 2025-04-24T16:10:43.308Z
Learning: In the generate_sql API, allow users to specify language codes not predefined in the WrenAILanguage enum, passing them through directly rather than strictly validating against the enum.
wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/misleading_assistance.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/data_assistance.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_question.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_generation.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/followup_sql_generation.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_tables_extraction.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_regeneration.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/user_guide_assistance.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/semantics_description.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_correction.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/utils/sql.py (2)
Learnt from: wwwy3y3
PR: #1585
File: wren-ui/src/pages/api/v1/generate_sql.ts:98-106
Timestamp: 2025-04-24T16:10:43.308Z
Learning: In the generate_sql API, allow users to specify language codes not predefined in the WrenAILanguage enum, passing them through directly rather than strictly validating against the enum.
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/question_recommendation.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
💤 Files with no reviewable changes (1)
- wren-ai-service/src/pipelines/retrieval/sql_functions.py
🧰 Additional context used
🧠 Learnings (16)
📓 Common learnings
Learnt from: wwwy3y3
PR: Canner/WrenAI#1585
File: wren-ui/src/pages/api/v1/generate_sql.ts:98-106
Timestamp: 2025-04-24T16:10:43.308Z
Learning: In the generate_sql API, allow users to specify language codes not predefined in the WrenAILanguage enum, passing them through directly rather than strictly validating against the enum.
wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/misleading_assistance.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/data_assistance.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_question.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_generation.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/followup_sql_generation.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_tables_extraction.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_regeneration.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/user_guide_assistance.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/semantics_description.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/sql_correction.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/utils/sql.py (2)
Learnt from: wwwy3y3
PR: #1585
File: wren-ui/src/pages/api/v1/generate_sql.ts:98-106
Timestamp: 2025-04-24T16:10:43.308Z
Learning: In the generate_sql API, allow users to specify language codes not predefined in the WrenAILanguage enum, passing them through directly rather than strictly validating against the enum.
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
wren-ai-service/src/pipelines/generation/question_recommendation.py (1)
Learnt from: cyyeh
PR: #1763
File: wren-ai-service/src/pipelines/generation/semantics_description.py:31-33
Timestamp: 2025-06-20T02:37:21.292Z
Learning: In the wren-ai-service codebase, when adding new fields like "alias" to the output of functions that use Pydantic models for validation, the user prefers not to update the corresponding Pydantic model definitions to include these new fields.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: pytest
- GitHub Check: pytest
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (38)
wren-ai-service/src/pipelines/common.py (2)
1-1: LGTM! Well-defined regex pattern for newline normalization.The regex pattern correctly identifies sequences of 3+ consecutive newlines for cleanup.
Also applies to: 108-109
111-112: LGTM! Clean utility function implementation.The function correctly normalizes excessive newlines by limiting consecutive newlines to exactly three, which standardizes prompt formatting.
wren-ai-service/src/web/v1/services/__init__.py (1)
1-1: LGTM! Appropriate imports for timezone functionality.The
datetimeandpytzimports are standard and necessary for the new timezone-aware time formatting.Also applies to: 5-5
wren-ai-service/src/web/v1/services/sql_answer.py (1)
102-102: LGTM! Correct integration of current time context.The addition of the
current_timeparameter properly integrates timezone-aware current time into the SQL answer generation pipeline. Note this depends on fixing the method placement issue in the Configuration class.wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py (2)
17-21: LGTM! Correct import addition for newline cleanup functionality.The import of
clean_up_new_linesis properly integrated with existing imports from the common module.
322-323: LGTM! Consistent implementation of prompt cleanup pattern.The modification correctly applies the
clean_up_new_linesfunction to normalize excessive newlines in the prompt output, following the standardized pattern across the codebase.wren-ai-service/src/pipelines/generation/sql_question.py (2)
14-14: LGTM! Necessary import for prompt cleanup functionality.The import of
clean_up_new_linesis correctly added to support the prompt normalization feature.
55-59: LGTM! Consistent prompt cleanup implementation.The function correctly applies the standardized cleanup pattern, storing the prompt builder result first and then returning the cleaned prompt string to normalize newline formatting.
wren-ai-service/src/pipelines/generation/relationship_recommendation.py (1)
16-16: LGTM: Consistent prompt cleanup implementationThe import and usage of
clean_up_new_linesfollows the standardized pattern being applied across pipeline modules. The implementation correctly normalizes newlines while maintaining the existing function interface.Also applies to: 55-56
wren-ai-service/src/pipelines/generation/data_assistance.py (1)
13-13: LGTM: Proper prompt normalization implementationThe changes correctly implement the standardized prompt cleanup pattern. The function maintains its original signature and behavior while adding newline normalization.
Also applies to: 65-70
wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (1)
13-13: LGTM: Standard prompt cleanup pattern applied correctlyThe implementation correctly follows the established pattern for prompt normalization. All parameters are properly passed to
prompt_builder.run()and the result is appropriately cleaned before returning.Also applies to: 75-85
wren-ai-service/src/pipelines/generation/misleading_assistance.py (1)
13-13: LGTM: Consistent prompt cleanup implementationThe changes properly implement the standardized prompt normalization pattern. The existing query processing logic is preserved while adding newline cleanup functionality.
Also applies to: 65-70
wren-ai-service/src/pipelines/generation/semantics_description.py (1)
14-14: LGTM: Proper prompt normalization appliedThe implementation correctly follows the standardized pattern for prompt cleanup. The function maintains its original behavior while adding newline normalization to ensure consistent prompt formatting.
Also applies to: 64-69
wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (2)
13-13: LGTM: Clean import addition for prompt normalization.The import of
clean_up_new_linesaligns with the systematic refactoring to standardize prompt formatting across pipeline modules.
65-74: LGTM: Consistent prompt cleaning implementation.The refactoring correctly introduces an intermediate variable and applies
clean_up_new_linesto normalize excessive newlines. This maintains the same external behavior while ensuring consistent prompt formatting across the system.wren-ai-service/src/pipelines/generation/intent_classification.py (2)
16-16: LGTM: Proper import addition for prompt cleaning.The
clean_up_new_linesimport is correctly added alongside the existingbuild_table_ddlimport, following the systematic refactoring pattern.
279-290: LGTM: Consistent prompt normalization implementation.The prompt function correctly implements the standardized pattern with an intermediate variable and applies
clean_up_new_linesfor consistent formatting. The external function behavior remains unchanged.wren-ai-service/src/pipelines/generation/chart_generation.py (2)
13-13: LGTM: Consistent import addition for prompt cleaning utility.The import follows the established pattern across pipeline modules for standardizing prompt formatting.
77-85: LGTM: Proper implementation of prompt normalization.The refactoring correctly implements the standardized pattern with intermediate variable and
clean_up_new_linesapplication, maintaining external function behavior while ensuring consistent prompt formatting.wren-ai-service/src/pipelines/generation/sql_tables_extraction.py (2)
14-14: LGTM: Standard import for prompt cleaning utility.The import addition is consistent with the systematic refactoring across pipeline generation modules.
64-65: LGTM: Consistent prompt cleaning implementation.Even with the simpler function signature, the implementation correctly follows the established pattern of using an intermediate variable and applying
clean_up_new_linesfor consistent prompt formatting.wren-ai-service/src/pipelines/generation/followup_sql_generation.py (2)
13-13: LGTM: Proper import addition maintaining import organization.The
clean_up_new_linesimport is correctly added alongside the existingretrieve_metadataimport from the same module, maintaining good import organization.
101-116: LGTM: Consistent prompt cleaning with complex parameters.Despite the more complex parameter set, the implementation correctly follows the established pattern with intermediate variable and
clean_up_new_linesapplication. This maintains consistency across all pipeline generation modules.wren-ai-service/src/pipelines/generation/question_recommendation.py (1)
14-14: LGTM! Consistent import and prompt formatting standardization.The import of
clean_up_new_linesand the modification to thepromptfunction align perfectly with the systematic refactoring to standardize prompt string formatting across pipeline modules. The change maintains the function signature while adding beneficial newline normalization.Also applies to: 36-43
wren-ai-service/src/pipelines/generation/chart_adjustment.py (1)
13-13: LGTM! Consistent application of prompt formatting pattern.The changes follow the established pattern for standardizing prompt string formatting. The import and modification to the
promptfunction are implemented correctly and maintain API compatibility.Also applies to: 101-110
wren-ai-service/src/pipelines/generation/sql_generation.py (1)
13-13: LGTM! Clean import consolidation and consistent prompt processing.The modification consolidates the import from
src.pipelines.commonand applies the standard prompt formatting pattern correctly. The implementation maintains all existing functionality while adding the beneficial newline normalization.Also applies to: 97-112
wren-ai-service/src/pipelines/generation/user_guide_assistance.py (1)
13-13: LGTM! Consistent prompt formatting implementation.The changes maintain the established pattern for standardizing prompt string formatting. The import and function modification are implemented correctly with no breaking changes to the API.
Also applies to: 55-60
wren-ai-service/src/pipelines/generation/sql_regeneration.py (1)
13-13: LGTM! Consistent completion of prompt formatting standardization.The changes complete the systematic refactoring pattern seen across all pipeline modules. The import and
promptfunction modification are implemented correctly, maintaining API compatibility while adding standardized newline normalization.This consistent application across all reviewed files demonstrates a well-coordinated effort to improve prompt formatting throughout the codebase.
Also applies to: 110-125
wren-ai-service/src/pipelines/generation/sql_correction.py (2)
14-14: Good addition of clean_up_new_lines import.The import follows the established pattern for improving prompt formatting consistency across the codebase.
69-73: Excellent implementation of prompt normalization.The changes correctly implement the standardized pattern for prompt processing:
- Store raw prompt builder output in local variable
- Apply clean_up_new_lines to normalize excessive newlines
- Return cleaned prompt in expected dictionary format
This aligns with the broader effort to standardize prompt formatting across all generation pipeline modules.
wren-ai-service/src/pipelines/generation/utils/sql.py (4)
198-198: Good improvement to reasoning plan format.Changing from always showing the last step as SQL generation to showing only bullet points makes the reasoning plan more focused and readable.
213-213: Excellent preference for CTEs over subqueries.This change promotes better SQL readability and maintainability. CTEs are generally easier to understand and debug compared to nested subqueries.
235-236: Well-structured alias usage guidelines.The restriction to use aliases only in the final SELECT clause, with values derived from database schema comments, provides better consistency and makes the intent clearer. This is a good refinement from the previous more permissive approach.
265-265: Improved function selection guidance.Changing from "must use" to "must only choose appropriate functions" promotes more selective and contextually relevant function usage, which should lead to better SQL quality.
wren-ai-service/src/pipelines/generation/sql_answer.py (4)
13-13: Good import additions for enhanced functionality.The imports for
clean_up_new_linesandConfigurationsupport the new prompt normalization and temporal context features.Also applies to: 15-15
45-49: Excellent improvement to prompt template structure.The changes provide better organization:
- Separating columns and rows makes the data structure clearer than embedding the full dictionary
- Adding current_time provides valuable temporal context for generating more accurate answers
These changes should improve the quality of SQL-to-answer generation.
59-76: Well-implemented prompt processing with temporal context.The function signature update and implementation correctly:
- Add current_time parameter to support temporal context
- Follow the established pattern for prompt normalization using clean_up_new_lines
- Maintain backward compatibility through proper parameter ordering
156-156: Smart default value implementation for current_time.Using
Configuration().show_current_time()as the default value ensures the pipeline always has current temporal context when not explicitly provided, while still allowing override when needed.Also applies to: 168-168
Summary by CodeRabbit
New Features
Improvements
Bug Fixes