Skip to content

Commit aad1533

Browse files
google-genai-botcopybara-github
authored andcommitted
docs: update the ask_data_insights docstring
PiperOrigin-RevId: 802362601
1 parent 219815d commit aad1533

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

src/google/adk/tools/bigquery/data_insights_tool.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,10 @@ def ask_data_insights(
5050
5151
Args:
5252
project_id (str): The project that the inquiry is performed in.
53-
user_query_with_context (str): The user's question, potentially including
54-
conversation history and system instructions for context.
53+
user_query_with_context (str): The user's original request, enriched with
54+
relevant context from the conversation history. The user's core intent
55+
should be preserved, but context should be added to resolve ambiguities
56+
in follow-up questions.
5557
table_references (List[Dict[str, str]]): A list of dictionaries, each
5658
specifying a BigQuery table to be used as context for the question.
5759
credentials (Credentials): The credentials to use for the request.
@@ -66,13 +68,17 @@ def ask_data_insights(
6668
6769
Example:
6870
A query joining multiple tables, showing the full return structure.
71+
The original question: "Which customer from New York spent the most last
72+
month?"
73+
6974
>>> ask_data_insights(
7075
... project_id="some-project-id",
71-
... user_query_with_context="Which customer from New York spent the
72-
most last month? "
73-
... "Context: The 'customers' table joins with
74-
the 'orders' table "
75-
... "on the 'customer_id' column.",
76+
... user_query_with_context=(
77+
... "Which customer from New York spent the most last month?"
78+
... "Context: The 'customers' table joins with the 'orders' table"
79+
... " on the 'customer_id' column."
80+
... ""
81+
... ),
7682
... table_references=[
7783
... {
7884
... "projectId": "my-gcp-project",
@@ -126,25 +132,20 @@ def ask_data_insights(
126132
ca_url = f"https://geminidataanalytics.googleapis.com/v1alpha/projects/{project_id}/locations/{location}:chat"
127133

128134
instructions = """**INSTRUCTIONS - FOLLOW THESE RULES:**
129-
1. **CONTENT:** Your answer should present the supporting data and then provide a conclusion based on that data.
130-
2. **OUTPUT FORMAT:** Your entire response MUST be in plain text format ONLY.
131-
3. **NO CHARTS:** You are STRICTLY FORBIDDEN from generating any charts, graphs, images, or any other form of visualization.
135+
1. **CONTENT:** Your answer should present the supporting data and then provide a conclusion based on that data, including relevant details and observations where possible.
136+
2. **ANALYSIS DEPTH:** Your analysis must go beyond surface-level observations. Crucially, you must prioritize metrics that measure impact or outcomes over metrics that simply measure volume or raw counts. For open-ended questions, explore the topic from multiple perspectives to provide a holistic view.
137+
3. **OUTPUT FORMAT:** Your entire response MUST be in plain text format ONLY.
138+
4. **NO CHARTS:** You are STRICTLY FORBIDDEN from generating any charts, graphs, images, or any other form of visualization.
132139
"""
133140

134-
final_query_text = f"""
135-
{instructions}
136-
137-
**User Query and Context:**
138-
{user_query_with_context}
139-
"""
140-
141141
ca_payload = {
142142
"project": f"projects/{project_id}",
143-
"messages": [{"userMessage": {"text": final_query_text}}],
143+
"messages": [{"userMessage": {"text": user_query_with_context}}],
144144
"inlineContext": {
145145
"datasourceReferences": {
146146
"bq": {"tableReferences": table_references}
147147
},
148+
"systemInstruction": instructions,
148149
"options": {"chart": {"image": {"noImage": {}}}},
149150
},
150151
}

0 commit comments

Comments
 (0)