Skip to content

Commit 01468bd

Browse files
committed
fix(ai): Use attribute id for label on SDK object
jira: GDAI-238 risk: low
1 parent 1d78b03 commit 01468bd

File tree

3 files changed

+70
-58
lines changed

3 files changed

+70
-58
lines changed

gooddata-sdk/gooddata_sdk/compute/visualization_to_sdk_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def convert_attribute(attr_dict: dict[str, Any]) -> Attribute:
3131
Attribute: An SDK Attribute object with local_id and label set
3232
"""
3333
local_id = attr_dict["id"]
34-
label = attr_dict["title"]
34+
label = attr_dict["id"]
3535
return Attribute(local_id=local_id, label=label)
3636

3737
@staticmethod

gooddata-sdk/tests/compute/fixtures/build_exec_def_from_chat_result.yaml

Lines changed: 68 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ interactions:
5050
to access it.
5151
status: 404
5252
title: Not Found
53-
traceId: 85c696d39f778b59e3021bc8655c417c
53+
traceId: 3078ca62b33d7fd01dc11b5be19dc230
5454
- request:
5555
method: GET
5656
uri: http://localhost:3000/api/v1/entities/workspaces/demo_testing?include=workspaces
@@ -99,7 +99,7 @@ interactions:
9999
to access it.
100100
status: 404
101101
title: Not Found
102-
traceId: 03937b37e651ec6d97d5d94df689ba7e
102+
traceId: df2b4b72297902bf4813ef4961090443
103103
- request:
104104
method: POST
105105
uri: http://localhost:3000/api/v1/entities/workspaces
@@ -1864,7 +1864,7 @@ interactions:
18641864
method: POST
18651865
uri: http://localhost:3000/api/v1/actions/workspaces/demo_testing/ai/chat
18661866
body:
1867-
question: What is the total revenue for the year 2024?
1867+
question: Display the revenue by product
18681868
headers:
18691869
Accept:
18701870
- application/json
@@ -1884,7 +1884,7 @@ interactions:
18841884
Cache-Control:
18851885
- no-cache, no-store, max-age=0, must-revalidate
18861886
Content-Length:
1887-
- '856'
1887+
- '775'
18881888
Content-Type:
18891889
- application/json
18901890
DATE: *id001
@@ -1916,70 +1916,67 @@ interactions:
19161916
reasoning: Creating a new visualization ...
19171917
createdVisualizations:
19181918
objects:
1919-
- id: total_revenue_for_2024
1920-
title: Total Revenue for 2024
1921-
visualizationType: HEADLINE
1919+
- id: revenue_by_product
1920+
title: Revenue by Product
1921+
visualizationType: COLUMN
19221922
metrics:
1923-
- id: total_revenue
1923+
- id: revenue
19241924
type: metric
1925-
title: Total Revenue
1926-
dimensionality: []
1927-
filters:
1928-
- using: date.year
1929-
include:
1930-
- '2024'
1925+
title: Revenue
1926+
dimensionality:
1927+
- id: product_name
1928+
type: attribute
1929+
title: Product name
1930+
filters: []
19311931
suggestions:
1932-
- query: Slice by 'Date - Month/Year' to see monthly revenue distribution
1933-
for 2024
1934-
label: Slice by month/year
1935-
- query: Slice by 'Date - Quarter/Year' to see quarterly revenue
1936-
distribution for 2024
1937-
label: Slice by quarter/year
1932+
- query: Slice by 'Category'
1933+
label: Slice by Category
1934+
- query: Switch to a table view for detailed comparison
1935+
label: Switch to Table View
19381936
reasoning: '
19391937
19401938
19411939
19421940
19431941
1944-
Here is a headline showing the Total Revenue for 2024.
1942+
Here is a column chart showing the Revenue by Product grouped by Product
1943+
name.
19451944
1946-
- Metrics: Total Revenue
1945+
- Metrics: Revenue
19471946
1948-
- Attributes: None
1947+
- Attributes: Product name
19491948
1950-
- Filter: Include Date. Year: 2024
1949+
- Filter: None
19511950
19521951
19531952
'
1954-
chatHistoryInteractionId: bc57ccb7ee8f4eec8eed2da588fdb9c3
1953+
chatHistoryInteractionId: bc34b41ff5d04e5eb658e0dffc0a3fd8
19551954
- request:
19561955
method: POST
19571956
uri: http://localhost:3000/api/v1/actions/workspaces/demo_testing/execution/afm/execute
19581957
body:
19591958
execution:
1960-
attributes: []
1961-
filters:
1962-
- positiveAttributeFilter:
1963-
in:
1964-
values:
1965-
- '2024'
1966-
label:
1967-
identifier:
1968-
id: date.year
1969-
type: label
1959+
attributes:
1960+
- label:
1961+
identifier:
1962+
id: product_name
1963+
type: label
1964+
localIdentifier: product_name
1965+
filters: []
19701966
measures:
19711967
- definition:
19721968
measure:
19731969
item:
19741970
identifier:
1975-
id: total_revenue
1971+
id: revenue
19761972
type: metric
19771973
computeRatio: false
19781974
filters: []
1979-
localIdentifier: total_revenue
1975+
localIdentifier: revenue
19801976
resultSpec:
19811977
dimensions:
1982-
- itemIdentifiers: []
1978+
- itemIdentifiers:
1979+
- product_name
19831980
localIdentifier: dim_0
19841981
- itemIdentifiers:
19851982
- measureGroup
@@ -2003,7 +2000,7 @@ interactions:
20032000
Cache-Control:
20042001
- no-cache, no-store, max-age=0, must-revalidate
20052002
Content-Length:
2006-
- '358'
2003+
- '646'
20072004
Content-Type:
20082005
- application/json
20092006
DATE: *id001
@@ -2026,24 +2023,39 @@ interactions:
20262023
X-Frame-Options:
20272024
- SAMEORIGIN
20282025
X-Gdc-Cancel-Token:
2029-
- 9dc6944c-e0f2-45e6-afc3-0b2276c397e1
2026+
- 00d8589a-ac36-4003-91b7-4d7740c479ca
20302027
X-GDC-TRACE-ID: *id001
20312028
X-Xss-Protection:
20322029
- 1; mode=block
20332030
body:
20342031
string:
20352032
executionResponse:
20362033
dimensions:
2037-
- headers: []
2034+
- headers:
2035+
- attributeHeader:
2036+
localIdentifier: product_name
2037+
label:
2038+
id: product_name
2039+
type: label
2040+
labelName: Product name
2041+
attribute:
2042+
id: product_name
2043+
type: attribute
2044+
attributeName: Product name
2045+
granularity: null
2046+
primaryLabel:
2047+
id: product_name
2048+
type: label
2049+
valueType: TEXT
20382050
localIdentifier: dim_0
20392051
- headers:
20402052
- measureGroupHeaders:
2041-
- localIdentifier: total_revenue
2053+
- localIdentifier: revenue
20422054
format: $#,##0
2043-
name: Total Revenue
2055+
name: Revenue
20442056
localIdentifier: dim_1
20452057
links:
2046-
executionResult: fb332d669c2540bc879f8591143bc142be634d42:5799a5b2a3489935b1e062ecdac565402623417d73ae07b4fe00c467bbfcb017
2058+
executionResult: 3686f03e3a854572d385962cdf522802010cfa49:8795bd272ad09519a4d36263aad7dc9b1d9ed3cebc1e874adcbd8618d419e005
20472059
- request:
20482060
method: POST
20492061
uri: http://localhost:3000/api/v1/actions/workspaces/demo_testing/ai/chatHistory
@@ -2146,18 +2158,6 @@ interactions:
21462158
body:
21472159
string:
21482160
data:
2149-
- id: demo
2150-
type: workspace
2151-
attributes:
2152-
name: Demo
2153-
links:
2154-
self: http://localhost:3000/api/v1/entities/workspaces/demo
2155-
- id: demo_testing
2156-
type: workspace
2157-
attributes:
2158-
name: demo_testing
2159-
links:
2160-
self: http://localhost:3000/api/v1/entities/workspaces/demo_testing
21612161
- id: demo_west
21622162
type: workspace
21632163
attributes:
@@ -2180,6 +2180,18 @@ interactions:
21802180
type: workspace
21812181
links:
21822182
self: http://localhost:3000/api/v1/entities/workspaces/demo_west_california
2183+
- id: demo
2184+
type: workspace
2185+
attributes:
2186+
name: Demo
2187+
links:
2188+
self: http://localhost:3000/api/v1/entities/workspaces/demo
2189+
- id: demo_testing
2190+
type: workspace
2191+
attributes:
2192+
name: demo_testing
2193+
links:
2194+
self: http://localhost:3000/api/v1/entities/workspaces/demo_testing
21832195
included:
21842196
- id: demo
21852197
type: workspace

gooddata-sdk/tests/compute/test_compute_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_build_exec_def_from_chat_result(test_config):
193193

194194
try:
195195
_setup_test_workspace(sdk, test_workspace_id, path)
196-
response = sdk.compute.ai_chat(test_workspace_id, "What is the total revenue for the year 2024?")
196+
response = sdk.compute.ai_chat(test_workspace_id, "Display the revenue by product")
197197
execution_definition = sdk.compute.build_exec_def_from_chat_result(response)
198198
assert execution_definition is not None
199199

0 commit comments

Comments
 (0)