|
3 | 3 |
|
4 | 4 | import logging
|
5 | 5 |
|
| 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 | + |
6 | 10 | from gooddata_sdk.client import GoodDataApiClient
|
7 | 11 | from gooddata_sdk.compute.model.execution import Execution, ExecutionDefinition, ResultCacheMetadata
|
8 | 12 |
|
@@ -64,3 +68,31 @@ def retrieve_result_cache_metadata(self, workspace_id: str, result_id: str) -> R
|
64 | 68 | ),
|
65 | 69 | )
|
66 | 70 | 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