Skip to content

Commit

Permalink
Support the input of a large DataFrame when generating follow-up ques…
Browse files Browse the repository at this point in the history
…tions.

It might get this error when submit a big df to LLM.

File "/workspace/venv/lib/python3.10/site-packages/vanna/base/base.py", line 317, in generate_followup_questions
    llm_response = self.submit_prompt(message_log, **kwargs)
  File "/workspace/venv/lib/python3.10/site-packages/vanna/bedrock/bedrock_converse.py", line 85, in submit_prompt
    raise Exception(f"A Bedrock client error occurred: {message}")
Exception: A Bedrock client error occurred: Input is too long for requested model.
  • Loading branch information
Flyfoxs authored Jan 29, 2025
1 parent ad014c4 commit bb03250
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/vanna/base/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def generate_followup_questions(

message_log = [
self.system_message(
f"You are a helpful data assistant. The user asked the question: '{question}'\n\nThe SQL query for this question was: {sql}\n\nThe following is a pandas DataFrame with the results of the query: \n{df.to_markdown()}\n\n"
f"You are a helpful data assistant. The user asked the question: '{question}'\n\nThe SQL query for this question was: {sql}\n\nThe following is a pandas DataFrame with the results of the query: \n{df.head(25).to_markdown()}\n\n"
),
self.user_message(
f"Generate a list of {n_questions} followup questions that the user might ask about this data. Respond with a list of questions, one per line. Do not answer with any explanations -- just the questions. Remember that there should be an unambiguous SQL query that can be generated from the question. Prefer questions that are answerable outside of the context of this conversation. Prefer questions that are slight modifications of the SQL query that was generated that allow digging deeper into the data. Each question will be turned into a button that the user can click to generate a new SQL query so don't use 'example' type questions. Each question must have a one-to-one correspondence with an instantiated SQL query." +
Expand Down

0 comments on commit bb03250

Please sign in to comment.