|
11 | 11 |
|
12 | 12 | from gptscript.confirm import AuthResponse
|
13 | 13 | from gptscript.credentials import Credential
|
| 14 | +from gptscript.datasets import DatasetElement |
14 | 15 | from gptscript.exec_utils import get_env
|
15 | 16 | from gptscript.frame import RunEventType, CallFrame, RunFrame, RunState, PromptFrame
|
16 | 17 | from gptscript.gptscript import GPTScript
|
@@ -775,17 +776,35 @@ async def test_datasets(gptscript):
|
775 | 776 | assert element_meta.name == "element1", "Expected element name to match"
|
776 | 777 | assert element_meta.description == "element1 description", "Expected element description to match"
|
777 | 778 |
|
778 |
| - # Get the element |
779 |
| - element = await gptscript.get_dataset_element(workspace_id, dataset.id, "element1") |
780 |
| - assert element.name == "element1", "Expected element name to match" |
781 |
| - assert element.contents == "element1 contents", "Expected element contents to match" |
782 |
| - assert element.description == "element1 description", "Expected element description to match" |
| 779 | + # Add two more elements |
| 780 | + await gptscript.add_dataset_elements(workspace_id, dataset.id, [ |
| 781 | + DatasetElement(name="element2", contents="element2 contents", description="element2 description"), |
| 782 | + DatasetElement(name="element3", contents="element3 contents", description="element3 description"), |
| 783 | + ]) |
| 784 | + |
| 785 | + # Get the elements |
| 786 | + e1 = await gptscript.get_dataset_element(workspace_id, dataset.id, "element1") |
| 787 | + assert e1.name == "element1", "Expected element name to match" |
| 788 | + assert e1.contents == "element1 contents", "Expected element contents to match" |
| 789 | + assert e1.description == "element1 description", "Expected element description to match" |
| 790 | + e2 = await gptscript.get_dataset_element(workspace_id, dataset.id, "element2") |
| 791 | + assert e2.name == "element2", "Expected element name to match" |
| 792 | + assert e2.contents == "element2 contents", "Expected element contents to match" |
| 793 | + assert e2.description == "element2 description", "Expected element description to match" |
| 794 | + e3 = await gptscript.get_dataset_element(workspace_id, dataset.id, "element3") |
| 795 | + assert e3.name == "element3", "Expected element name to match" |
| 796 | + assert e3.contents == "element3 contents", "Expected element contents to match" |
| 797 | + assert e3.description == "element3 description", "Expected element description to match" |
783 | 798 |
|
784 | 799 | # List elements in the dataset
|
785 | 800 | elements = await gptscript.list_dataset_elements(workspace_id, dataset.id)
|
786 |
| - assert len(elements) == 1, "Expected one element in the dataset" |
| 801 | + assert len(elements) == 3, "Expected one element in the dataset" |
787 | 802 | assert elements[0].name == "element1", "Expected element name to match"
|
788 | 803 | assert elements[0].description == "element1 description", "Expected element description to match"
|
| 804 | + assert elements[1].name == "element2", "Expected element name to match" |
| 805 | + assert elements[1].description == "element2 description", "Expected element description to match" |
| 806 | + assert elements[2].name == "element3", "Expected element name to match" |
| 807 | + assert elements[2].description == "element3 description", "Expected element description to match" |
789 | 808 |
|
790 | 809 | # List datasets
|
791 | 810 | datasets = await gptscript.list_datasets(workspace_id)
|
|
0 commit comments