kobai-sdk 0.2.8rc12__py3-none-any.whl → 0.2.8rc13__py3-none-any.whl
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.
- kobai/ai_query.py +3 -3
- kobai/ai_rag.py +9 -9
- kobai/tenant_client.py +3 -2
- {kobai_sdk-0.2.8rc12.dist-info → kobai_sdk-0.2.8rc13.dist-info}/METADATA +1 -1
- kobai_sdk-0.2.8rc13.dist-info/RECORD +13 -0
- {kobai_sdk-0.2.8rc12.dist-info → kobai_sdk-0.2.8rc13.dist-info}/WHEEL +1 -1
- kobai_sdk-0.2.8rc12.dist-info/RECORD +0 -13
- {kobai_sdk-0.2.8rc12.dist-info → kobai_sdk-0.2.8rc13.dist-info}/LICENSE +0 -0
- {kobai_sdk-0.2.8rc12.dist-info → kobai_sdk-0.2.8rc13.dist-info}/top_level.txt +0 -0
kobai/ai_query.py
CHANGED
|
@@ -73,17 +73,17 @@ def format_docs(docs):
|
|
|
73
73
|
def input_only(inpt):
|
|
74
74
|
return inpt["question"]
|
|
75
75
|
|
|
76
|
-
def followup_question(user_question, question_results, question_name, question_def, embedding_model: Union[SentenceTransformer, Embeddings], chat_model: BaseChatModel, use_inmem_vectors=False):
|
|
76
|
+
def followup_question(user_question, question_results, question_name, question_def, embedding_model: Union[SentenceTransformer, Embeddings], chat_model: BaseChatModel, use_inmem_vectors=False, k=50):
|
|
77
77
|
|
|
78
78
|
row_texts = process_question_results(question_def, question_results)
|
|
79
79
|
question_documents = [Document(page_content=r, metadata={"source": "kobai"}) for r in row_texts]
|
|
80
80
|
|
|
81
81
|
if use_inmem_vectors:
|
|
82
82
|
question_retriever = InMemoryVectorStore.from_documents(question_documents, embedding=embedding_model).as_retriever(
|
|
83
|
-
search_kwargs={"k":
|
|
83
|
+
search_kwargs={"k": k}
|
|
84
84
|
)
|
|
85
85
|
else:
|
|
86
|
-
question_retriever = QuestionRetriever(documents=question_documents)
|
|
86
|
+
question_retriever = QuestionRetriever(documents=question_documents, k=k)
|
|
87
87
|
|
|
88
88
|
output_parser = StrOutputParser()
|
|
89
89
|
|
kobai/ai_rag.py
CHANGED
|
@@ -201,15 +201,15 @@ def encode_to_delta_local(tc: AIContext, st_model: Union[SentenceTransformer, Em
|
|
|
201
201
|
.whenMatchedUpdate(set={"vector": "s.vector"}) \
|
|
202
202
|
.execute()
|
|
203
203
|
|
|
204
|
-
ss.sql(f"""
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
204
|
+
#ss.sql(f"""
|
|
205
|
+
# CREATE FUNCTION IF NOT EXISTS {schema}.cos_sim(a ARRAY<FLOAT>, b ARRAY<FLOAT>)
|
|
206
|
+
# RETURNS FLOAT
|
|
207
|
+
# LANGUAGE PYTHON
|
|
208
|
+
# AS $$
|
|
209
|
+
# import numpy as np
|
|
210
|
+
# return float(np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b)))
|
|
211
|
+
# $$
|
|
212
|
+
# """)
|
|
213
213
|
|
|
214
214
|
|
|
215
215
|
def rag_delta(tc: AIContext, emb_model: Union[SentenceTransformer, Embeddings], chat_model: BaseChatModel, question, k=5, replica_schema=None):
|
kobai/tenant_client.py
CHANGED
|
@@ -82,6 +82,7 @@ class TenantClient:
|
|
|
82
82
|
access = credential.authenticate()
|
|
83
83
|
|
|
84
84
|
oauth_token = access.serialize()
|
|
85
|
+
print(oauth_token)
|
|
85
86
|
user_name = json.loads(access.serialize())["username"]
|
|
86
87
|
|
|
87
88
|
if override_username is not None:
|
|
@@ -478,7 +479,7 @@ class TenantClient:
|
|
|
478
479
|
# AI Functions
|
|
479
480
|
########################################
|
|
480
481
|
|
|
481
|
-
def followup_question(self, user_question, question_id=None, use_inmem_vectors=False):
|
|
482
|
+
def followup_question(self, user_question, question_id=None, use_inmem_vectors=False, k=50):
|
|
482
483
|
"""
|
|
483
484
|
Use LLM to answer question in the context of a Kobai Studio question.
|
|
484
485
|
|
|
@@ -499,7 +500,7 @@ class TenantClient:
|
|
|
499
500
|
question_def = self.get_question(question_id)
|
|
500
501
|
question_name = question_def["description"]
|
|
501
502
|
|
|
502
|
-
return ai_query.followup_question(user_question, question_results, question_name, question_def, self.embedding_model, self.chat_model, use_inmem_vectors=use_inmem_vectors)
|
|
503
|
+
return ai_query.followup_question(user_question, question_results, question_name, question_def, self.embedding_model, self.chat_model, use_inmem_vectors=use_inmem_vectors, k=k)
|
|
503
504
|
|
|
504
505
|
def init_ai_components(self, embedding_model: Union[SentenceTransformer, Embeddings] = None, chat_model: BaseChatModel = None):
|
|
505
506
|
"""
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
kobai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
kobai/ai_query.py,sha256=xZh_OyakU01gIrnzaW4v_TdfzG51nPu0ntXJw1WEnvw,9424
|
|
3
|
+
kobai/ai_rag.py,sha256=Y6R0THtatIixAJvfN1V9NPFTzh8nPdtwBrlLpIFTWJk,14692
|
|
4
|
+
kobai/databricks_client.py,sha256=fyqqMly2Qm0r1AHWsQjkYeNsDdH0G1JSgTkF9KJ55qA,2118
|
|
5
|
+
kobai/demo_tenant_client.py,sha256=wlNc-bdI2wotRXo8ppUOalv4hYdBlek_WzJNARZV-AE,9293
|
|
6
|
+
kobai/spark_client.py,sha256=opM_F-4Ut5Hq5zZjWMuLvUps9sDULvyPNZHXGL8dW1k,776
|
|
7
|
+
kobai/tenant_api.py,sha256=9U6UbxpaAb-kpbuADXx3kbkNKaOzYy0I-GGwbpiCCOk,4212
|
|
8
|
+
kobai/tenant_client.py,sha256=7ckHbn5cciLdIkUTBocZ2O5WRyBNExEuJnIDOjoXOX0,39502
|
|
9
|
+
kobai_sdk-0.2.8rc13.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
10
|
+
kobai_sdk-0.2.8rc13.dist-info/METADATA,sha256=AUtGYR-gSfiDeBMv0s0Rcd3k1v8FV3kHNjEBL9CmnQM,19205
|
|
11
|
+
kobai_sdk-0.2.8rc13.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
12
|
+
kobai_sdk-0.2.8rc13.dist-info/top_level.txt,sha256=ns1El3BrTTHKvoAgU1XtiSaVIudYeCXbEEUVY8HFDZ4,6
|
|
13
|
+
kobai_sdk-0.2.8rc13.dist-info/RECORD,,
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
kobai/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
kobai/ai_query.py,sha256=d0WOPKtQ-bI_zW3-_6guEJX0t55OcxdXIdgXaD-zKK0,9413
|
|
3
|
-
kobai/ai_rag.py,sha256=hc8M7M9azY-tFovsXdrjHJTmemFr8L74X2dy0j-XUoY,14685
|
|
4
|
-
kobai/databricks_client.py,sha256=fyqqMly2Qm0r1AHWsQjkYeNsDdH0G1JSgTkF9KJ55qA,2118
|
|
5
|
-
kobai/demo_tenant_client.py,sha256=wlNc-bdI2wotRXo8ppUOalv4hYdBlek_WzJNARZV-AE,9293
|
|
6
|
-
kobai/spark_client.py,sha256=opM_F-4Ut5Hq5zZjWMuLvUps9sDULvyPNZHXGL8dW1k,776
|
|
7
|
-
kobai/tenant_api.py,sha256=9U6UbxpaAb-kpbuADXx3kbkNKaOzYy0I-GGwbpiCCOk,4212
|
|
8
|
-
kobai/tenant_client.py,sha256=OUHQMmqWlezenkmMJH9p4wOz5CsAntmO25v5vWdepVE,39464
|
|
9
|
-
kobai_sdk-0.2.8rc12.dist-info/LICENSE,sha256=QwcOLU5TJoTeUhuIXzhdCEEDDvorGiC6-3YTOl4TecE,11356
|
|
10
|
-
kobai_sdk-0.2.8rc12.dist-info/METADATA,sha256=vrkBxo0XcZ1uG4lPHs-XfL38rxu-az55yw4NuJ_v5rk,19205
|
|
11
|
-
kobai_sdk-0.2.8rc12.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
12
|
-
kobai_sdk-0.2.8rc12.dist-info/top_level.txt,sha256=ns1El3BrTTHKvoAgU1XtiSaVIudYeCXbEEUVY8HFDZ4,6
|
|
13
|
-
kobai_sdk-0.2.8rc12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|