langchain-timbr 2.1.13__tar.gz → 2.1.14__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.
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/PKG-INFO +1 -1
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/_version.py +2 -2
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/config.py +1 -1
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langchain/execute_timbr_query_chain.py +1 -1
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langchain/validate_timbr_sql_chain.py +1 -1
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/utils/timbr_llm_utils.py +4 -4
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/utils/timbr_utils.py +23 -10
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_timeout_functionality.py +2 -2
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/.github/dependabot.yml +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/.github/pull_request_template.md +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/.github/workflows/_codespell.yml +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/.github/workflows/_fossa.yml +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/.github/workflows/install-dependencies-and-run-tests.yml +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/.github/workflows/publish.yml +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/.gitignore +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/LICENSE +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/README.md +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/SECURITY.md +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/pyproject.toml +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/pytest.ini +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/requirements.txt +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/requirements310.txt +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/requirements311.txt +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/__init__.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langchain/__init__.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langchain/generate_answer_chain.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langchain/generate_timbr_sql_chain.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langchain/identify_concept_chain.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langchain/timbr_sql_agent.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langgraph/__init__.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langgraph/execute_timbr_query_node.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langgraph/generate_response_node.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langgraph/generate_timbr_sql_node.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langgraph/identify_concept_node.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langgraph/validate_timbr_query_node.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/llm_wrapper/llm_wrapper.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/llm_wrapper/timbr_llm_wrapper.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/timbr_llm_connector.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/utils/general.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/utils/prompt_service.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/utils/temperature_supported_models.json +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/README.md +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/conftest.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_agent_integration.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_azure_databricks_provider.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_azure_openai_model.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_chain_pipeline.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_chain_reasoning.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_jwt_token.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_langchain_chains.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_langgraph_nodes.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/conftest.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_chain_documentation.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_connection_validation.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_llm_wrapper_optional_params.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_optional_llm_integration.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_standard_chain_requirements.py +0 -0
- {langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/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.
|
|
3
|
+
Version: 2.1.14
|
|
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.
|
|
32
|
-
__version_tuple__ = version_tuple = (2, 1,
|
|
31
|
+
__version__ = version = '2.1.14'
|
|
32
|
+
__version_tuple__ = version_tuple = (2, 1, 14)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -19,7 +19,7 @@ llm_model = os.environ.get('LLM_MODEL')
|
|
|
19
19
|
llm_api_key = os.environ.get('LLM_API_KEY')
|
|
20
20
|
llm_temperature = os.environ.get('LLM_TEMPERATURE', 0.0)
|
|
21
21
|
llm_additional_params = os.environ.get('LLM_ADDITIONAL_PARAMS', '')
|
|
22
|
-
llm_timeout = to_integer(os.environ.get('LLM_TIMEOUT',
|
|
22
|
+
llm_timeout = to_integer(os.environ.get('LLM_TIMEOUT', 120)) # Default 120 seconds timeout
|
|
23
23
|
|
|
24
24
|
# Optional for Azure OpenAI with Service Principal authentication
|
|
25
25
|
llm_tenant_id = os.environ.get('LLM_TENANT_ID', None)
|
|
@@ -252,7 +252,7 @@ class ExecuteTimbrQueryChain(Chain):
|
|
|
252
252
|
usage_metadata = {}
|
|
253
253
|
|
|
254
254
|
if sql and self._should_validate_sql:
|
|
255
|
-
is_sql_valid, error = validate_sql(sql, self._get_conn_params())
|
|
255
|
+
is_sql_valid, error, sql = validate_sql(sql, self._get_conn_params())
|
|
256
256
|
|
|
257
257
|
is_infered = False
|
|
258
258
|
iteration = 0
|
|
@@ -180,7 +180,7 @@ class ValidateTimbrSqlChain(Chain):
|
|
|
180
180
|
concept = self._concept
|
|
181
181
|
reasoning_status = None
|
|
182
182
|
|
|
183
|
-
is_sql_valid, error = validate_sql(sql, self._get_conn_params())
|
|
183
|
+
is_sql_valid, error, sql = validate_sql(sql, self._get_conn_params())
|
|
184
184
|
if not is_sql_valid:
|
|
185
185
|
prompt_extension = self._note + '\n' if self._note else ""
|
|
186
186
|
generate_res = generate_sql(
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/utils/timbr_llm_utils.py
RENAMED
|
@@ -52,14 +52,14 @@ def _clean_snowflake_prompt(prompt: Any) -> None:
|
|
|
52
52
|
prompt[1].content = clean_func(prompt[1].content) # User message
|
|
53
53
|
|
|
54
54
|
|
|
55
|
-
def _call_llm_with_timeout(llm: LLM, prompt: Any, timeout: int =
|
|
55
|
+
def _call_llm_with_timeout(llm: LLM, prompt: Any, timeout: int = 120) -> Any:
|
|
56
56
|
"""
|
|
57
57
|
Call LLM with timeout to prevent hanging.
|
|
58
58
|
|
|
59
59
|
Args:
|
|
60
60
|
llm: The LLM instance
|
|
61
61
|
prompt: The prompt to send
|
|
62
|
-
timeout: Timeout in seconds (default:
|
|
62
|
+
timeout: Timeout in seconds (default: 120)
|
|
63
63
|
|
|
64
64
|
Returns:
|
|
65
65
|
LLM response
|
|
@@ -626,7 +626,7 @@ def _generate_sql_with_llm(
|
|
|
626
626
|
result["p_hash"] = encrypt_prompt(prompt)
|
|
627
627
|
|
|
628
628
|
if should_validate_sql:
|
|
629
|
-
result["is_valid"], result["error"] = validate_sql(result["sql"], conn_params)
|
|
629
|
+
result["is_valid"], result["error"], result["sql"] = validate_sql(result["sql"], conn_params)
|
|
630
630
|
|
|
631
631
|
return result
|
|
632
632
|
|
|
@@ -764,7 +764,7 @@ def generate_sql(
|
|
|
764
764
|
break
|
|
765
765
|
|
|
766
766
|
# Step 2: Regenerate SQL with feedback (with validation retries)
|
|
767
|
-
evaluation_note = note + f"\n\nThe previously generated SQL: `{sql_query}` was assessed as '{evaluation.get('assessment')}' because: {evaluation.get('reasoning', '*could not determine cause*')}. Please provide a corrected SQL query that better answers the question: '{question}'."
|
|
767
|
+
evaluation_note = note + f"\n\nThe previously generated SQL: `{sql_query}` was assessed as '{evaluation.get('assessment')}' because: {evaluation.get('reasoning', '*could not determine cause*')}. Please provide a corrected SQL query that better answers the question: '{question}'.\n\nCRITICAL: Return ONLY the SQL query without any explanation or comments."
|
|
768
768
|
|
|
769
769
|
# Increase graph depth for 2nd+ reasoning attempts, up to max of 3
|
|
770
770
|
context_graph_depth = min(3, int(graph_depth) + step) if graph_depth < 3 and step > 0 else graph_depth
|
|
@@ -154,24 +154,37 @@ def get_datasources(conn_params: dict, filter_active: Optional[bool] = False) ->
|
|
|
154
154
|
return res
|
|
155
155
|
|
|
156
156
|
|
|
157
|
-
def
|
|
157
|
+
def _validate(sql: str, conn_params: dict) -> bool:
|
|
158
|
+
explain_sql = f"EXPLAIN {sql}"
|
|
159
|
+
explain_res = run_query(explain_sql, conn_params)
|
|
160
|
+
|
|
161
|
+
query_sql = f"SELECT * FROM ({sql.replace(';', '')}) explainable_query WHERE 1=0"
|
|
162
|
+
query_res = run_query(query_sql, conn_params)
|
|
163
|
+
|
|
164
|
+
return to_boolean(explain_res and explain_res[0].get('PLAN') and query_res is not None)
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def validate_sql(sql: str, conn_params: dict) -> tuple[bool, str, str]:
|
|
158
168
|
if not sql:
|
|
159
169
|
raise Exception("Please provide SQL to validate.")
|
|
160
170
|
|
|
161
|
-
|
|
162
|
-
query_res = None
|
|
171
|
+
is_valid = False
|
|
163
172
|
error = None
|
|
164
173
|
|
|
165
174
|
try:
|
|
166
|
-
|
|
167
|
-
explain_res = run_query(explain_sql, conn_params)
|
|
168
|
-
|
|
169
|
-
query_sql = f"SELECT * FROM ({sql.replace(';', '')}) explainable_query WHERE 1=0"
|
|
170
|
-
query_res = run_query(query_sql, conn_params)
|
|
175
|
+
is_valid = _validate(sql, conn_params)
|
|
171
176
|
except Exception as e:
|
|
172
177
|
error = str(getattr(e, 'doc', e))
|
|
173
|
-
|
|
174
|
-
|
|
178
|
+
if not sql.upper().startswith("SELECT"):
|
|
179
|
+
sql = sql[sql.upper().index("SELECT"):]
|
|
180
|
+
try:
|
|
181
|
+
is_valid = _validate(sql, conn_params)
|
|
182
|
+
if is_valid:
|
|
183
|
+
error = None
|
|
184
|
+
except Exception:
|
|
185
|
+
pass
|
|
186
|
+
|
|
187
|
+
return is_valid, error, sql
|
|
175
188
|
|
|
176
189
|
|
|
177
190
|
def _should_ignore_tag(tag_name: str) -> bool:
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_timeout_functionality.py
RENAMED
|
@@ -13,14 +13,14 @@ from unittest.mock import Mock
|
|
|
13
13
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'langchain_timbr'))
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
def _call_llm_with_timeout(llm, prompt, timeout: int =
|
|
16
|
+
def _call_llm_with_timeout(llm, prompt, timeout: int = 120):
|
|
17
17
|
"""
|
|
18
18
|
Call LLM with timeout to prevent hanging.
|
|
19
19
|
|
|
20
20
|
Args:
|
|
21
21
|
llm: The LLM instance (mock for testing)
|
|
22
22
|
prompt: The prompt to send
|
|
23
|
-
timeout: Timeout in seconds (default:
|
|
23
|
+
timeout: Timeout in seconds (default: 120)
|
|
24
24
|
|
|
25
25
|
Returns:
|
|
26
26
|
LLM response
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/langchain/timbr_sql_agent.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/llm_wrapper/llm_wrapper.py
RENAMED
|
File without changes
|
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/timbr_llm_connector.py
RENAMED
|
File without changes
|
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/src/langchain_timbr/utils/prompt_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_agent_integration.py
RENAMED
|
File without changes
|
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_azure_openai_model.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/integration/test_langchain_chains.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_chain_documentation.py
RENAMED
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_connection_validation.py
RENAMED
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_llm_wrapper_optional_params.py
RENAMED
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_optional_llm_integration.py
RENAMED
|
File without changes
|
{langchain_timbr-2.1.13 → langchain_timbr-2.1.14}/tests/standard/test_standard_chain_requirements.py
RENAMED
|
File without changes
|
|
File without changes
|