Skip to content

Commit

Permalink
Merge pull request #871 from gooddata/snapshot-master-2cad3a60-to-rel…
Browse files Browse the repository at this point in the history
…/dev

[bot] Merge master/2cad3a60 into rel/dev
  • Loading branch information
yenkins-admin authored Nov 7, 2024
2 parents 69a8e46 + 2cad3a6 commit 5183042
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions gooddata-sdk/gooddata_sdk/compute/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

import logging

from gooddata_api_client.model.chat_history_request import ChatHistoryRequest
from gooddata_api_client.model.chat_request import ChatRequest
from gooddata_api_client.model.chat_result import ChatResult

from gooddata_sdk.client import GoodDataApiClient
from gooddata_sdk.compute.model.execution import Execution, ExecutionDefinition, ResultCacheMetadata

Expand Down Expand Up @@ -64,3 +68,31 @@ def retrieve_result_cache_metadata(self, workspace_id: str, result_id: str) -> R
),
)
return ResultCacheMetadata(result_cache_metadata=result_cache_metadata)

def ai_chat(self, workspace_id: str, question: str) -> ChatResult:
"""
Chat with AI in GoodData workspace.
Args:
workspace_id: workspace identifier
question: question to ask AI
Returns:
str: Chat response
"""
chat_request = ChatRequest(question=question)
response = self._actions_api.ai_chat(workspace_id, chat_request, _check_return_type=False)
return response

def ai_chat_history(self, workspace_id: str, chat_history_interaction_id: int = 0) -> ChatResult:
"""
Get chat history with AI in GoodData workspace.
Args:
workspace_id: workspace identifier
chat_history_interaction_id: collect history starting from this interaction id
Returns:
str: Chat history response
"""
chat_history_request = ChatHistoryRequest(chat_history_interaction_id=chat_history_interaction_id)
response = self._actions_api.ai_chat_history(workspace_id, chat_history_request, _check_return_type=False)
return response

0 comments on commit 5183042

Please sign in to comment.