Skip to content

Commit e7a28db

Browse files
committed
Added async explain_sql API
1 parent 2f28b32 commit e7a28db

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

doc/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Sphinx is used to generate documentation
22

33
```text
4-
python -m pip install sphinx
4+
python -m pip install -r requirements.txt
55
```
66

77
For more information on Sphinx, please visit this page:

examples/async_examples/1_sql.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ async def main():
3232
sql_tasks = [
3333
async_profile.show_sql(prompt="How many customers?"),
3434
async_profile.run_sql(prompt="How many promotions"),
35+
async_profile.explain_sql(prompt="How many promotions"),
3536
]
3637
# Collect results from multiple asynchronous tasks
3738
for sql_task in asyncio.as_completed(sql_tasks):

src/select_ai/async_profile.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,17 @@ async def narrate(self, prompt, params: Mapping = None) -> str:
305305
prompt, action=Action.NARRATE, params=params
306306
)
307307

308+
async def explain_sql(self, prompt: str, params: Mapping = None):
309+
"""Explain the generated SQL
310+
311+
:param str prompt: Natural language prompt
312+
:param params: Parameters to include in the LLM request
313+
:return: str
314+
"""
315+
return await self.generate(
316+
prompt, action=Action.EXPLAINSQL, params=params
317+
)
318+
308319
async def run_sql(
309320
self, prompt, params: Mapping = None
310321
) -> pandas.DataFrame:

0 commit comments

Comments
 (0)