langchain-timbr 2.1.8__tar.gz → 2.1.10__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.
Files changed (58) hide show
  1. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/PKG-INFO +1 -1
  2. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/_version.py +2 -2
  3. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langchain/execute_timbr_query_chain.py +1 -0
  4. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langchain/validate_timbr_sql_chain.py +1 -0
  5. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/timbr_llm_connector.py +1 -1
  6. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/utils/timbr_llm_utils.py +19 -25
  7. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/utils/timbr_utils.py +4 -4
  8. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/.github/dependabot.yml +0 -0
  9. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/.github/pull_request_template.md +0 -0
  10. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/.github/workflows/_codespell.yml +0 -0
  11. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/.github/workflows/_fossa.yml +0 -0
  12. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/.github/workflows/install-dependencies-and-run-tests.yml +0 -0
  13. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/.github/workflows/publish.yml +0 -0
  14. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/.gitignore +0 -0
  15. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/LICENSE +0 -0
  16. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/README.md +0 -0
  17. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/SECURITY.md +0 -0
  18. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/pyproject.toml +0 -0
  19. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/pytest.ini +0 -0
  20. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/requirements.txt +0 -0
  21. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/requirements310.txt +0 -0
  22. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/requirements311.txt +0 -0
  23. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/__init__.py +0 -0
  24. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/config.py +0 -0
  25. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langchain/__init__.py +0 -0
  26. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langchain/generate_answer_chain.py +0 -0
  27. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langchain/generate_timbr_sql_chain.py +0 -0
  28. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langchain/identify_concept_chain.py +0 -0
  29. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langchain/timbr_sql_agent.py +0 -0
  30. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langgraph/__init__.py +0 -0
  31. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langgraph/execute_timbr_query_node.py +0 -0
  32. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langgraph/generate_response_node.py +0 -0
  33. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langgraph/generate_timbr_sql_node.py +0 -0
  34. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langgraph/identify_concept_node.py +0 -0
  35. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/langgraph/validate_timbr_query_node.py +0 -0
  36. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/llm_wrapper/llm_wrapper.py +0 -0
  37. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/llm_wrapper/timbr_llm_wrapper.py +0 -0
  38. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/utils/general.py +0 -0
  39. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/utils/prompt_service.py +0 -0
  40. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/src/langchain_timbr/utils/temperature_supported_models.json +0 -0
  41. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/README.md +0 -0
  42. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/conftest.py +0 -0
  43. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/integration/test_agent_integration.py +0 -0
  44. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/integration/test_azure_databricks_provider.py +0 -0
  45. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/integration/test_azure_openai_model.py +0 -0
  46. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/integration/test_chain_pipeline.py +0 -0
  47. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/integration/test_chain_reasoning.py +0 -0
  48. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/integration/test_jwt_token.py +0 -0
  49. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/integration/test_langchain_chains.py +0 -0
  50. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/integration/test_langgraph_nodes.py +0 -0
  51. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/integration/test_timeout_functionality.py +0 -0
  52. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/standard/conftest.py +0 -0
  53. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/standard/test_chain_documentation.py +0 -0
  54. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/standard/test_connection_validation.py +0 -0
  55. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/standard/test_llm_wrapper_optional_params.py +0 -0
  56. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/standard/test_optional_llm_integration.py +0 -0
  57. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/standard/test_standard_chain_requirements.py +0 -0
  58. {langchain_timbr-2.1.8 → langchain_timbr-2.1.10}/tests/standard/test_unit_tests.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langchain-timbr
3
- Version: 2.1.8
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/
@@ -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.8'
32
- __version_tuple__ = version_tuple = (2, 1, 8)
31
+ __version__ = version = '2.1.10'
32
+ __version_tuple__ = version_tuple = (2, 1, 10)
33
33
 
34
34
  __commit_id__ = commit_id = None
@@ -248,6 +248,7 @@ class ExecuteTimbrQueryChain(Chain):
248
248
  is_sql_valid = True
249
249
  error = None
250
250
  reasoning_status = None
251
+ rows = []
251
252
  usage_metadata = {}
252
253
 
253
254
  if sql and self._should_validate_sql:
@@ -178,6 +178,7 @@ class ValidateTimbrSqlChain(Chain):
178
178
  prompt = inputs["prompt"]
179
179
  schema = self._schema
180
180
  concept = self._concept
181
+ reasoning_status = None
181
182
 
182
183
  is_sql_valid, error = validate_sql(sql, self._get_conn_params())
183
184
  if not is_sql_valid:
@@ -279,7 +279,7 @@ class TimbrLlmConnector:
279
279
  ) -> dict[str, Any]:
280
280
  agent = create_timbr_sql_agent(
281
281
  llm=self._llm,
282
- **self._get_conn_params(),
282
+ conn_params=self._get_conn_params(),
283
283
  concept=None,
284
284
  concepts_list=concepts_list,
285
285
  views_list=views_list,
@@ -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
- concepts = get_concepts(
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 concepts:
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 concept in concepts.values():
291
- concept_name = concept.get('concept')
292
- concept_desc = concept.get('description')
293
- concept_tags = tags.get('concept_tags').get(concept_name) if concept.get('is_view') == 'false' else tags.get('view_tags').get(concept_name)
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 concept_tags:
296
- concept_tags = str(concept_tags).replace('{', '').replace('}', '').replace("'", '')
295
+ if item_tags:
296
+ item_tags = str(item_tags).replace('{', '').replace('}', '').replace("'", '')
297
297
 
298
- concept_verbose = f"`{concept_name}`"
299
- if concept_desc:
300
- concept_verbose += f" (description: {concept_desc})"
301
- if concept_tags:
302
- concept_verbose += f" [tags: {concept_tags}]"
303
- concepts[concept_name]['tags'] = f"- Annotations and constraints: {concept_tags}\n"
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
- combined_list = concepts_list + views_list
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 = concepts_list[0] if concepts_list else views_list[0]
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 concepts.keys():
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 concepts.get(determined_concept_name).get('is_view') == 'true' else 'dtimbr'
355
+ schema = 'vtimbr' if concepts_and_views.get(determined_concept_name).get('is_view') == 'true' else 'dtimbr'
362
356
  return {
363
- "concept_metadata": concepts.get(determined_concept_name) if determined_concept_name else None,
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[str] = '',
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 != '*' and tag_name not in include_tags) or _should_ignore_tag(tag_name):
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] == 'none' or list[0] == 'null'))
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