langchain-timbr 2.1.9__py3-none-any.whl → 2.1.10__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.
- langchain_timbr/_version.py +2 -2
- langchain_timbr/langchain/execute_timbr_query_chain.py +1 -0
- langchain_timbr/langchain/validate_timbr_sql_chain.py +1 -0
- langchain_timbr/utils/timbr_llm_utils.py +19 -25
- langchain_timbr/utils/timbr_utils.py +4 -4
- {langchain_timbr-2.1.9.dist-info → langchain_timbr-2.1.10.dist-info}/METADATA +1 -1
- {langchain_timbr-2.1.9.dist-info → langchain_timbr-2.1.10.dist-info}/RECORD +9 -9
- {langchain_timbr-2.1.9.dist-info → langchain_timbr-2.1.10.dist-info}/WHEEL +0 -0
- {langchain_timbr-2.1.9.dist-info → langchain_timbr-2.1.10.dist-info}/licenses/LICENSE +0 -0
langchain_timbr/_version.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '2.1.
|
|
32
|
-
__version_tuple__ = version_tuple = (2, 1,
|
|
31
|
+
__version__ = version = '2.1.10'
|
|
32
|
+
__version_tuple__ = version_tuple = (2, 1, 10)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -276,43 +276,37 @@ def determine_concept(
|
|
|
276
276
|
|
|
277
277
|
determine_concept_prompt = get_determine_concept_prompt_template(conn_params)
|
|
278
278
|
tags = get_tags(conn_params=conn_params, include_tags=include_tags)
|
|
279
|
-
|
|
279
|
+
concepts_and_views = get_concepts(
|
|
280
280
|
conn_params=conn_params,
|
|
281
281
|
concepts_list=concepts_list,
|
|
282
282
|
views_list=views_list,
|
|
283
283
|
include_logic_concepts=include_logic_concepts,
|
|
284
284
|
)
|
|
285
285
|
|
|
286
|
-
if not
|
|
286
|
+
if not concepts_and_views:
|
|
287
287
|
raise Exception("No relevant concepts found for the query.")
|
|
288
288
|
|
|
289
289
|
concepts_desc_arr = []
|
|
290
|
-
for
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
for item in concepts_and_views.values():
|
|
291
|
+
item_name = item.get('concept')
|
|
292
|
+
item_desc = item.get('description')
|
|
293
|
+
item_tags = tags.get('concept_tags').get(item_name) if item.get('is_view') == 'false' else tags.get('view_tags').get(item_name)
|
|
294
294
|
|
|
295
|
-
if
|
|
296
|
-
|
|
295
|
+
if item_tags:
|
|
296
|
+
item_tags = str(item_tags).replace('{', '').replace('}', '').replace("'", '')
|
|
297
297
|
|
|
298
|
-
concept_verbose = f"`{
|
|
299
|
-
if
|
|
300
|
-
concept_verbose += f" (description: {
|
|
301
|
-
if
|
|
302
|
-
concept_verbose += f" [tags: {
|
|
303
|
-
|
|
298
|
+
concept_verbose = f"`{item_name}`"
|
|
299
|
+
if item_desc:
|
|
300
|
+
concept_verbose += f" (description: {item_desc})"
|
|
301
|
+
if item_tags:
|
|
302
|
+
concept_verbose += f" [tags: {item_tags}]"
|
|
303
|
+
concepts_and_views[item_name]['tags'] = f"- Annotations and constraints: {item_tags}\n"
|
|
304
304
|
|
|
305
305
|
concepts_desc_arr.append(concept_verbose)
|
|
306
306
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if len(combined_list) == 1 and not (combined_list[0].lower() == 'none' or combined_list[0].lower() == 'null'):
|
|
307
|
+
if len(concepts_and_views) == 1: # and not (concepts[0].lower() == 'none' or concepts[0].lower() == 'null'):
|
|
310
308
|
# If only one concept is provided, return it directly
|
|
311
|
-
determined_concept_name =
|
|
312
|
-
|
|
313
|
-
if determined_concept_name not in concepts:
|
|
314
|
-
raise Exception(f"'{determined_concept_name}' was not found in the ontology.")
|
|
315
|
-
|
|
309
|
+
determined_concept_name = list(concepts_and_views.keys())[0]
|
|
316
310
|
else:
|
|
317
311
|
# Use LLM to determine the concept based on the question
|
|
318
312
|
iteration = 0
|
|
@@ -347,7 +341,7 @@ def determine_concept(
|
|
|
347
341
|
|
|
348
342
|
response_text = _get_response_text(response)
|
|
349
343
|
candidate = response_text.strip()
|
|
350
|
-
if should_validate and candidate not in
|
|
344
|
+
if should_validate and candidate not in concepts_and_views.keys():
|
|
351
345
|
error = f"Concept '{determined_concept_name}' not found in the list of concepts."
|
|
352
346
|
continue
|
|
353
347
|
|
|
@@ -358,9 +352,9 @@ def determine_concept(
|
|
|
358
352
|
raise Exception(f"Failed to determine concept: {error}")
|
|
359
353
|
|
|
360
354
|
if determined_concept_name:
|
|
361
|
-
schema = 'vtimbr' if
|
|
355
|
+
schema = 'vtimbr' if concepts_and_views.get(determined_concept_name).get('is_view') == 'true' else 'dtimbr'
|
|
362
356
|
return {
|
|
363
|
-
"concept_metadata":
|
|
357
|
+
"concept_metadata": concepts_and_views.get(determined_concept_name) if determined_concept_name else None,
|
|
364
358
|
"concept": determined_concept_name,
|
|
365
359
|
"schema": schema,
|
|
366
360
|
"usage_metadata": usage_metadata,
|
|
@@ -192,7 +192,7 @@ def _should_ignore_tag(tag_name: str) -> bool:
|
|
|
192
192
|
def _prepare_tags_dict(
|
|
193
193
|
type: Optional[str] = 'concept',
|
|
194
194
|
tags_list: Optional[list] = [],
|
|
195
|
-
include_tags: Optional[
|
|
195
|
+
include_tags: Optional[list] = [],
|
|
196
196
|
) -> dict:
|
|
197
197
|
tags_dict = {}
|
|
198
198
|
if not include_tags:
|
|
@@ -206,7 +206,7 @@ def _prepare_tags_dict(
|
|
|
206
206
|
tag_name = tag.get('tag_name')
|
|
207
207
|
|
|
208
208
|
# Check if the tag is included
|
|
209
|
-
if (include_tags
|
|
209
|
+
if (not _should_select_all(include_tags) and tag_name not in include_tags) or _should_ignore_tag(tag_name):
|
|
210
210
|
continue
|
|
211
211
|
|
|
212
212
|
key = tag.get('target_name')
|
|
@@ -242,11 +242,11 @@ def get_tags(conn_params: dict, include_tags: Optional[Any] = None) -> dict:
|
|
|
242
242
|
|
|
243
243
|
|
|
244
244
|
def _should_ignore_list(list: list) -> bool:
|
|
245
|
-
return bool(list and len(list) == 1 and (list[0]
|
|
245
|
+
return bool(list and len(list) == 1 and (list[0].lower() in ['none', 'null']))
|
|
246
246
|
|
|
247
247
|
|
|
248
248
|
def _should_select_all(list: list) -> bool:
|
|
249
|
-
return list and len(list) == 1 and list[0] == '*'
|
|
249
|
+
return bool(list and len(list) == 1 and list[0] == '*')
|
|
250
250
|
|
|
251
251
|
|
|
252
252
|
@cache_with_version_check
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langchain-timbr
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.10
|
|
4
4
|
Summary: LangChain & LangGraph extensions that parse LLM prompts into Timbr semantic SQL and execute them.
|
|
5
5
|
Project-URL: Homepage, https://github.com/WPSemantix/langchain-timbr
|
|
6
6
|
Project-URL: Documentation, https://docs.timbr.ai/doc/docs/integration/langchain-sdk/
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
langchain_timbr/__init__.py,sha256=qNyk3Rt-8oWr_OGuU_E-6siNZXuCnvVEkj65EIuVbbQ,824
|
|
2
|
-
langchain_timbr/_version.py,sha256=
|
|
2
|
+
langchain_timbr/_version.py,sha256=17o5HAWEs2V5c2y1ZXOar4fpD2AlgrefncES8TLLxVk,706
|
|
3
3
|
langchain_timbr/config.py,sha256=b-mLIrswgSez282ItJntb5mCa8poOe7kqXG1W_jGxvw,1971
|
|
4
4
|
langchain_timbr/timbr_llm_connector.py,sha256=Y3nzWoocI5txvPGPAxwFsJde9k9l2J9ioB54MYRLrEQ,13288
|
|
5
5
|
langchain_timbr/langchain/__init__.py,sha256=ejcsZKP9PK0j4WrrCCcvBXpDpP-TeRiVb21OIUJqix8,580
|
|
6
|
-
langchain_timbr/langchain/execute_timbr_query_chain.py,sha256=
|
|
6
|
+
langchain_timbr/langchain/execute_timbr_query_chain.py,sha256=Ht6B63IEAESgfFMe3b6Q08VJ-pegxSS6A8kwE-U-0cY,16401
|
|
7
7
|
langchain_timbr/langchain/generate_answer_chain.py,sha256=nteA4QZp9CAOskTBl_CokwaMlqnR2g2GvKz2mLs9WVY,4871
|
|
8
8
|
langchain_timbr/langchain/generate_timbr_sql_chain.py,sha256=PE01noOzdkhLE5nxklSwTT_aQY3vjdKgZeXrwN5aYQ4,9853
|
|
9
9
|
langchain_timbr/langchain/identify_concept_chain.py,sha256=kuzg0jJQpFGIiaxtNhdQ5K4HXveLVwONFNsoipPCteE,7169
|
|
10
10
|
langchain_timbr/langchain/timbr_sql_agent.py,sha256=AaBNJz3qKwJZVd-mvEmlVp6REE8QEEwlOvtkkjdBxxc,20938
|
|
11
|
-
langchain_timbr/langchain/validate_timbr_sql_chain.py,sha256=
|
|
11
|
+
langchain_timbr/langchain/validate_timbr_sql_chain.py,sha256=ndFWSdb_LNI-BQg254hfTlzcZXOuM1opHHLdC0SALDo,10317
|
|
12
12
|
langchain_timbr/langgraph/__init__.py,sha256=mKBFd0x01jWpRujUWe-suX3FFhenPoDxrvzs8I0mum0,457
|
|
13
13
|
langchain_timbr/langgraph/execute_timbr_query_node.py,sha256=FUsDHQAEMKYETi3lxNuF_PU8yvq9z5PYPyRFsHjLPbs,6057
|
|
14
14
|
langchain_timbr/langgraph/generate_response_node.py,sha256=opwscNEXabaSyCFLbzGQFkDFEymJurhNU9aAtm1rnOk,2375
|
|
@@ -20,9 +20,9 @@ langchain_timbr/llm_wrapper/timbr_llm_wrapper.py,sha256=sDqDOz0qu8b4WWlagjNceswM
|
|
|
20
20
|
langchain_timbr/utils/general.py,sha256=KkehHvIj8GoQ_0KVXLcUVeaYaTtkuzgXmYYx2TXJhI4,10253
|
|
21
21
|
langchain_timbr/utils/prompt_service.py,sha256=QVmfA9cHO2IPVsKG8V5cuMm2gPfvRq2VzLcx04sqT88,12197
|
|
22
22
|
langchain_timbr/utils/temperature_supported_models.json,sha256=d3UmBUpG38zDjjB42IoGpHTUaf0pHMBRSPY99ao1a3g,1832
|
|
23
|
-
langchain_timbr/utils/timbr_llm_utils.py,sha256=
|
|
24
|
-
langchain_timbr/utils/timbr_utils.py,sha256=
|
|
25
|
-
langchain_timbr-2.1.
|
|
26
|
-
langchain_timbr-2.1.
|
|
27
|
-
langchain_timbr-2.1.
|
|
28
|
-
langchain_timbr-2.1.
|
|
23
|
+
langchain_timbr/utils/timbr_llm_utils.py,sha256=AlEvwncFFLarLAea4wteyJxxMHTNweHKL4L_M8KYGLw,34494
|
|
24
|
+
langchain_timbr/utils/timbr_utils.py,sha256=0LqA7ain_cXse_KH1Zgg0zox-JAwAlPK8gNK7rNgm8s,18885
|
|
25
|
+
langchain_timbr-2.1.10.dist-info/METADATA,sha256=nIJ6Gigjh9Bdxlo1f4QqRN9HD0rbc07HgFadW79EfWY,10725
|
|
26
|
+
langchain_timbr-2.1.10.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
27
|
+
langchain_timbr-2.1.10.dist-info/licenses/LICENSE,sha256=0ITGFk2alkC7-e--bRGtuzDrv62USIiVyV2Crf3_L_0,1065
|
|
28
|
+
langchain_timbr-2.1.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|