Skip to content

Commit 3252afe

Browse files
authored
Merge pull request #1050 from Mara3l/master
2 parents 46ecd8b + a016126 commit 3252afe

File tree

9 files changed

+375
-0
lines changed

9 files changed

+375
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
title: "GoodData AI (beta)"
3+
linkTitle: "GoodData AI (beta)"
4+
weight: 24
5+
no_list: true
6+
---
7+
8+
GoodData AI is a feature that allows you to ask questions about your data in natural language.
9+
10+
For more information on how to use and setup GoodData AI, see the [GoodData AI documentation](https://www.gooddata.com/docs/cloud/ai/).
11+
12+
## Methods
13+
14+
* [ai_chat](./ai_chat/)
15+
* [ai_chat_stream](./ai_chat_stream/)
16+
* [get_ai_chat_history](./get_ai_chat_history/)
17+
* [reset_ai_chat_history](./reset_ai_chat_history/)
18+
* [set_ai_chat_history_feedback](./set_ai_chat_history_feedback/)
19+
* [search_ai](./search_ai/)
20+
* [sync_metadata](./sync_metadata/)
21+
22+
23+
## Example
24+
25+
This example shows how to use the GoodData AI to get execution definition. You can also use it to get a pandas dataframe, but for that you need to use the [GoodPandas](../../pandas/).
26+
27+
```python
28+
from gooddata_sdk import GoodDataSdk # For AI chat and execution definition.
29+
from gooddata_pandas import GoodDataPandas # For pandas dataframe.
30+
31+
32+
host = "https://www.example.com"
33+
token = "<your_personal_access_token>"
34+
sdk = GoodDataSdk.create(host, token)
35+
36+
# Get execution definition from AI chat (not needed for pandas dataframe)
37+
response = sdk.compute.ai_chat(test_workspace_id, "Display the revenue by product")
38+
execution_definition = sdk.compute.buid_exec_def_from_chat_result(response)
39+
40+
# Create a pandas dataframe from the AI response.
41+
gp = GoodDataPandas(host, token)
42+
gdf = gp.data_frames(workspace_id)
43+
df, df_metadata = gdf.for_created_visualization(response)
44+
45+
# Print the results
46+
print(execution_definition) # Execution Definition.
47+
print(df_metadata) # Dataframe metadata.
48+
print(df) # Pandas dataframe.
49+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: "ai_chat"
3+
linkTitle: "ai_chat"
4+
weight: 92
5+
superheading: "compute."
6+
---
7+
8+
``ai_chat(workspace_id: str, question: str) -> ChatResult``
9+
10+
Chat with AI in GoodData workspace.
11+
12+
13+
{{% parameters-block title="Parameters" %}}
14+
{{< parameter p_name="workspace_id" p_type="str" >}}
15+
The ID of the GoodData Workspace.
16+
{{< /parameter >}}
17+
{{< parameter p_name="question" p_type="str" >}}
18+
The question to ask the AI.
19+
{{< /parameter >}}
20+
{{% /parameters-block %}}
21+
22+
{{% parameters-block title="Returns"%}}
23+
{{< parameter p_name="chat_result" p_type="ChatResult" >}}
24+
Chat response
25+
{{< /parameter >}}
26+
{{% /parameters-block %}}
27+
28+
29+
## Example
30+
31+
```python
32+
33+
host = "https://www.example.com"
34+
token = "<your_personal_access_token>"
35+
sdk = GoodDataSdk.create(host, token)
36+
37+
chat_result = sdk.compute.ai_chat(workspace_id, "Display the revenue by product")
38+
39+
print(chat_result)
40+
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: "ai_chat_stream"
3+
linkTitle: "ai_chat_stream"
4+
weight: 93
5+
superheading: "compute."
6+
---
7+
8+
``ai_chat_stream(workspace_id: str, question: str) -> Iterator[Any]``
9+
10+
Chat with AI in GoodData workspace. Stream the response.
11+
12+
13+
{{% parameters-block title="Parameters" %}}
14+
{{< parameter p_name="workspace_id" p_type="str" >}}
15+
The ID of the GoodData Workspace.
16+
{{< /parameter >}}
17+
{{< parameter p_name="question" p_type="str" >}}
18+
The question to ask the AI.
19+
{{< /parameter >}}
20+
{{% /parameters-block %}}
21+
22+
{{% parameters-block title="Returns"%}}
23+
{{< parameter p_name="chat_result" p_type="Iterator[Any]" >}}
24+
Yields parsed JSON objects from each SSE event's data field{{< /parameter >}}
25+
{{% /parameters-block %}}
26+
27+
28+
## Example
29+
30+
```python
31+
32+
host = "https://www.example.com"
33+
token = "<your_personal_access_token>"
34+
sdk = GoodDataSdk.create(host, token)
35+
36+
chat_result = sdk.compute.ai_chat_stream(workspace_id, "Display the revenue by product")
37+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
title: "build_exec_def_from_chat_result"
3+
linkTitle: "build_exec_def_from_chat_result"
4+
weight: 95
5+
superheading: "compute."
6+
---
7+
8+
``build_exec_def_from_chat_result(chat_result: ChatResult) -> ExecutionDefinition``
9+
10+
Build execution definition from chat result.
11+
12+
13+
{{% parameters-block title="Parameters" %}}
14+
{{< parameter p_name="chat_result" p_type="ChatResult" >}}
15+
ChatResult object containing visualization details from AI chat response
16+
{{< /parameter >}}
17+
{{% /parameters-block %}}
18+
19+
{{% parameters-block title="Returns" %}}
20+
{{< parameter p_name="execution_definition" p_type="ExecutionDefinition" >}}
21+
ExecutionDefinition object containing the execution definition for the visualization
22+
{{< /parameter >}}
23+
{{% /parameters-block %}}
24+
25+
26+
## Example
27+
28+
```python
29+
30+
host = "https://www.example.com"
31+
token = "<your_personal_access_token>"
32+
sdk = GoodDataSdk.create(host, token)
33+
34+
chat_result = sdk.compute.ai_chat(workspace_id, "Display the revenue by product")
35+
execution_definition = sdk.compute.build_exec_def_from_chat_result(chat_result)
36+
37+
print(execution_definition)
38+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: "ai_chat"
3+
linkTitle: "ai_chat"
4+
weight: 96
5+
superheading: "compute."
6+
---
7+
8+
``ai_chat(workspace_id: str, question: str) -> ChatResult``
9+
10+
Chat with AI in GoodData workspace.
11+
12+
13+
{{% parameters-block title="Parameters" %}}
14+
{{< parameter p_name="workspace_id" p_type="str" >}}
15+
The ID of the GoodData Workspace.
16+
{{< /parameter >}}
17+
{{< parameter p_name="question" p_type="str" >}}
18+
The question to ask the AI.
19+
{{< /parameter >}}
20+
{{% /parameters-block %}}
21+
22+
{{% parameters-block title="Returns"%}}
23+
{{< parameter p_name="chat_result" p_type="ChatResult" >}}
24+
Chat response
25+
{{< /parameter >}}
26+
{{% /parameters-block %}}
27+
28+
29+
## Example
30+
31+
```python
32+
33+
host = "https://www.example.com"
34+
token = "<your_personal_access_token>"
35+
sdk = GoodDataSdk.create(host, token)
36+
37+
chat_result = sdk.compute.ai_chat(workspace_id, "Display the revenue by product")
38+
39+
print(chat_result)
40+
```
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
title: "reset_ai_chat_history"
3+
linkTitle: "reset_ai_chat_history"
4+
weight: 97
5+
superheading: "compute."
6+
---
7+
8+
``reset_ai_chat_history(workspace_id: str) -> None``
9+
10+
Reset AI chat history in GoodData workspace.
11+
12+
13+
{{% parameters-block title="Parameters" %}}
14+
{{< parameter p_name="workspace_id" p_type="str" >}}
15+
The ID of the GoodData Workspace.
16+
{{< /parameter >}}
17+
{{% /parameters-block %}}
18+
19+
{{% parameters-block title="Returns" None="true"%}}
20+
{{% /parameters-block %}}
21+
22+
23+
## Example
24+
25+
```python
26+
27+
host = "https://www.example.com"
28+
token = "<your_personal_access_token>"
29+
sdk = GoodDataSdk.create(host, token)
30+
31+
sdk.compute.reset_ai_chat_history(workspace_id)
32+
```
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: "search_ai"
3+
linkTitle: "search_ai"
4+
weight: 98
5+
superheading: "compute."
6+
---
7+
8+
``search_ai(
9+
workspace_id: str,
10+
question: str,
11+
deep_search: Optional[bool] = None,
12+
limit: Optional[int] = None,
13+
object_types: Optional[list[str]] = None,
14+
relevant_score_threshold: Optional[float] = None,
15+
title_to_descriptor_ratio: Optional[float] = None,
16+
) -> SearchResult:``
17+
18+
Search for metadata objects using similarity search.
19+
20+
Default values for optional parameters are documented in the AI Search endpoint of the GoodData API.
21+
22+
23+
{{% parameters-block title="Parameters" %}}
24+
{{< parameter p_name="workspace_id" p_type="str" >}}
25+
The ID of the GoodData Workspace.
26+
{{< /parameter >}}
27+
{{< parameter p_name="question" p_type="str" >}}
28+
The question to ask the AI.
29+
{{< /parameter >}}
30+
{{< parameter p_name="deep_search" p_type="Optional[bool]" >}}
31+
turn on deep search - if true, content of complex objects will be searched as well
32+
{{< /parameter >}}
33+
{{< parameter p_name="limit" p_type="Optional[int]" >}}
34+
maximum number of results to return. Defaults to None.
35+
{{< /parameter >}}
36+
{{< parameter p_name="object_types" p_type="Optional[list[str]]" >}}
37+
list of object types to search for. Enum items: "attribute", "metric", "fact", "label", "date", "dataset", "visualization" and "dashboard". Defaults to None.
38+
{{< /parameter >}}
39+
{{< parameter p_name="relevant_score_threshold" p_type="Optional[float]" >}}
40+
minimum relevance score threshold for results. Defaults to None.
41+
{{< /parameter >}}
42+
{{< parameter p_name="title_to_descriptor_ratio" p_type="Optional[float]" >}}
43+
ratio of title score to descriptor score. Defaults to None.
44+
{{< /parameter >}}
45+
{{% /parameters-block %}}
46+
47+
{{% parameters-block title="Returns"%}}
48+
{{< parameter p_name="search_result" p_type="SearchResult" >}}
49+
SearchResult: Search results{{< /parameter >}}
50+
{{% /parameters-block %}}
51+
52+
53+
## Example
54+
55+
```python
56+
57+
host = "https://www.example.com"
58+
token = "<your_personal_access_token>"
59+
sdk = GoodDataSdk.create(host, token)
60+
61+
chat_result = sdk.compute.ai_chat(workspace_id, "Display the revenue by product")
62+
63+
print(chat_result)
64+
```
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: "set_ai_chat_history_feedback"
3+
linkTitle: "set_ai_chat_history_feedback"
4+
weight: 101
5+
superheading: "compute."
6+
---
7+
``set_ai_chat_history_feedback(workspace_id: str, interaction_id: str, user_feedback: str, chat_history_interaction_id: str, thread_id_suffix: str = "") -> None``
8+
9+
Set feedback for an AI chat history interaction.
10+
11+
12+
{{% parameters-block title="Parameters" %}}
13+
{{< parameter p_name="workspace_id" p_type="str" >}}
14+
workspace identifier
15+
{{< /parameter >}}
16+
{{< parameter p_name="interaction_id" p_type="str" >}}
17+
feedback to provide ("POSITIVE", "NEGATIVE" or "NONE").
18+
{{< /parameter >}}
19+
{{< parameter p_name="user_feedback" p_type="str" >}}
20+
interaction id to provide feedback for.
21+
{{< /parameter >}}
22+
{{< parameter p_name="chat_history_interaction_id" p_type="str" >}}
23+
suffix to identify a specific chat thread. Defaults to "".
24+
{{< /parameter >}}
25+
{{% /parameters-block %}}
26+
27+
{{% parameters-block title="Returns" None="true"%}}
28+
{{% /parameters-block %}}
29+
30+
31+
## Example
32+
33+
```python
34+
35+
host = "https://www.example.com"
36+
token = "<your_personal_access_token>"
37+
sdk = GoodDataSdk.create(host, token)
38+
39+
sdk.compute.set_ai_chat_history_feedback(workspace_id, "POSITIVE", "123", "456")
40+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: "sync_metadata"
3+
linkTitle: "sync_metadata"
4+
weight: 100
5+
superheading: "compute."
6+
---
7+
8+
``sync_metadata(workspace_id: str, async_req: bool = False) -> None``
9+
10+
Sync metadata in GoodData workspace.
11+
12+
13+
{{% parameters-block title="Parameters" %}}
14+
{{< parameter p_name="workspace_id" p_type="str" >}}
15+
The ID of the GoodData Workspace.
16+
{{< /parameter >}}
17+
{{< parameter p_name="async_req" p_type="bool" >}}
18+
Whether to perform the request asynchronously.
19+
{{< /parameter >}}
20+
{{% /parameters-block %}}
21+
22+
{{% parameters-block title="Returns" None="true"%}}
23+
{{% /parameters-block %}}
24+
25+
26+
## Example
27+
28+
```python
29+
30+
host = "https://www.example.com"
31+
token = "<your_personal_access_token>"
32+
sdk = GoodDataSdk.create(host, token)
33+
34+
sdk.compute.sync_metadata(workspace_id)
35+
```

0 commit comments

Comments
 (0)