Skip to content

Commit

Permalink
fix: clarification questions now work with vertex ai
Browse files Browse the repository at this point in the history
  • Loading branch information
gventuri committed Dec 13, 2023
1 parent bf1c3f7 commit 5f03916
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions pandasai/agent/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def clarification_questions(self, query: str) -> List[str]:
f"""Clarification Questions: {result}
"""
)
result = result.replace("```json", "").replace("```", "")
questions: list[str] = json.loads(result)
return questions[:3]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

You are provided with the following pandas DataFrames:

{dataframes}
Expand All @@ -7,14 +6,13 @@ You are provided with the following pandas DataFrames:
{conversation}
</conversation>

Based on the conversation, are there any clarification questions that a senior data scientist would ask about the query "{query}"?

It is extremely important that you follow the following guidelines when generating clarification questions:
- Ask questions a non technical person could answer. Do not include technical terms, do not ask for questions that require knowledge about how the dataframes are structured or about a specific column.
Find the clarification questions that could be asked to a senior data scientist would ask about the query "{query}"?
- Only ask for questions related to the query if the query is not clear or ambiguous and that cannot be deduced from the context.
- Return a maximum of 3 questions. The lower the number of questions, the better.
- If no meaningful clarification questions can be asked, return an empty array.
- Return up to 3 questions.

Example:
['Question 1', 'Question 2']

Return the JSON array of the clarification questions.
Return a JSON list of the clarification questions strings.

Json:
1 change: 1 addition & 0 deletions pandasai/prompts/clarification_questions_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def setup(

def validate(self, output) -> bool:
try:
output = output.replace("```json", "").replace("```", "")
json_data = json.loads(output)
return isinstance(json_data, List)
except json.JSONDecodeError:
Expand Down

0 comments on commit 5f03916

Please sign in to comment.