forked from gooddata/gooddata-python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai_chat.py
More file actions
36 lines (24 loc) · 918 Bytes
/
ai_chat.py
File metadata and controls
36 lines (24 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# (C) 2024 GoodData Corporation
import os
import sys
import pytest
# Add the root directory to sys.path
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from env import HOST, TOKEN, WORKSPACE_ID
from gooddata_sdk import GoodDataSdk
@pytest.fixture
def test_config():
return {"host": HOST, "token": TOKEN, "workspace_id": WORKSPACE_ID}
questions = [
"What is the number of Accounts?",
"What is the total of Amount?",
]
@pytest.mark.parametrize("question", questions)
def test_ask_ai(test_config, question):
sdk = GoodDataSdk.create(host_=test_config["host"], token_=test_config["token"])
workspace_id = test_config["workspace_id"]
chat_ai_res = sdk.compute.ai_chat(workspace_id, question=question)
print(f"Chat AI response: {chat_ai_res}")
assert chat_ai_res is not None, "Response should not be None"
if __name__ == "__main__":
pytest.main()