Skip to content
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

chore(wren-ai-service): minor updates #1269

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions wren-ai-service/src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class Settings(BaseSettings):
allow_using_db_schemas_without_pruning: bool = Field(default=False)

# generation config
allow_intent_classification: bool = Field(default=True)
allow_sql_generation_reasoning: bool = Field(default=True)

# engine config
Expand Down
1 change: 1 addition & 0 deletions wren-ai-service/src/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def create_service_container(
**pipe_components["sql_summary"],
),
},
allow_intent_classification=settings.allow_intent_classification,
allow_sql_generation_reasoning=settings.allow_sql_generation_reasoning,
**query_cache,
),
Expand Down
17 changes: 9 additions & 8 deletions wren-ai-service/src/web/v1/services/ask.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class AskService:
def __init__(
self,
pipelines: Dict[str, BasicPipeline],
allow_intent_classification: bool = True,
allow_sql_generation_reasoning: bool = True,
maxsize: int = 1_000_000,
ttl: int = 120,
Expand All @@ -111,6 +112,7 @@ def __init__(
maxsize=maxsize, ttl=ttl
)
self._allow_sql_generation_reasoning = allow_sql_generation_reasoning
self._allow_intent_classification = allow_intent_classification

def _is_stopped(self, query_id: str):
if (
Expand Down Expand Up @@ -144,6 +146,8 @@ async def ask(
error_message = ""

try:
user_query = ask_request.query

# ask status can be understanding, searching, generating, finished, failed, stopped
# we will need to handle business logic for each status
if not self._is_stopped(query_id):
Expand All @@ -152,7 +156,7 @@ async def ask(
)

historical_question = await self._pipelines["historical_question"].run(
query=ask_request.query,
query=user_query,
id=ask_request.project_id,
)

Expand All @@ -173,10 +177,10 @@ async def ask(
for result in historical_question_result
]
sql_generation_reasoning = ""
else:
elif self._allow_intent_classification:
intent_classification_result = (
await self._pipelines["intent_classification"].run(
query=ask_request.query,
query=user_query,
history=ask_request.history,
id=ask_request.project_id,
configuration=ask_request.configurations,
Expand All @@ -188,11 +192,8 @@ async def ask(
)
intent_reasoning = intent_classification_result.get("reasoning")

user_query = (
ask_request.query
if not rephrased_question
else rephrased_question
)
if rephrased_question:
user_query = rephrased_question

if intent == "MISLEADING_QUERY":
self._ask_results[query_id] = AskResultResponse(
Expand Down
Loading