Skip to content

feat(wren-ai-service): new-workflow-api (ai-env-changed) #1591

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

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8b91226
add web v2 endpoint boilerplates
cyyeh Apr 18, 2025
4361ccc
update
cyyeh Apr 22, 2025
449a08a
update
cyyeh Apr 22, 2025
4ef1dd9
handle streaming stop
cyyeh Apr 22, 2025
dd00613
update
cyyeh Apr 22, 2025
7d03e2e
update
cyyeh Apr 23, 2025
e39982e
update
cyyeh Apr 23, 2025
9cf6c68
update deps
cyyeh Apr 23, 2025
4b4053a
refactor
cyyeh Apr 23, 2025
1e3f9cf
update
cyyeh Apr 23, 2025
bca3429
add content_block_label
cyyeh Apr 24, 2025
6eed7f6
update
cyyeh Apr 24, 2025
014fc94
update
cyyeh Apr 24, 2025
3ffaf2f
update
cyyeh Apr 24, 2025
5affb41
add invalid_sql
cyyeh Apr 24, 2025
aca2d8c
update conversation history
cyyeh Apr 24, 2025
8eaa736
fix bug
cyyeh Apr 24, 2025
8d10a20
update
cyyeh May 6, 2025
5c7f842
update
cyyeh Apr 25, 2025
bc1e47e
update
cyyeh Apr 25, 2025
cf85c5f
update
cyyeh Apr 25, 2025
ee7a366
update
cyyeh Apr 25, 2025
c9e452a
update
cyyeh Apr 28, 2025
bc2c962
fix chart adjustment
cyyeh Apr 30, 2025
9de0c7d
fix intent classification output
cyyeh Apr 30, 2025
f507f26
fix
cyyeh May 2, 2025
6ec37c2
fix history order
cyyeh May 5, 2025
105e620
update
cyyeh May 5, 2025
5f01768
update
cyyeh May 5, 2025
22cf00b
fix
cyyeh May 6, 2025
a2cf016
add greetings and refactor
cyyeh May 7, 2025
39e214b
refactor
cyyeh May 7, 2025
3a9ad97
add PREVIEW_DATA
cyyeh May 7, 2025
7244d32
update
cyyeh May 7, 2025
a5c36f5
fix chart
cyyeh May 7, 2025
0b5bd4c
update
cyyeh May 7, 2025
e7325d6
update
cyyeh May 7, 2025
b3ef012
update
cyyeh May 8, 2025
0bd90ff
add title to DATA_PREVIEW
cyyeh May 8, 2025
99d6218
update configs
cyyeh May 8, 2025
61251d6
update wording
cyyeh May 9, 2025
7b3075f
improve sql_executor
cyyeh May 9, 2025
4733480
Merge branch 'main' into feat/ai-service/workflow-improvement
cyyeh May 9, 2025
64dc800
allow string type as conversationhistory response
cyyeh May 12, 2025
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
3 changes: 2 additions & 1 deletion deployment/kustomizations/base/cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ data:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
doc_endpoint: https://docs.getwren.ai
Expand Down
3 changes: 2 additions & 1 deletion docker/config.example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
doc_endpoint: https://docs.getwren.ai
Expand Down
3 changes: 2 additions & 1 deletion wren-ai-service/docs/config_examples/config.anthropic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
engine_timeout: 30
Expand Down
3 changes: 2 additions & 1 deletion wren-ai-service/docs/config_examples/config.azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
engine_timeout: 30
Expand Down
3 changes: 2 additions & 1 deletion wren-ai-service/docs/config_examples/config.deepseek.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
engine_timeout: 30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
engine_timeout: 30
Expand Down
3 changes: 2 additions & 1 deletion wren-ai-service/docs/config_examples/config.grok.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
engine_timeout: 30
Expand Down
3 changes: 2 additions & 1 deletion wren-ai-service/docs/config_examples/config.groq.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
engine_timeout: 30
Expand Down
3 changes: 2 additions & 1 deletion wren-ai-service/docs/config_examples/config.lm_studio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
engine_timeout: 30
Expand Down
3 changes: 2 additions & 1 deletion wren-ai-service/docs/config_examples/config.ollama.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
engine_timeout: 30
Expand Down
3 changes: 2 additions & 1 deletion wren-ai-service/docs/config_examples/config.open_router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ pipes:
document_store: qdrant
- name: sql_tables_extraction
llm: litellm_llm.default

- name: data_exploration_assistance
llm: litellm_llm.default
---
settings:
engine_timeout: 30
Expand Down
644 changes: 1 addition & 643 deletions wren-ai-service/poetry.lock

Large diffs are not rendered by default.

15 changes: 4 additions & 11 deletions wren-ai-service/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,19 @@ qdrant-client = "==1.11.0"

[tool.poetry.group.dev.dependencies]
pre-commit = "^3.7.1"
streamlit = "^1.37.0"
watchdog = "^4.0.0"
pandas = "^2.2.2"
matplotlib = "^3.9.2"
sseclient-py = "^1.8.0"
dspy-ai = "^2.5.26"
requests = "^2.32.2"
extra-streamlit-components = "^0.1.71"
deepeval = "^1.0.6"
tomlkit = "^0.13.0"
nltk = "^3.9.1"

[tool.poetry.group.eval.dependencies]
gitpython = "^3.1.43"
plotly = "^5.24.1"
nbformat = "^5.1.3"
ipykernel = "^6.29.5"
itables = "^2.2.1"
gdown = "^5.2.0"
streamlit-tags = "^1.2.8"
nltk = "^3.9.1"
tomlkit = "^0.13.0"
deepeval = "^1.0.6"
dspy-ai = "^2.5.26"

[tool.poetry.group.test.dependencies]
locust = "^2.32.0"
Expand Down
2 changes: 2 additions & 0 deletions wren-ai-service/src/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
setup_custom_logger,
)
from src.web.v1 import routers
from src.web.v2 import routers as v2_routers

setup_custom_logger(
"wren-ai-service", level_str=settings.logging_level, is_dev=settings.development
Expand Down Expand Up @@ -54,6 +55,7 @@ async def lifespan(app: FastAPI):
allow_headers=["*"],
)
app.include_router(routers.router, prefix="/v1", tags=["v1"])
app.include_router(v2_routers.router, prefix="/v2", tags=["v2"])
# TODO: deprecated, it was used for load testing using locust only. should be removed in the future
if settings.development:
from src.web import development
Expand Down
83 changes: 83 additions & 0 deletions wren-ai-service/src/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from src.pipelines import generation, indexing, retrieval
from src.utils import fetch_wren_ai_docs
from src.web.v1 import services
from src.web.v2 import services as v2_services

logger = logging.getLogger("wren-ai-service")

Expand All @@ -27,6 +28,7 @@ class ServiceContainer:
sql_question_service: services.SqlQuestionService
instructions_service: services.InstructionsService
sql_correction_service: services.SqlCorrectionService
conversation_service: v2_services.ConversationService


@dataclass
Expand Down Expand Up @@ -269,6 +271,87 @@ def create_service_container(
},
**query_cache,
),
conversation_service=v2_services.ConversationService(
pipelines={
"intent_classification": generation.IntentClassificationV2(
**pipe_components["intent_classification"],
wren_ai_docs=wren_ai_docs,
),
"misleading_assistance": generation.MisleadingAssistance(
**pipe_components["misleading_assistance"],
),
"data_assistance": generation.DataAssistance(
**pipe_components["data_assistance"]
),
"user_guide_assistance": generation.UserGuideAssistance(
**pipe_components["user_guide_assistance"],
wren_ai_docs=wren_ai_docs,
),
"data_exploration_assistance": generation.DataExplorationAssistance(
**pipe_components["data_exploration_assistance"],
),
"db_schema_retrieval": retrieval.DbSchemaRetrieval(
**pipe_components["db_schema_retrieval"],
table_retrieval_size=settings.table_retrieval_size,
table_column_retrieval_size=settings.table_column_retrieval_size,
),
"historical_question": retrieval.HistoricalQuestionRetrieval(
**pipe_components["historical_question_retrieval"],
historical_question_retrieval_similarity_threshold=settings.historical_question_retrieval_similarity_threshold,
),
"sql_pairs_retrieval": retrieval.SqlPairsRetrieval(
**pipe_components["sql_pairs_retrieval"],
sql_pairs_similarity_threshold=settings.sql_pairs_similarity_threshold,
sql_pairs_retrieval_max_size=settings.sql_pairs_retrieval_max_size,
),
"instructions_retrieval": retrieval.Instructions(
**pipe_components["instructions_retrieval"],
similarity_threshold=settings.instructions_similarity_threshold,
top_k=settings.instructions_top_k,
),
"sql_generation": generation.SQLGeneration(
**pipe_components["sql_generation"],
engine_timeout=settings.engine_timeout,
),
"sql_generation_reasoning": generation.SQLGenerationReasoning(
**pipe_components["sql_generation_reasoning"],
),
"followup_sql_generation_reasoning": generation.FollowUpSQLGenerationReasoning(
**pipe_components["followup_sql_generation_reasoning"],
),
"sql_correction": generation.SQLCorrection(
**pipe_components["sql_correction"],
engine_timeout=settings.engine_timeout,
),
"followup_sql_generation": generation.FollowUpSQLGeneration(
**pipe_components["followup_sql_generation"],
engine_timeout=settings.engine_timeout,
),
"sql_regeneration": generation.SQLRegeneration(
**pipe_components["sql_regeneration"],
engine_timeout=settings.engine_timeout,
),
"sql_functions_retrieval": retrieval.SqlFunctions(
**pipe_components["sql_functions_retrieval"],
engine_timeout=settings.engine_timeout,
),
"sql_executor": retrieval.SQLExecutor(
**pipe_components["sql_executor"],
engine_timeout=settings.engine_timeout,
),
"sql_answer": generation.SQLAnswer(
**pipe_components["sql_answer"],
engine_timeout=settings.engine_timeout,
),
"chart_generation": generation.ChartGeneration(
**pipe_components["chart_generation"],
),
"chart_adjustment": generation.ChartAdjustmentV2(
**pipe_components["chart_adjustment"],
),
},
max_histories=settings.max_histories,
),
)


Expand Down
6 changes: 6 additions & 0 deletions wren-ai-service/src/pipelines/generation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from .chart_adjustment import ChartAdjustment
from .chart_adjustment_v2 import ChartAdjustmentV2
from .chart_generation import ChartGeneration
from .data_assistance import DataAssistance
from .data_exploration_assistance import DataExplorationAssistance
from .followup_sql_generation import FollowUpSQLGeneration
from .followup_sql_generation_reasoning import FollowUpSQLGenerationReasoning
from .intent_classification import IntentClassification
from .intent_classification_v2 import IntentClassificationV2
from .misleading_assistance import MisleadingAssistance
from .question_recommendation import QuestionRecommendation
from .relationship_recommendation import RelationshipRecommendation
Expand All @@ -20,9 +23,11 @@
__all__ = [
"ChartGeneration",
"ChartAdjustment",
"ChartAdjustmentV2",
"DataAssistance",
"FollowUpSQLGeneration",
"IntentClassification",
"IntentClassificationV2",
"QuestionRecommendation",
"RelationshipRecommendation",
"SemanticsDescription",
Expand All @@ -36,4 +41,5 @@
"FollowUpSQLGenerationReasoning",
"MisleadingAssistance",
"SQLTablesExtraction",
"DataExplorationAssistance",
]
Loading
Loading