kobai-sdk 0.2.8rc5__tar.gz → 0.2.8rc7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of kobai-sdk might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: kobai-sdk
3
- Version: 0.2.8rc5
3
+ Version: 0.2.8rc7
4
4
  Summary: A package that enables interaction with a Kobai tenant.
5
5
  Author-email: Ryan Oattes <ryan@kobai.io>
6
6
  License: Apache License
@@ -25,28 +25,28 @@ class AIContext:
25
25
 
26
26
  def ai_run_question_remote(tc: AIContext, question_id, dynamic_filters: dict = None):
27
27
 
28
- """
29
- Returns JSON formatted result of Kobai question.
28
+ """
29
+ Returns JSON formatted result of Kobai question.
30
30
 
31
- Parameters:
32
- question_id (int): Numeric identifier of Kobai question.
33
- """
31
+ Parameters:
32
+ question_id (int): Numeric identifier of Kobai question.
33
+ """
34
34
 
35
- uri = '/data-svcs/api/query/' + str(question_id) + '/execute?' #'/data-svcs/api/query/4518/solution/9/execute/tabular?'
35
+ uri = '/data-svcs/api/query/' + str(question_id) + '/execute?' #'/data-svcs/api/query/4518/solution/9/execute/tabular?'
36
36
 
37
- queryParams = {'jsontype': 'tableau'}
37
+ queryParams = {'jsontype': 'tableau'}
38
38
 
39
- if bool(dynamic_filters):
40
- queryParams.update(dynamic_filters)
39
+ if bool(dynamic_filters):
40
+ queryParams.update(dynamic_filters)
41
41
 
42
- uri += urllib.parse.urlencode(queryParams)
42
+ uri += urllib.parse.urlencode(queryParams)
43
43
 
44
- json={
45
- 'simulations': {'concepts': {}, 'data': None}
46
- }
47
- response = tc.api_client._TenantAPI__run_post(uri, json)
44
+ json={
45
+ 'simulations': {'concepts': {}, 'data': None}
46
+ }
47
+ response = tc.api_client._TenantAPI__run_post(uri, json)
48
48
 
49
- return response.json()
49
+ return response.json()
50
50
 
51
51
  def generate_sentences(tc: AIContext, replica_schema=None, concept_white_list=None, use_questions=False):
52
52
  """
@@ -59,9 +59,6 @@ def generate_sentences(tc: AIContext, replica_schema=None, concept_white_list=No
59
59
  use_questions (bool) OPTIONAL: Extract facts from published Kobai questions.
60
60
  """
61
61
 
62
- #if tc.spark_client is None:
63
- # return None
64
-
65
62
  ss = tc.spark_session
66
63
 
67
64
  print("Getting Tenant Config")
@@ -152,9 +149,6 @@ def encode_to_delta_local(tc: AIContext, st_model: SentenceTransformer, replica_
152
149
  replica_schema (str) OPTIONAL: An alternate schema (catalog.database) to create the Delta table. Useful when the base Kobai schema is not on a Unity Catalog.
153
150
  """
154
151
 
155
- #if tc.spark_client is None:
156
- # return None
157
-
158
152
  ss = tc.spark_session
159
153
 
160
154
  schema = tc.schema
@@ -224,10 +218,6 @@ def rag_delta(tc: AIContext, emb_model: Union[SentenceTransformer, Embeddings],
224
218
  if replica_schema is not None:
225
219
  schema = replica_schema
226
220
 
227
- #if tc.spark_client is None:
228
- # print("Instantiate Spark Client First")
229
- # return None
230
-
231
221
  ss = tc.spark_session
232
222
 
233
223
  if isinstance(emb_model, SentenceTransformer):
@@ -2,7 +2,6 @@ import base64
2
2
  import json
3
3
  import urllib
4
4
  import urllib.parse
5
- import requests
6
5
 
7
6
  from azure.identity import DeviceCodeCredential
8
7
  from pyspark.sql import SparkSession
@@ -65,7 +64,7 @@ class TenantClient:
65
64
  # MS Entra Auth
66
65
  ########################################
67
66
 
68
- def authenticate(self, client_id: str, tenant_id: str):
67
+ def authenticate(self, client_id: str, tenant_id: str, run_ai_init: bool = True):
69
68
 
70
69
  """
71
70
  Authenticate the TenantClient with the Kobai instance. Returns nothing, but stores bearer token in client.
@@ -110,11 +109,12 @@ class TenantClient:
110
109
 
111
110
  self.__api_init_session()
112
111
  self.__set_tenant_solutionid()
113
- self.init_ai_components()
112
+ if run_ai_init:
113
+ self.init_ai_components()
114
114
 
115
115
  print("Authentication Successful.")
116
116
 
117
- def authenticate_browser_token(self, access_token):
117
+ def authenticate_browser_token(self, access_token, run_ai_init: bool = True):
118
118
 
119
119
  """
120
120
  Authenticate the TenantClient with the Kobai instance. Returns nothing, but stores bearer token in client.
@@ -128,7 +128,8 @@ class TenantClient:
128
128
 
129
129
  self.__api_init_session()
130
130
  self.__set_tenant_solutionid()
131
- self.init_ai_components()
131
+ if run_ai_init:
132
+ self.init_ai_components()
132
133
 
133
134
 
134
135
  print("Authentication Successful.")
@@ -468,7 +469,7 @@ class TenantClient:
468
469
  k (int) OPTIONAL: The number of RAG documents to retrieve.
469
470
  replica_schema (str) OPTIONAL: An alternate schema (catalog.database) to create the Delta table. Useful when the base Kobai schema is not on a Unity Catalog.
470
471
  """
471
- ai_rag.rag_delta(self.get_ai_context(), emb_model=emb_model, chat_model=chat_model, question=question, k=k, replica_schema=replica_schema)
472
+ return ai_rag.rag_delta(self.get_ai_context(), emb_model=emb_model, chat_model=chat_model, question=question, k=k, replica_schema=replica_schema)
472
473
 
473
474
  ########################################
474
475
  # AI Functions
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: kobai-sdk
3
- Version: 0.2.8rc5
3
+ Version: 0.2.8rc7
4
4
  Summary: A package that enables interaction with a Kobai tenant.
5
5
  Author-email: Ryan Oattes <ryan@kobai.io>
6
6
  License: Apache License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "kobai-sdk"
7
- version = "0.2.8rc5"
7
+ version = "0.2.8rc7"
8
8
  description = "A package that enables interaction with a Kobai tenant."
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Ryan Oattes", email = "ryan@kobai.io" }]
File without changes
File without changes
File without changes
File without changes