Skip to content

Commit

Permalink
update notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
zainhoda committed Jul 28, 2023
1 parent 7e0460b commit 2c8edf9
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 40 deletions.
103 changes: 68 additions & 35 deletions notebooks/vn-ask.ipynb

Large diffs are not rendered by default.

21 changes: 16 additions & 5 deletions src/vanna/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,12 @@ def ask(question: Union[str, None] = None, print_results: bool = True, auto_trai
return None, None, None, None

if print_results:
print(sql)

try:
Code = __import__('IPython.display', fromlist=['Code']).Code
display(Code(sql))
except Exception as e:
print(sql)

if run_sql is None:
print("If you want to run the SQL query, provide a vn.run_sql function.")

Expand Down Expand Up @@ -993,10 +997,17 @@ def ask(question: Union[str, None] = None, print_results: bool = True, auto_trai
if generate_followups:
followup_questions = generate_followup_questions(question=question, df=df)
if print_results and followup_questions is not None and len(followup_questions) > 0:
print("AI-generated follow-up questions:")
md = "AI-generated follow-up questions:\n\n"
for followup_question in followup_questions:
print(followup_question)
pass
md += f"* {followup_question}\n"

try:
display = __import__('IPython.display', fromlist=['display']).display
Markdown = __import__('IPython.display', fromlist=['Markdown']).Markdown
display(Markdown(md))
except Exception as e:
print(md)


if print_results:
return None
Expand Down

0 comments on commit 2c8edf9

Please sign in to comment.