Skip to content

feat(wren-ai-service): enable filtering is fallback triggered#1748

Merged
cyyeh merged 7 commits into
mainfrom
feat/wren-ai-service/enable-filtering-is_fallback_triggered
Jun 17, 2025
Merged

feat(wren-ai-service): enable filtering is fallback triggered#1748
cyyeh merged 7 commits into
mainfrom
feat/wren-ai-service/enable-filtering-is_fallback_triggered

Conversation

@yichieh-lu
Copy link
Copy Markdown
Collaborator

@yichieh-lu yichieh-lu commented Jun 16, 2025

Summary by CodeRabbit

  • New Features

    • Added support for tracking and returning the model name used in various generation and retrieval pipelines, enabling users to identify which model produced a given result.
  • Chores

    • Updated environment configuration to use specific version numbers instead of "latest" for improved stability and consistency.

Steven Lu and others added 2 commits June 16, 2025 16:35
…s multiple pipelines and update .env file with specific version numbers.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 16, 2025

Caution

Review failed

The pull request is closed.

"""

Walkthrough

This update introduces a new generator_name parameter to numerous asynchronous pipeline functions and classes across the codebase, enabling the propagation and return of the generator's model name alongside generation results. The change ensures that each pipeline component and generator call can access and forward the model identifier, affecting both function signatures and internal component dictionaries.

Changes

File(s) Change Summary
.../generation/chart_adjustment.py
.../generation/chart_generation.py
.../generation/question_recommendation.py
.../generation/relationship_recommendation.py
.../generation/semantics_description.py
.../generation/sql_correction.py
.../generation/sql_generation.py
.../generation/sql_generation_reasoning.py
.../generation/sql_regeneration.py
.../generation/sql_tables_extraction.py
.../generation/sql_question.py
.../generation/intent_classification.py
.../generation/followup_sql_generation.py
.../generation/followup_sql_generation_reasoning.py
.../generation/data_assistance.py
.../generation/misleading_assistance.py
.../generation/sql_answer.py
.../generation/user_guide_assistance.py
Added generator_name parameter to async function signatures and class components; updated returns to include model name.
.../retrieval/db_schema_retrieval.py Added generator_name parameter to filtering function and class components; updated generator call and return.
.../utils.py Updated trace_cost decorator to unpack and process (result, generator_name) tuple from wrapped calls.
.../tools/dev/.env Changed version tags from "latest" to specific version numbers for several environment variables.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant PipelineComponent
    participant Generator

    Caller->>PipelineComponent: call_async_function(prompt, generator, ..., generator_name)
    PipelineComponent->>Generator: generator(prompt, ..., generator_name)
    Generator-->>PipelineComponent: result
    PipelineComponent-->>Caller: (result, generator_name)
Loading

Possibly related PRs

Suggested reviewers

  • cyyeh

Poem

A rabbit hopped through fields of code,
Passing model names wherever it strode.
Pipelines now know who did the deed,
Each result tagged with the model’s breed.
No more “latest,” versions are clear—
Hopping forward, the future’s here!
🐇✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03569bb and 555d53e.

📒 Files selected for processing (1)
  • wren-ai-service/src/utils.py (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch feat/wren-ai-service/enable-filtering-is_fallback_triggered
  • Post Copyable Unit Tests in Comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 18

🔭 Outside diff range comments (1)
wren-ai-service/src/utils.py (1)

164-179: Tuple-unpacking makes the decorator brittle – add backward-compatibility guard

trace_cost() now assumes the wrapped coroutine returns a 2-tuple.
If a future/legacy pipeline returns only the result dict, Python will raise ValueError: not enough values to unpack.

-        result, generator_name = await func(*args, **kwargs)
+        outcome = await func(*args, **kwargs)
+        # Accept both the legacy `dict` and the new `(dict, str)` forms
+        if isinstance(outcome, tuple) and len(outcome) == 2:
+            result, generator_name = outcome
+        else:
+            result, generator_name = outcome, None

This keeps existing pipelines working while still supporting the new pair signature.
Also consider using generator_name (currently commented) to ensure the correct model is logged.

♻️ Duplicate comments (6)
wren-ai-service/src/pipelines/generation/misleading_assistance.py (2)

74-80: Same coupling/tuple concern as raised in user_guide_assistance.py.


97-98: Same component-naming nitpick as above.

wren-ai-service/src/pipelines/generation/data_assistance.py (2)

74-80: Same coupling/tuple concern as raised in user_guide_assistance.py.


97-98: Same component-naming nitpick as above.

wren-ai-service/src/pipelines/generation/sql_answer.py (2)

69-74: Same coupling/tuple concern as raised in user_guide_assistance.py.


94-95: Same component-naming nitpick as above.

🧹 Nitpick comments (7)
wren-ai-service/src/pipelines/generation/user_guide_assistance.py (1)

87-88: Component naming inconsistency

"generator_name" is stored alongside callables (generator, prompt_builder).
Consider prefixing with something like model_name or grouping non-callable constants in
_configs for clarity and to avoid accidental misinterpretation by Hamilton.

wren-ai-service/src/pipelines/generation/question_recommendation.py (1)

235-241: Unused component increases payload size

"generator_name": llm_provider.get_model() is injected into _components but never consumed by any node inside this pipeline (only the generate function takes it as an explicit arg).
Keeping redundant entries bloats every driver execution payload.

Either:

  1. Feed generator_name explicitly via inputs= instead of _components, or
  2. Remove it from _components and let generate() call llm_provider.get_model() directly.

Small, but keeps the DAG tidy.

wren-ai-service/src/pipelines/generation/sql_regeneration.py (1)

156-162: Minor: remove dead dependency

Same as other files – if nothing downstream references "generator_name" from _components, prefer passing it directly or dropping it to keep the component map minimal.

wren-ai-service/src/pipelines/generation/chart_adjustment.py (1)

146-163: Component bloat

Consider whether storing "generator_name" in _components is necessary for this DAG; otherwise eliminate it.

wren-ai-service/src/pipelines/generation/sql_generation.py (1)

143-149: Question redundancy

Storing "generator_name" in _components without later use adds overhead. Pass it explicitly or drop.

wren-ai-service/src/pipelines/generation/sql_question.py (1)

100-106: Component not referenced

"generator_name" is injected yet unused by any downstream node. Consider removing to lighten execution context.

wren-ai-service/src/pipelines/generation/sql_tables_extraction.py (1)

321-328: Minor: remove redundant else after early return

-    if prompt:
-        ...
-        return ..., generator_name
-    else:
-        return {}, generator_name
+    if not prompt:
+        return {}
+    return await table_columns_selection_generator(...), generator_name

Simplifies control-flow and satisfies pylint R1705.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5114432 and ea07fde.

📒 Files selected for processing (26)
  • wren-ai-service/eval/metrics/spider/process_sql.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/chart_adjustment.py (2 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 (2 hunks)
  • wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/intent_classification.py (2 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 (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_correction.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_generation.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_question.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_regeneration.py (2 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/retrieval/db_schema_retrieval.py (2 hunks)
  • wren-ai-service/src/pipelines/retrieval/preprocess_sql_data.py (1 hunks)
  • wren-ai-service/src/providers/__init__.py (3 hunks)
  • wren-ai-service/src/utils.py (1 hunks)
  • wren-ai-service/src/web/v1/routers/ask.py (1 hunks)
  • wren-ai-service/tests/pytest/services/test_semantics_description.py (1 hunks)
  • wren-ai-service/tools/dev/.env (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
wren-ai-service/src/web/v1/routers/ask.py (2)
wren-ai-service/tests/pytest/services/test_ask.py (1)
  • ask_service (23-62)
wren-ai-service/src/web/v1/services/ask.py (1)
  • AskFeedbackResultResponse (120-132)
wren-ai-service/src/pipelines/generation/sql_regeneration.py (1)
wren-ai-service/src/core/provider.py (2)
  • get_model (11-12)
  • get_model (30-31)
wren-ai-service/src/pipelines/generation/data_assistance.py (1)
wren-ai-service/src/core/provider.py (2)
  • get_model (11-12)
  • get_model (30-31)
wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py (1)
wren-ai-service/src/core/provider.py (2)
  • get_model (11-12)
  • get_model (30-31)
wren-ai-service/src/pipelines/generation/relationship_recommendation.py (4)
wren-ai-service/src/pipelines/generation/question_recommendation.py (2)
  • generate (46-47)
  • prompt (21-41)
wren-ai-service/src/pipelines/generation/semantics_description.py (2)
  • generate (70-71)
  • prompt (55-65)
wren-ai-service/src/web/v1/routers/relationship_recommendation.py (1)
  • get (117-129)
wren-ai-service/src/core/provider.py (2)
  • get_model (11-12)
  • get_model (30-31)
🪛 dotenv-linter (3.3.0)
wren-ai-service/tools/dev/.env

[warning] 14-14: [UnorderedKey] The WREN_ENGINE_VERSION key should go before the WREN_PRODUCT_VERSION key


[warning] 15-15: [UnorderedKey] The WREN_AI_SERVICE_VERSION key should go before the WREN_ENGINE_VERSION key


[warning] 16-16: [UnorderedKey] The IBIS_SERVER_VERSION key should go before the WREN_AI_SERVICE_VERSION key


[warning] 18-18: [UnorderedKey] The WREN_BOOTSTRAP_VERSION key should go before the WREN_ENGINE_VERSION key

🪛 Pylint (3.3.7)
wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py

[refactor] 323-328: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (15)
wren-ai-service/tools/dev/.env (1)

14-18: Pin explicit version tags to avoid drifting dependencies. The replacement of "latest" with fixed versions (0.16.1, 0.23.2, 0.16.1, 0.28.0, 0.1.5) ensures consistent, reproducible builds.

wren-ai-service/src/pipelines/retrieval/preprocess_sql_data.py (1)

52-60: Guard against infinite loops in data reduction. Introducing the iteration counter with a 1000-iteration break prevents endless token trimming when reducing SQL data.

wren-ai-service/tests/pytest/services/test_semantics_description.py (1)

234-235: Formatting-only change for dictionary literal. Converting the nested dict to a single-line expression preserves behavior while improving brevity.

wren-ai-service/src/web/v1/routers/ask.py (1)

155-159: Refactored feedback result initialization formatting. Switching to bracket notation for _ask_feedback_results[query_id] assignment is a non-functional style update that enhances clarity.

wren-ai-service/src/providers/__init__.py (1)

78-86: Consistent multi-line unpacking in litellm_params. The added commas and structured conditional unpacking for api_version and kwargs maintain existing logic while improving readability.

wren-ai-service/src/pipelines/generation/sql_correction.py (1)

103-108: Component name added correctly – LGTM

generator_name is surfaced via _components; that keeps the Hamilton graph consistent with the new function signature.

wren-ai-service/src/pipelines/generation/relationship_recommendation.py (2)

65-77: Potential misuse of generate result

normalized() still executes reply = generate.get("replies")[0].
If trace_cost ever returns the raw tuple (e.g., in error paths or when the decorator is disabled), this will raise. Consider guarding with:

raw = generate[0] if isinstance(generate, tuple) else generate
reply = raw.get("replies")[0]

199-200: Component injection looks good

The extra generator_name entry is necessary for Hamilton to satisfy the new parameter; no issues spotted.

wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (1)

107-108: Component wiring verified

generator_name added; consistent with other pipelines.

wren-ai-service/src/pipelines/generation/intent_classification.py (1)

352-353: Component addition OK

generator_name correctly supplied.

wren-ai-service/src/pipelines/generation/semantics_description.py (1)

219-220: No issues with component injection

generator_name added – consistent and correct.

wren-ai-service/src/pipelines/generation/chart_generation.py (1)

130-131: Component naming is fine, but remember to mark it as a @node only if consumed

Adding "generator_name" to _components is OK; just verify that no other pipeline adds another key with the same name to avoid collision when merging inputs.

wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py (1)

459-460: Component addition OK – just ensure unique key

No objections; same caveat on potential key collision as noted earlier.

wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (1)

122-123: Constructor change looks good

Injection of model name into components is consistent with the new pattern.

wren-ai-service/src/pipelines/generation/followup_sql_generation.py (1)

153-154: Addition of generator_name component accepted

Implementation consistent across pipelines.

Comment thread wren-ai-service/eval/metrics/spider/process_sql.py
Comment thread wren-ai-service/eval/metrics/spider/process_sql.py Outdated
Comment thread wren-ai-service/src/pipelines/generation/user_guide_assistance.py
Comment thread wren-ai-service/src/pipelines/generation/sql_correction.py
Comment thread wren-ai-service/src/pipelines/generation/chart_generation.py
Comment thread wren-ai-service/src/pipelines/generation/sql_tables_extraction.py
Comment on lines +321 to 329
prompt: dict, table_columns_selection_generator: Any, generator_name: str
) -> dict:
if prompt:
return await table_columns_selection_generator(
prompt=prompt.get("prompt")
)
), generator_name
else:
return {}
return {}, generator_name

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Logic now always enters truthy branch – breaks pruning path

Returning a tuple makes filter_columns_in_tables always truthy (({}, "gpt-4o")), so construct_retrieval_results() will incorrectly attempt to access ["replies"] on a tuple and bypass the “no-pruning” path.

Adopt one of:

-        return await table_columns_selection_generator(...), generator_name
+        result: dict = await table_columns_selection_generator(...)
+        result["generator_name"] = generator_name
+        return result

and drop the tuple altogether; or adjust the downstream truthiness check & attribute access.

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Pylint (3.3.7)

[refactor] 323-328: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)

🤖 Prompt for AI Agents
In wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py around lines
321 to 329, the function returns a tuple which causes the caller to always
evaluate it as truthy, breaking the pruning logic. To fix this, modify the
function to return only the dictionary (or an empty dict) without wrapping it in
a tuple, or alternatively update the downstream code to correctly handle the
tuple by adjusting truthiness checks and attribute access accordingly.

Comment thread wren-ai-service/src/pipelines/generation/followup_sql_generation.py
…nsistency across pipelines, and update type hints to include Tuple in multiple files.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py (1)

321-328: Returning a tuple breaks downstream logic – revert to a single‐dict payload

filter_columns_in_tables() now returns (dict, str), yet construct_retrieval_results() still treats the node output as a dict (e.g. filter_columns_in_tables["replies"]).
At runtime this will raise TypeError: tuple indices must be integers or slices, not str, and the mere truthiness of the tuple will wrongly force the pruning path.

Restore the original dict return type and embed the generator name inside the dict to keep interfaces consistent and avoid truthiness pitfalls.
This also removes the superfluous else flagged by pylint.

-async def filter_columns_in_tables(
-    prompt: dict, table_columns_selection_generator: Any, generator_name: str
-) -> tuple[dict, str]:
-    if prompt:
-        return await table_columns_selection_generator(
-            prompt=prompt.get("prompt")
-        ), generator_name
-    else:
-        return {}, generator_name
+async def filter_columns_in_tables(
+    prompt: dict,
+    table_columns_selection_generator: Any,
+    generator_name: str,
+) -> dict:
+    """Runs the column-selection LLM and attaches generator metadata."""
+
+    result: dict
+    if prompt:
+        result = await table_columns_selection_generator(
+            prompt=prompt.get("prompt")
+        )
+    else:
+        result = {}
+
+    # Propagate model identity without changing the outer type.
+    result["generator_name"] = generator_name
+    return result

After this change, no further modifications are needed in construct_retrieval_results() and the pylint R1705 warning is resolved.
Please run the unit / integration tests to confirm the fix.

🧹 Nitpick comments (1)
wren-ai-service/eval/metrics/spider/process_sql.py (1)

560-565: Prefer try/except over str.isdigit() for robust LIMIT parsing

str.isdigit() rejects negative numbers and any representation containing a sign or whitespace, and it also requires the string to be non-empty.
A small try/except around int(limit_token) is both clearer and more permissive.

-        limit_token = toks[idx - 1]
-        if not str(limit_token).isdigit():
-            # Preserve previous behaviour but make the intent explicit
-            return idx, 1
-
-        return idx, int(limit_token)
+        limit_token = toks[idx - 1]
+        try:
+            return idx, int(limit_token)
+        except ValueError:
+            # Preserve previous behaviour but make the intent explicit
+            return idx, 1
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a49af96 and 1f53757.

📒 Files selected for processing (17)
  • wren-ai-service/eval/metrics/spider/process_sql.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/chart_adjustment.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/chart_generation.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/followup_sql_generation.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/intent_classification.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_correction.py (3 hunks)
  • wren-ai-service/src/pipelines/generation/sql_generation.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_question.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_regeneration.py (2 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/retrieval/db_schema_retrieval.py (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (15)
  • wren-ai-service/src/pipelines/generation/sql_correction.py
  • wren-ai-service/src/pipelines/generation/relationship_recommendation.py
  • wren-ai-service/src/pipelines/generation/sql_tables_extraction.py
  • wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py
  • wren-ai-service/src/pipelines/generation/sql_question.py
  • wren-ai-service/src/pipelines/generation/user_guide_assistance.py
  • wren-ai-service/src/pipelines/generation/sql_regeneration.py
  • wren-ai-service/src/pipelines/generation/chart_generation.py
  • wren-ai-service/src/pipelines/generation/followup_sql_generation.py
  • wren-ai-service/src/pipelines/generation/chart_adjustment.py
  • wren-ai-service/src/pipelines/generation/sql_generation.py
  • wren-ai-service/src/pipelines/generation/semantics_description.py
  • wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py
  • wren-ai-service/src/pipelines/generation/intent_classification.py
  • wren-ai-service/src/pipelines/generation/question_recommendation.py
🧰 Additional context used
🪛 Pylint (3.3.7)
wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py

[refactor] 323-328: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
wren-ai-service/eval/metrics/spider/process_sql.py (1)

321-324: Exception handling correctly narrowed to ValueError – good catch

Limiting the except clause to ValueError prevents unrelated errors from being swallowed and improves debuggability.
No further action required.

@yichieh-lu yichieh-lu changed the title Feat/wren ai service/enable filtering is fallback triggered feat/wren ai service/enable filtering is fallback triggered Jun 17, 2025
Replaced tuple yields (e.g., `yield key, value`) with dicts to avoid issues
related to unpacking, schema validation, or serialization in downstream code.

This ensures more consistent and safer data handling across generator consumers.
Enhanced the trace_cost function to include fallback metadata, allowing for better tracking of model usage and fallback conditions. This update improves the context management for AI service operations.
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py (1)

321-328: Tuple return still breaks downstream logic – same issue as flagged previously

filter_columns_in_tables() continues to return a tuple (<dict>, generator_name), but construct_retrieval_results() still treats the value as a mapping and immediately does
filter_columns_in_tables["replies"][0], which raises TypeError: tuple indices must be integers.

Either embed the model name inside the dict (recommended) or update every downstream consumer to unpack the tuple before treating it as a dict.

Suggested quick fix:

-async def filter_columns_in_tables(
-    prompt: dict, table_columns_selection_generator: Any, generator_name: str
-) -> dict:
-    if prompt:
-        return await table_columns_selection_generator(
-            prompt=prompt.get("prompt")
-        ), generator_name
-    else:
-        return {}, generator_name
+async def filter_columns_in_tables(
+    prompt: dict, table_columns_selection_generator: Any, generator_name: str
+) -> dict:
+    if not prompt:
+        return {}
+
+    result: dict = await table_columns_selection_generator(
+        prompt=prompt.get("prompt")
+    )
+    # propagate the model name in-band
+    result["generator_name"] = generator_name
+    return result

This keeps the return type a dict, preserves generator provenance, and avoids breaking callers.

🧹 Nitpick comments (1)
wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py (1)

323-328: Minor: Unnecessary else after return

After an early return, the else block is redundant and triggers Pylint R1705. Removing it simplifies the flow.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f53757 and 03569bb.

📒 Files selected for processing (17)
  • wren-ai-service/src/pipelines/generation/chart_adjustment.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/chart_generation.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/followup_sql_generation.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/intent_classification.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_correction.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_generation.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_question.py (2 hunks)
  • wren-ai-service/src/pipelines/generation/sql_regeneration.py (2 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/retrieval/db_schema_retrieval.py (2 hunks)
  • wren-ai-service/src/utils.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (16)
  • wren-ai-service/src/pipelines/generation/relationship_recommendation.py
  • wren-ai-service/src/pipelines/generation/followup_sql_generation.py
  • wren-ai-service/src/pipelines/generation/sql_regeneration.py
  • wren-ai-service/src/pipelines/generation/chart_generation.py
  • wren-ai-service/src/pipelines/generation/semantics_description.py
  • wren-ai-service/src/pipelines/generation/sql_generation_reasoning.py
  • wren-ai-service/src/pipelines/generation/sql_correction.py
  • wren-ai-service/src/pipelines/generation/user_guide_assistance.py
  • wren-ai-service/src/pipelines/generation/sql_tables_extraction.py
  • wren-ai-service/src/pipelines/generation/question_recommendation.py
  • wren-ai-service/src/utils.py
  • wren-ai-service/src/pipelines/generation/chart_adjustment.py
  • wren-ai-service/src/pipelines/generation/sql_question.py
  • wren-ai-service/src/pipelines/generation/sql_generation.py
  • wren-ai-service/src/pipelines/generation/intent_classification.py
  • wren-ai-service/src/pipelines/generation/followup_sql_generation_reasoning.py
🧰 Additional context used
🪛 Pylint (3.3.7)
wren-ai-service/src/pipelines/retrieval/db_schema_retrieval.py

[refactor] 323-328: Unnecessary "else" after "return", remove the "else" and de-indent the code inside it

(R1705)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (go)

@cyyeh cyyeh changed the title feat/wren ai service/enable filtering is fallback triggered feat(wren-ai-service): enable filtering is fallback triggered Jun 17, 2025
@cyyeh cyyeh added module/ai-service ai-service related ci/ai-service ai-service related labels Jun 17, 2025
@cyyeh cyyeh self-requested a review June 17, 2025 07:50
Copy link
Copy Markdown
Member

@cyyeh cyyeh left a comment

Choose a reason for hiding this comment

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

lgtm, thanks

@cyyeh cyyeh merged commit 6e84b6a into main Jun 17, 2025
10 of 11 checks passed
@cyyeh cyyeh deleted the feat/wren-ai-service/enable-filtering-is_fallback_triggered branch June 17, 2025 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/ai-service ai-service related module/ai-service ai-service related wren-ai-service

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants