langchain-timbr 1.5.3__tar.gz → 1.5.4__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-1.5.3 → langchain_timbr-1.5.4}/PKG-INFO +1 -1
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/_version.py +2 -2
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/utils/prompt_service.py +42 -61
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/utils/timbr_llm_utils.py +4 -4
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/.github/dependabot.yml +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/.github/pull_request_template.md +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/.github/workflows/_codespell.yml +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/.github/workflows/_fossa.yml +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/.github/workflows/install-dependencies-and-run-tests.yml +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/.github/workflows/publish.yml +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/.gitignore +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/LICENSE +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/README.md +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/pyproject.toml +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/pytest.ini +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/requirements.txt +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/__init__.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/config.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langchain/__init__.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langchain/execute_timbr_query_chain.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langchain/generate_answer_chain.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langchain/generate_timbr_sql_chain.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langchain/identify_concept_chain.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langchain/timbr_sql_agent.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langchain/validate_timbr_sql_chain.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langgraph/__init__.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langgraph/execute_timbr_query_node.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langgraph/generate_response_node.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langgraph/generate_timbr_sql_node.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langgraph/identify_concept_node.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/langgraph/validate_timbr_query_node.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/llm_wrapper/llm_wrapper.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/llm_wrapper/timbr_llm_wrapper.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/timbr_llm_connector.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/utils/general.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/utils/temperature_supported_models.json +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/utils/timbr_utils.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/README.md +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/conftest.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_agent_integration.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_azure_databricks_provider.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_azure_openai_model.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_chain_pipeline.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_jwt_token.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_langchain_chains.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_langgraph_nodes.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_timeout_functionality.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/standard/conftest.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/standard/test_chain_documentation.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/standard/test_standard_chain_requirements.py +0 -0
- {langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/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: 1.5.
|
|
3
|
+
Version: 1.5.4
|
|
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 = '1.5.
|
|
32
|
-
__version_tuple__ = version_tuple = (1, 5,
|
|
31
|
+
__version__ = version = '1.5.4'
|
|
32
|
+
__version_tuple__ = version_tuple = (1, 5, 4)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
import requests
|
|
2
2
|
from typing import Dict, Any, Optional, List, Union
|
|
3
|
-
from langchain.schema import SystemMessage, HumanMessage
|
|
4
3
|
from langchain.prompts.chat import ChatPromptTemplate
|
|
5
4
|
from langchain.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate
|
|
6
5
|
import json
|
|
7
6
|
import logging
|
|
8
|
-
|
|
9
|
-
from ..config import url, token as default_token, is_jwt, jwt_tenant_id as default_jwt_tenant_id, llm_timeout
|
|
7
|
+
from ..config import url as default_url, token as default_token, is_jwt, jwt_tenant_id as default_jwt_tenant_id, llm_timeout
|
|
10
8
|
|
|
11
9
|
logger = logging.getLogger(__name__)
|
|
12
10
|
|
|
13
11
|
# Global template cache shared across all PromptService instances
|
|
14
|
-
_global_template_cache = {}
|
|
12
|
+
_global_template_cache: dict[Any, Any] = {}
|
|
15
13
|
|
|
16
14
|
class PromptService:
|
|
17
15
|
def __init__(
|
|
18
16
|
self,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
is_jwt: Optional[bool] = is_jwt,
|
|
22
|
-
jwt_tenant_id: Optional[str] = default_jwt_tenant_id,
|
|
23
|
-
timeout: Optional[int] = llm_timeout,
|
|
17
|
+
conn_params: Optional[Dict[str, Any]] = None,
|
|
18
|
+
**kwargs
|
|
24
19
|
):
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
"""
|
|
21
|
+
Initialize PromptService with connection parameters.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
conn_params: Dictionary containing connection parameters
|
|
25
|
+
**kwargs: Additional parameters for backward compatibility
|
|
26
|
+
"""
|
|
27
|
+
# Extract relevant parameters from conn_params or use defaults
|
|
28
|
+
if conn_params:
|
|
29
|
+
url_value = conn_params.get('url') or default_url
|
|
30
|
+
self.base_url = url_value.rstrip('/') if url_value else ''
|
|
31
|
+
self.token = conn_params.get('token') or default_token
|
|
32
|
+
self.is_jwt = conn_params.get('is_jwt', is_jwt)
|
|
33
|
+
self.jwt_tenant_id = conn_params.get('jwt_tenant_id') or default_jwt_tenant_id
|
|
34
|
+
self.timeout = conn_params.get('timeout') or llm_timeout
|
|
35
|
+
else:
|
|
36
|
+
# Fallback to kwargs for backward compatibility
|
|
37
|
+
url_value = kwargs.get('url') or default_url
|
|
38
|
+
self.base_url = url_value.rstrip('/') if url_value else ''
|
|
39
|
+
self.token = str(kwargs.get('token') or default_token)
|
|
40
|
+
self.is_jwt = kwargs.get('is_jwt', is_jwt)
|
|
41
|
+
self.jwt_tenant_id = kwargs.get('jwt_tenant_id') or default_jwt_tenant_id
|
|
42
|
+
self.timeout = kwargs.get('timeout') or llm_timeout
|
|
30
43
|
|
|
31
44
|
|
|
32
45
|
def _get_headers(self) -> Dict[str, str]:
|
|
@@ -220,99 +233,67 @@ class PromptTemplateWrapper:
|
|
|
220
233
|
|
|
221
234
|
# Individual prompt template getter functions
|
|
222
235
|
def get_determine_concept_prompt_template(
|
|
223
|
-
|
|
224
|
-
is_jwt: Optional[bool] = None,
|
|
225
|
-
jwt_tenant_id: Optional[str] = None
|
|
236
|
+
conn_params: Optional[dict] = None
|
|
226
237
|
) -> PromptTemplateWrapper:
|
|
227
238
|
"""
|
|
228
239
|
Get determine concept prompt template wrapper
|
|
229
240
|
|
|
230
241
|
Args:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
jwt_tenant_id: JWT tenant ID
|
|
234
|
-
|
|
242
|
+
conn_params: Connection parameters including url, token, is_jwt, and jwt_tenant_id
|
|
243
|
+
|
|
235
244
|
Returns:
|
|
236
245
|
PromptTemplateWrapper for determine concept
|
|
237
246
|
"""
|
|
238
|
-
prompt_service = PromptService(
|
|
239
|
-
token=token,
|
|
240
|
-
is_jwt=is_jwt,
|
|
241
|
-
jwt_tenant_id=jwt_tenant_id
|
|
242
|
-
)
|
|
247
|
+
prompt_service = PromptService(conn_params=conn_params)
|
|
243
248
|
return PromptTemplateWrapper(prompt_service, "get_identify_concept_template")
|
|
244
249
|
|
|
245
250
|
|
|
246
251
|
def get_generate_sql_prompt_template(
|
|
247
|
-
|
|
248
|
-
is_jwt: Optional[bool] = None,
|
|
249
|
-
jwt_tenant_id: Optional[str] = None
|
|
252
|
+
conn_params: Optional[dict] = None
|
|
250
253
|
) -> PromptTemplateWrapper:
|
|
251
254
|
"""
|
|
252
255
|
Get generate SQL prompt template wrapper
|
|
253
256
|
|
|
254
257
|
Args:
|
|
255
|
-
|
|
256
|
-
is_jwt: Whether the token is a JWT
|
|
257
|
-
jwt_tenant_id: JWT tenant ID
|
|
258
|
+
conn_params: Connection parameters including url, token, is_jwt, and jwt_tenant_id
|
|
258
259
|
|
|
259
260
|
Returns:
|
|
260
261
|
PromptTemplateWrapper for generate SQL
|
|
261
262
|
"""
|
|
262
|
-
prompt_service = PromptService(
|
|
263
|
-
token=token,
|
|
264
|
-
is_jwt=is_jwt,
|
|
265
|
-
jwt_tenant_id=jwt_tenant_id
|
|
266
|
-
)
|
|
263
|
+
prompt_service = PromptService(conn_params=conn_params)
|
|
267
264
|
return PromptTemplateWrapper(prompt_service, "get_generate_sql_template")
|
|
268
265
|
|
|
269
266
|
|
|
270
267
|
def get_qa_prompt_template(
|
|
271
|
-
|
|
272
|
-
is_jwt: Optional[bool] = None,
|
|
273
|
-
jwt_tenant_id: Optional[str] = None
|
|
268
|
+
conn_params: Optional[dict] = None
|
|
274
269
|
) -> PromptTemplateWrapper:
|
|
275
270
|
"""
|
|
276
271
|
Get QA prompt template wrapper
|
|
277
272
|
|
|
278
273
|
Args:
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
jwt_tenant_id: JWT tenant ID
|
|
282
|
-
|
|
274
|
+
conn_params: Connection parameters including url, token, is_jwt, and jwt_tenant_id
|
|
275
|
+
|
|
283
276
|
Returns:
|
|
284
277
|
PromptTemplateWrapper for QA
|
|
285
278
|
"""
|
|
286
|
-
prompt_service = PromptService(
|
|
287
|
-
token=token,
|
|
288
|
-
is_jwt=is_jwt,
|
|
289
|
-
jwt_tenant_id=jwt_tenant_id
|
|
290
|
-
)
|
|
279
|
+
prompt_service = PromptService(conn_params=conn_params)
|
|
291
280
|
return PromptTemplateWrapper(prompt_service, "get_generate_answer_template")
|
|
292
281
|
|
|
293
282
|
|
|
294
283
|
# Global prompt service instance (updated signature)
|
|
295
284
|
def get_prompt_service(
|
|
296
|
-
|
|
297
|
-
is_jwt: bool = None,
|
|
298
|
-
jwt_tenant_id: str = None
|
|
285
|
+
conn_params: Optional[dict] = None
|
|
299
286
|
) -> PromptService:
|
|
300
287
|
"""
|
|
301
288
|
Get or create a prompt service instance
|
|
302
289
|
|
|
303
290
|
Args:
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
jwt_tenant_id: JWT tenant ID
|
|
307
|
-
|
|
291
|
+
conn_params: Connection parameters including url, token, is_jwt, and jwt_tenant_id
|
|
292
|
+
|
|
308
293
|
Returns:
|
|
309
294
|
PromptService instance
|
|
310
295
|
"""
|
|
311
|
-
return PromptService(
|
|
312
|
-
token=token,
|
|
313
|
-
is_jwt=is_jwt,
|
|
314
|
-
jwt_tenant_id=jwt_tenant_id
|
|
315
|
-
)
|
|
296
|
+
return PromptService(conn_params=conn_params)
|
|
316
297
|
|
|
317
298
|
|
|
318
299
|
# Global cache management functions
|
{langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/utils/timbr_llm_utils.py
RENAMED
|
@@ -212,7 +212,7 @@ def determine_concept(
|
|
|
212
212
|
note: Optional[str] = '',
|
|
213
213
|
debug: Optional[bool] = False,
|
|
214
214
|
timeout: Optional[int] = None,
|
|
215
|
-
) -> dict[str,
|
|
215
|
+
) -> dict[str, Any]:
|
|
216
216
|
usage_metadata = {}
|
|
217
217
|
determined_concept_name = None
|
|
218
218
|
schema = 'dtimbr'
|
|
@@ -221,7 +221,7 @@ def determine_concept(
|
|
|
221
221
|
if timeout is None:
|
|
222
222
|
timeout = llm_timeout
|
|
223
223
|
|
|
224
|
-
determine_concept_prompt = get_determine_concept_prompt_template(conn_params
|
|
224
|
+
determine_concept_prompt = get_determine_concept_prompt_template(conn_params)
|
|
225
225
|
tags = get_tags(conn_params=conn_params, include_tags=include_tags)
|
|
226
226
|
concepts = get_concepts(
|
|
227
227
|
conn_params=conn_params,
|
|
@@ -418,7 +418,7 @@ def generate_sql(
|
|
|
418
418
|
if timeout is None:
|
|
419
419
|
timeout = llm_timeout
|
|
420
420
|
|
|
421
|
-
generate_sql_prompt = get_generate_sql_prompt_template(conn_params
|
|
421
|
+
generate_sql_prompt = get_generate_sql_prompt_template(conn_params)
|
|
422
422
|
|
|
423
423
|
if concept and concept != "" and (schema is None or schema != "vtimbr"):
|
|
424
424
|
concepts_list = [concept]
|
|
@@ -550,7 +550,7 @@ def answer_question(
|
|
|
550
550
|
if timeout is None:
|
|
551
551
|
timeout = llm_timeout
|
|
552
552
|
|
|
553
|
-
qa_prompt = get_qa_prompt_template(conn_params
|
|
553
|
+
qa_prompt = get_qa_prompt_template(conn_params)
|
|
554
554
|
|
|
555
555
|
prompt = qa_prompt.format_messages(
|
|
556
556
|
question=question,
|
|
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-1.5.3 → langchain_timbr-1.5.4}/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
|
|
File without changes
|
{langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/llm_wrapper/llm_wrapper.py
RENAMED
|
File without changes
|
{langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/src/langchain_timbr/llm_wrapper/timbr_llm_wrapper.py
RENAMED
|
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-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_azure_databricks_provider.py
RENAMED
|
File without changes
|
{langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_azure_openai_model.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/integration/test_timeout_functionality.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{langchain_timbr-1.5.3 → langchain_timbr-1.5.4}/tests/standard/test_standard_chain_requirements.py
RENAMED
|
File without changes
|
|
File without changes
|