Skip to content

Commit 1efc008

Browse files
smart_fill
1 parent a97712a commit 1efc008

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

seatable_api/main.py

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ def _dtable_db_linked_records_url(self):
172172
def _dtable_db_insert_rows_url(self):
173173
return self.dtable_db_url + '/api/v1/insert-rows/' + self.dtable_uuid + '/'
174174

175+
def _smart_fill_from_text_url(self):
176+
return self.dtable_db_url + '/api/v1/smart-fill-from-text/'
177+
178+
def _smart_fill_from_column_url(self):
179+
return self.dtable_db_url + '/api/v1/smart-fill-from-column/'
180+
175181
def _get_related_users_url(self):
176182
return '%(server_url)s/api/v2.1/dtables/%(dtable_uuid)s/related-users/' % {
177183
'server_url': self.server_url,
@@ -944,7 +950,6 @@ def add_workflow_task_with_existed_row(self, workflow_token, row_id, initiator=N
944950
response = requests.post(url, data={'row_id': row_id, 'initiator': initiator}, headers=headers)
945951
return parse_response(response)['task']
946952

947-
948953
def big_data_insert_rows(self, table_name, rows_data):
949954
url = self._dtable_db_insert_rows_url()
950955
json_data = {
@@ -954,6 +959,45 @@ def big_data_insert_rows(self, table_name, rows_data):
954959
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
955960
return parse_response(response)
956961

962+
# ----- ----- ----- AI ----- ----- ----- #
963+
964+
def smart_fill_from_text(self, table_name, long_text, columns):
965+
"""
966+
:param table_name: str
967+
:param long_text: str
968+
:param columns: list
969+
:return: list
970+
"""
971+
url = self._smart_fill_from_text_url()
972+
json_data = {
973+
'dtable_uuid': self.dtable_uuid,
974+
'table_name': table_name,
975+
'long_text': long_text,
976+
'columns': columns,
977+
}
978+
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
979+
return parse_response(response)
980+
981+
def smart_fill_from_column(self, table_name, long_text_column_name, columns, start=0, limit=10):
982+
"""
983+
:param table_name: str
984+
:param long_text_column_name: str
985+
:param columns: list
986+
:param start: int
987+
:param limit: int
988+
:return: list
989+
"""
990+
url = self._smart_fill_from_column_url()
991+
json_data = {
992+
'dtable_uuid': self.dtable_uuid,
993+
'table_name': table_name,
994+
'long_text_column_name': long_text_column_name,
995+
'columns': columns,
996+
'start': start,
997+
'limit': limit,
998+
}
999+
response = requests.post(url, json=json_data, headers=self.headers, timeout=self.timeout)
1000+
return parse_response(response)
9571001

9581002

9591003
class Account(object):

0 commit comments

Comments
 (0)