Skip to content

Commit 2cad3a6

Browse files
authored
Merge pull request #870 from jaceksan/ai
PoC expose AI use cases
2 parents 254ea0a + add2998 commit 2cad3a6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

gooddata-sdk/gooddata_sdk/compute/service.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
import logging
55

6+
from gooddata_api_client.model.chat_history_request import ChatHistoryRequest
7+
from gooddata_api_client.model.chat_request import ChatRequest
8+
from gooddata_api_client.model.chat_result import ChatResult
9+
610
from gooddata_sdk.client import GoodDataApiClient
711
from gooddata_sdk.compute.model.execution import Execution, ExecutionDefinition, ResultCacheMetadata
812

@@ -64,3 +68,31 @@ def retrieve_result_cache_metadata(self, workspace_id: str, result_id: str) -> R
6468
),
6569
)
6670
return ResultCacheMetadata(result_cache_metadata=result_cache_metadata)
71+
72+
def ai_chat(self, workspace_id: str, question: str) -> ChatResult:
73+
"""
74+
Chat with AI in GoodData workspace.
75+
76+
Args:
77+
workspace_id: workspace identifier
78+
question: question to ask AI
79+
Returns:
80+
str: Chat response
81+
"""
82+
chat_request = ChatRequest(question=question)
83+
response = self._actions_api.ai_chat(workspace_id, chat_request, _check_return_type=False)
84+
return response
85+
86+
def ai_chat_history(self, workspace_id: str, chat_history_interaction_id: int = 0) -> ChatResult:
87+
"""
88+
Get chat history with AI in GoodData workspace.
89+
90+
Args:
91+
workspace_id: workspace identifier
92+
chat_history_interaction_id: collect history starting from this interaction id
93+
Returns:
94+
str: Chat history response
95+
"""
96+
chat_history_request = ChatHistoryRequest(chat_history_interaction_id=chat_history_interaction_id)
97+
response = self._actions_api.ai_chat_history(workspace_id, chat_history_request, _check_return_type=False)
98+
return response

0 commit comments

Comments
 (0)