langchain-timbr 2.1.4__tar.gz → 2.1.6__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.4 → langchain_timbr-2.1.6}/PKG-INFO +8 -32
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/README.md +1 -1
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/pyproject.toml +9 -34
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/requirements.txt +3 -2
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/requirements310.txt +4 -3
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/requirements311.txt +3 -2
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/_version.py +2 -2
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/config.py +5 -1
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langchain/execute_timbr_query_chain.py +11 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langchain/generate_timbr_sql_chain.py +10 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langchain/timbr_sql_agent.py +19 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langgraph/execute_timbr_query_node.py +7 -1
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langgraph/generate_response_node.py +3 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langgraph/generate_timbr_sql_node.py +7 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/llm_wrapper/llm_wrapper.py +51 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/utils/timbr_llm_utils.py +353 -61
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/standard/test_optional_llm_integration.py +1 -6
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/.github/dependabot.yml +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/.github/pull_request_template.md +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/.github/workflows/_codespell.yml +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/.github/workflows/_fossa.yml +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/.github/workflows/install-dependencies-and-run-tests.yml +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/.github/workflows/publish.yml +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/.gitignore +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/LICENSE +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/SECURITY.md +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/pytest.ini +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/__init__.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langchain/__init__.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langchain/generate_answer_chain.py +1 -1
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langchain/identify_concept_chain.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langchain/validate_timbr_sql_chain.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langgraph/__init__.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langgraph/identify_concept_node.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langgraph/validate_timbr_query_node.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/llm_wrapper/timbr_llm_wrapper.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/timbr_llm_connector.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/utils/general.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/utils/prompt_service.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/utils/temperature_supported_models.json +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/utils/timbr_utils.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/README.md +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/conftest.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/integration/test_agent_integration.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/integration/test_azure_databricks_provider.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/integration/test_azure_openai_model.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/integration/test_chain_pipeline.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/integration/test_jwt_token.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/integration/test_langchain_chains.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/integration/test_langgraph_nodes.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/integration/test_timeout_functionality.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/standard/conftest.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/standard/test_chain_documentation.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/standard/test_connection_validation.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/standard/test_llm_wrapper_optional_params.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/tests/standard/test_standard_chain_requirements.py +0 -0
- {langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/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.6
|
|
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/
|
|
@@ -19,44 +19,17 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.12
|
|
20
20
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
21
21
|
Requires-Python: <3.13,>=3.10
|
|
22
|
-
Requires-Dist: anthropic==0.42.0
|
|
23
|
-
Requires-Dist: azure-identity==1.25.0; python_version >= '3.11'
|
|
24
|
-
Requires-Dist: azure-identity>=1.16.1; python_version == '3.10'
|
|
25
22
|
Requires-Dist: cryptography==45.0.7; python_version >= '3.11'
|
|
26
23
|
Requires-Dist: cryptography>=44.0.3; python_version == '3.10'
|
|
27
|
-
Requires-Dist: databricks-langchain==0.7.1
|
|
28
|
-
Requires-Dist: databricks-sdk==0.64.0
|
|
29
|
-
Requires-Dist: google-generativeai==0.8.4
|
|
30
|
-
Requires-Dist: langchain-anthropic==0.3.5; python_version >= '3.11'
|
|
31
|
-
Requires-Dist: langchain-anthropic>=0.3.1; python_version == '3.10'
|
|
32
24
|
Requires-Dist: langchain-community==0.3.30; python_version >= '3.11'
|
|
33
|
-
Requires-Dist: langchain-community>=0.3.
|
|
34
|
-
Requires-Dist: langchain-core
|
|
35
|
-
Requires-Dist: langchain-core>=0.3.58; python_version == '3.10'
|
|
36
|
-
Requires-Dist: langchain-google-genai==2.0.10; python_version >= '3.11'
|
|
37
|
-
Requires-Dist: langchain-google-genai>=2.0.9; python_version == '3.10'
|
|
38
|
-
Requires-Dist: langchain-google-vertexai==2.1.2; python_version >= '3.11'
|
|
39
|
-
Requires-Dist: langchain-google-vertexai>=2.0.28; python_version == '3.10'
|
|
40
|
-
Requires-Dist: langchain-openai==0.3.34; python_version >= '3.11'
|
|
41
|
-
Requires-Dist: langchain-openai>=0.3.16; python_version == '3.10'
|
|
42
|
-
Requires-Dist: langchain-tests==0.3.22; python_version >= '3.11'
|
|
43
|
-
Requires-Dist: langchain-tests>=0.3.20; python_version == '3.10'
|
|
25
|
+
Requires-Dist: langchain-community>=0.3.27; python_version == '3.10'
|
|
26
|
+
Requires-Dist: langchain-core>=0.3.80
|
|
44
27
|
Requires-Dist: langchain==0.3.27; python_version >= '3.11'
|
|
45
28
|
Requires-Dist: langchain>=0.3.25; python_version == '3.10'
|
|
46
29
|
Requires-Dist: langgraph==0.6.8; python_version >= '3.11'
|
|
47
30
|
Requires-Dist: langgraph>=0.3.20; python_version == '3.10'
|
|
48
|
-
Requires-Dist: openai==2.1.0; python_version >= '3.11'
|
|
49
|
-
Requires-Dist: openai>=1.77.0; python_version == '3.10'
|
|
50
|
-
Requires-Dist: opentelemetry-api==1.38.0; python_version == '3.10'
|
|
51
|
-
Requires-Dist: opentelemetry-sdk==1.38.0; python_version == '3.10'
|
|
52
31
|
Requires-Dist: pydantic==2.10.4
|
|
53
|
-
Requires-Dist:
|
|
54
|
-
Requires-Dist: pytimbr-api==2.0.0; python_version >= '3.11'
|
|
55
|
-
Requires-Dist: pytimbr-api>=2.0.0; python_version == '3.10'
|
|
56
|
-
Requires-Dist: snowflake-snowpark-python==1.39.1; python_version >= '3.11'
|
|
57
|
-
Requires-Dist: snowflake-snowpark-python>=1.39.1; python_version == '3.10'
|
|
58
|
-
Requires-Dist: snowflake==1.8.0; python_version >= '3.11'
|
|
59
|
-
Requires-Dist: snowflake>=1.8.0; python_version == '3.10'
|
|
32
|
+
Requires-Dist: pytimbr-api>=2.1.0
|
|
60
33
|
Requires-Dist: tiktoken==0.8.0
|
|
61
34
|
Requires-Dist: transformers==4.57.0; python_version >= '3.11'
|
|
62
35
|
Requires-Dist: transformers>=4.53; python_version == '3.10'
|
|
@@ -70,6 +43,7 @@ Requires-Dist: databricks-sdk==0.64.0; extra == 'all'
|
|
|
70
43
|
Requires-Dist: google-generativeai==0.8.4; extra == 'all'
|
|
71
44
|
Requires-Dist: langchain-anthropic==0.3.5; (python_version >= '3.11') and extra == 'all'
|
|
72
45
|
Requires-Dist: langchain-anthropic>=0.3.1; (python_version == '3.10') and extra == 'all'
|
|
46
|
+
Requires-Dist: langchain-aws<1,>=0.2.35; extra == 'all'
|
|
73
47
|
Requires-Dist: langchain-google-genai==2.0.10; (python_version >= '3.11') and extra == 'all'
|
|
74
48
|
Requires-Dist: langchain-google-genai>=2.0.9; (python_version == '3.10') and extra == 'all'
|
|
75
49
|
Requires-Dist: langchain-google-vertexai==2.1.2; (python_version >= '3.11') and extra == 'all'
|
|
@@ -97,6 +71,8 @@ Requires-Dist: langchain-openai==0.3.34; (python_version >= '3.11') and extra ==
|
|
|
97
71
|
Requires-Dist: langchain-openai>=0.3.16; (python_version == '3.10') and extra == 'azure-openai'
|
|
98
72
|
Requires-Dist: openai==2.1.0; (python_version >= '3.11') and extra == 'azure-openai'
|
|
99
73
|
Requires-Dist: openai>=1.77.0; (python_version == '3.10') and extra == 'azure-openai'
|
|
74
|
+
Provides-Extra: bedrock
|
|
75
|
+
Requires-Dist: langchain-aws==0.2.35; extra == 'bedrock'
|
|
100
76
|
Provides-Extra: databricks
|
|
101
77
|
Requires-Dist: databricks-langchain==0.7.1; extra == 'databricks'
|
|
102
78
|
Requires-Dist: databricks-sdk==0.64.0; extra == 'databricks'
|
|
@@ -158,7 +134,7 @@ python -m pip install langchain-timbr
|
|
|
158
134
|
|
|
159
135
|
### Install with selected LLM providers
|
|
160
136
|
|
|
161
|
-
#### One of: openai, anthropic, google, azure_openai, snowflake, databricks, vertex_ai (or 'all')
|
|
137
|
+
#### One of: openai, anthropic, google, azure_openai, snowflake, databricks, vertex_ai, bedrock (or 'all')
|
|
162
138
|
|
|
163
139
|
```bash
|
|
164
140
|
python -m pip install 'langchain-timbr[<your selected providers, separated by comma w/o space>]'
|
|
@@ -29,7 +29,7 @@ python -m pip install langchain-timbr
|
|
|
29
29
|
|
|
30
30
|
### Install with selected LLM providers
|
|
31
31
|
|
|
32
|
-
#### One of: openai, anthropic, google, azure_openai, snowflake, databricks, vertex_ai (or 'all')
|
|
32
|
+
#### One of: openai, anthropic, google, azure_openai, snowflake, databricks, vertex_ai, bedrock (or 'all')
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
35
|
python -m pip install 'langchain-timbr[<your selected providers, separated by comma w/o space>]'
|
|
@@ -24,53 +24,24 @@ classifiers = [
|
|
|
24
24
|
|
|
25
25
|
dependencies = [
|
|
26
26
|
# Core dependencies that are the same across all Python versions
|
|
27
|
-
"anthropic==0.42.0",
|
|
28
|
-
"databricks-langchain==0.7.1",
|
|
29
|
-
"databricks-sdk==0.64.0",
|
|
30
|
-
"google-generativeai==0.8.4",
|
|
31
27
|
"pydantic==2.10.4",
|
|
32
|
-
"pytest==8.3.4",
|
|
33
28
|
"tiktoken==0.8.0",
|
|
34
29
|
"uvicorn==0.34.0",
|
|
30
|
+
"pytimbr-api>=2.1.0",
|
|
31
|
+
"langchain-core>=0.3.80",
|
|
35
32
|
|
|
36
33
|
# Python 3.11+ versions (same for 3.11 and 3.12+)
|
|
37
|
-
"azure-identity==1.25.0; python_version>='3.11'",
|
|
38
34
|
"cryptography==45.0.7; python_version>='3.11'",
|
|
39
35
|
"langchain==0.3.27; python_version>='3.11'",
|
|
40
|
-
"langchain-anthropic==0.3.5; python_version>='3.11'",
|
|
41
36
|
"langchain-community==0.3.30; python_version>='3.11'",
|
|
42
|
-
"langchain-core==0.3.78; python_version>='3.11'",
|
|
43
|
-
"langchain-google-genai==2.0.10; python_version>='3.11'",
|
|
44
|
-
"langchain-google-vertexai==2.1.2; python_version>='3.11'",
|
|
45
|
-
"langchain-openai==0.3.34; python_version>='3.11'",
|
|
46
|
-
"langchain-tests==0.3.22; python_version>='3.11'",
|
|
47
37
|
"langgraph==0.6.8; python_version>='3.11'",
|
|
48
|
-
"openai==2.1.0; python_version>='3.11'",
|
|
49
|
-
"opentelemetry-api==1.38.0; python_version=='3.10'",
|
|
50
|
-
"opentelemetry-sdk==1.38.0; python_version=='3.10'",
|
|
51
|
-
"pytimbr_api==2.0.0; python_version>='3.11'",
|
|
52
|
-
"snowflake==1.8.0; python_version>='3.11'",
|
|
53
|
-
"snowflake-snowpark-python==1.39.1; python_version>='3.11'",
|
|
54
38
|
"transformers==4.57.0; python_version>='3.11'",
|
|
55
39
|
|
|
56
40
|
# Python 3.10 specific versions
|
|
57
|
-
"azure-identity>=1.16.1; python_version=='3.10'",
|
|
58
41
|
"cryptography>=44.0.3; python_version=='3.10'",
|
|
59
42
|
"langchain>=0.3.25; python_version=='3.10'",
|
|
60
|
-
"langchain-
|
|
61
|
-
"langchain_community>=0.3.20; python_version=='3.10'",
|
|
62
|
-
"langchain-core>=0.3.58; python_version=='3.10'",
|
|
63
|
-
"langchain-google-genai>=2.0.9; python_version=='3.10'",
|
|
64
|
-
"langchain-google-vertexai>=2.0.28; python_version=='3.10'",
|
|
65
|
-
"langchain-openai>=0.3.16; python_version=='3.10'",
|
|
66
|
-
"langchain-tests>=0.3.20; python_version=='3.10'",
|
|
43
|
+
"langchain-community>=0.3.27; python_version=='3.10'",
|
|
67
44
|
"langgraph>=0.3.20; python_version=='3.10'",
|
|
68
|
-
"openai>=1.77.0; python_version=='3.10'",
|
|
69
|
-
"opentelemetry-api==1.38.0; python_version=='3.10'",
|
|
70
|
-
"opentelemetry-sdk==1.38.0; python_version=='3.10'",
|
|
71
|
-
"pytimbr-api>=2.0.0; python_version=='3.10'",
|
|
72
|
-
"snowflake>=1.8.0; python_version=='3.10'",
|
|
73
|
-
"snowflake-snowpark-python>=1.39.1; python_version=='3.10'",
|
|
74
45
|
"transformers>=4.53; python_version=='3.10'",
|
|
75
46
|
]
|
|
76
47
|
|
|
@@ -117,6 +88,9 @@ databricks = [
|
|
|
117
88
|
"databricks-langchain==0.7.1",
|
|
118
89
|
"databricks-sdk==0.64.0"
|
|
119
90
|
]
|
|
91
|
+
bedrock = [
|
|
92
|
+
"langchain-aws==0.2.35",
|
|
93
|
+
]
|
|
120
94
|
|
|
121
95
|
# Development and testing
|
|
122
96
|
dev = [
|
|
@@ -128,12 +102,13 @@ dev = [
|
|
|
128
102
|
|
|
129
103
|
# All optional dependencies
|
|
130
104
|
all = [
|
|
131
|
-
"anthropic==0.42.0",
|
|
132
|
-
"google-generativeai==0.8.4",
|
|
133
105
|
"pytest==8.3.4",
|
|
134
106
|
"uvicorn==0.34.0",
|
|
107
|
+
"anthropic==0.42.0",
|
|
108
|
+
"google-generativeai==0.8.4",
|
|
135
109
|
"databricks-langchain==0.7.1",
|
|
136
110
|
"databricks-sdk==0.64.0",
|
|
111
|
+
"langchain-aws>=0.2.35,<1",
|
|
137
112
|
# Python 3.11+ versions
|
|
138
113
|
"azure-identity==1.25.0; python_version>='3.11'",
|
|
139
114
|
"langchain-anthropic==0.3.5; python_version>='3.11'",
|
|
@@ -6,8 +6,9 @@ databricks-sdk==0.64.0
|
|
|
6
6
|
google-generativeai==0.8.4
|
|
7
7
|
langchain==0.3.27
|
|
8
8
|
langchain-anthropic==0.3.5
|
|
9
|
+
langchain-aws==0.2.35
|
|
9
10
|
langchain-community==0.3.30
|
|
10
|
-
langchain-core==0.3.
|
|
11
|
+
langchain-core==0.3.80
|
|
11
12
|
langchain-google-genai==2.0.10
|
|
12
13
|
langchain-google-vertexai==2.1.2
|
|
13
14
|
langchain-openai==0.3.34
|
|
@@ -17,7 +18,7 @@ langgraph-checkpoint==3.0.0
|
|
|
17
18
|
openai==2.1.0
|
|
18
19
|
pydantic==2.10.4
|
|
19
20
|
pytest==8.3.4
|
|
20
|
-
|
|
21
|
+
pytimbr-api>=2.1.0
|
|
21
22
|
snowflake==1.8.0
|
|
22
23
|
snowflake-snowpark-python==1.39.1
|
|
23
24
|
tiktoken==0.8.0
|
|
@@ -6,8 +6,9 @@ databricks-sdk==0.64.0
|
|
|
6
6
|
google-generativeai==0.8.4
|
|
7
7
|
langchain>=0.3.25
|
|
8
8
|
langchain-anthropic>=0.3.1
|
|
9
|
-
|
|
10
|
-
langchain-
|
|
9
|
+
langchain-aws==0.2.35
|
|
10
|
+
langchain-community>=0.3.27
|
|
11
|
+
langchain-core>=0.3.80
|
|
11
12
|
langchain-google-genai>=2.0.9
|
|
12
13
|
langchain-google-vertexai>=2.0.28
|
|
13
14
|
langchain-openai>=0.3.16
|
|
@@ -18,7 +19,7 @@ opentelemetry-api==1.38.0 # Required when using snowflake with Python under 3.12
|
|
|
18
19
|
opentelemetry-sdk==1.38.0 # Required when using snowflake with Python under 3.12
|
|
19
20
|
pydantic==2.10.4
|
|
20
21
|
pytest==8.3.4
|
|
21
|
-
pytimbr-api>=2.
|
|
22
|
+
pytimbr-api>=2.1.0
|
|
22
23
|
snowflake>=1.8.0
|
|
23
24
|
snowflake-snowpark-python>=1.23.0
|
|
24
25
|
snowflake-connector-python[pandas]>=3.13.1,<4
|
|
@@ -6,8 +6,9 @@ databricks-sdk==0.64.0
|
|
|
6
6
|
google-generativeai==0.8.4
|
|
7
7
|
langchain==0.3.27
|
|
8
8
|
langchain-anthropic==0.3.5
|
|
9
|
+
langchain-aws==0.2.35
|
|
9
10
|
langchain-community==0.3.30
|
|
10
|
-
langchain-core==0.3.
|
|
11
|
+
langchain-core==0.3.80
|
|
11
12
|
langchain-google-genai==2.0.10
|
|
12
13
|
langchain-google-vertexai==2.1.2
|
|
13
14
|
langchain-openai==0.3.34
|
|
@@ -18,7 +19,7 @@ opentelemetry-api==1.38.0 # Required when using snowflake with Python under 3.12
|
|
|
18
19
|
opentelemetry-sdk==1.38.0 # Required when using snowflake with Python under 3.12
|
|
19
20
|
pydantic==2.10.4
|
|
20
21
|
pytest==8.3.4
|
|
21
|
-
|
|
22
|
+
pytimbr-api>=2.1.0
|
|
22
23
|
snowflake==1.8.0
|
|
23
24
|
snowflake-snowpark-python==1.39.1
|
|
24
25
|
tiktoken==0.8.0
|
|
@@ -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.6'
|
|
32
|
+
__version_tuple__ = version_tuple = (2, 1, 6)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
|
@@ -27,4 +27,8 @@ llm_client_id = os.environ.get('LLM_CLIENT_ID', None)
|
|
|
27
27
|
llm_client_secret = os.environ.get('LLM_CLIENT_SECRET', None)
|
|
28
28
|
llm_endpoint = os.environ.get('LLM_ENDPOINT', None)
|
|
29
29
|
llm_api_version = os.environ.get('LLM_API_VERSION', None)
|
|
30
|
-
llm_scope = os.environ.get('LLM_SCOPE', "https://cognitiveservices.azure.com/.default") # e.g. "api://<your-client-id>/.default"
|
|
30
|
+
llm_scope = os.environ.get('LLM_SCOPE', "https://cognitiveservices.azure.com/.default") # e.g. "api://<your-client-id>/.default"
|
|
31
|
+
|
|
32
|
+
# Whether to enable reasoning during SQL generation
|
|
33
|
+
with_reasoning = to_boolean(os.environ.get('WITH_REASONING', 'false'))
|
|
34
|
+
reasoning_steps = to_integer(os.environ.get('REASONING_STEPS', 2))
|
|
@@ -42,6 +42,8 @@ class ExecuteTimbrQueryChain(Chain):
|
|
|
42
42
|
is_jwt: Optional[bool] = False,
|
|
43
43
|
jwt_tenant_id: Optional[str] = None,
|
|
44
44
|
conn_params: Optional[dict] = None,
|
|
45
|
+
with_reasoning: Optional[bool] = config.with_reasoning,
|
|
46
|
+
reasoning_steps: Optional[int] = config.reasoning_steps,
|
|
45
47
|
debug: Optional[bool] = False,
|
|
46
48
|
**kwargs,
|
|
47
49
|
):
|
|
@@ -69,6 +71,8 @@ class ExecuteTimbrQueryChain(Chain):
|
|
|
69
71
|
:param is_jwt: Whether to use JWT authentication (default is False).
|
|
70
72
|
:param jwt_tenant_id: JWT tenant ID for multi-tenant environments (required when is_jwt=True).
|
|
71
73
|
:param conn_params: Extra Timbr connection parameters sent with every request (e.g., 'x-api-impersonate-user').
|
|
74
|
+
:param with_reasoning: Whether to enable reasoning during SQL generation (default is False).
|
|
75
|
+
:param reasoning_steps: Number of reasoning steps to perform if reasoning is enabled (default is 2).
|
|
72
76
|
:param kwargs: Additional arguments to pass to the base
|
|
73
77
|
:return: A list of rows from the Timbr query
|
|
74
78
|
|
|
@@ -137,6 +141,8 @@ class ExecuteTimbrQueryChain(Chain):
|
|
|
137
141
|
self._jwt_tenant_id = jwt_tenant_id
|
|
138
142
|
self._debug = to_boolean(debug)
|
|
139
143
|
self._conn_params = conn_params or {}
|
|
144
|
+
self._with_reasoning = to_boolean(with_reasoning)
|
|
145
|
+
self._reasoning_steps = to_integer(reasoning_steps)
|
|
140
146
|
|
|
141
147
|
|
|
142
148
|
@property
|
|
@@ -209,6 +215,8 @@ class ExecuteTimbrQueryChain(Chain):
|
|
|
209
215
|
note=(self._note or '') + err_txt,
|
|
210
216
|
db_is_case_sensitive=self._db_is_case_sensitive,
|
|
211
217
|
graph_depth=self._graph_depth,
|
|
218
|
+
with_reasoning=self._with_reasoning,
|
|
219
|
+
reasoning_steps=self._reasoning_steps,
|
|
212
220
|
debug=self._debug,
|
|
213
221
|
)
|
|
214
222
|
|
|
@@ -239,6 +247,7 @@ class ExecuteTimbrQueryChain(Chain):
|
|
|
239
247
|
concept_name = inputs.get("concept", self._concept)
|
|
240
248
|
is_sql_valid = True
|
|
241
249
|
error = None
|
|
250
|
+
reasoning_status = None
|
|
242
251
|
usage_metadata = {}
|
|
243
252
|
|
|
244
253
|
if sql and self._should_validate_sql:
|
|
@@ -255,6 +264,7 @@ class ExecuteTimbrQueryChain(Chain):
|
|
|
255
264
|
schema_name = generate_res.get("schema", schema_name)
|
|
256
265
|
concept_name = generate_res.get("concept", concept_name)
|
|
257
266
|
is_sql_valid = generate_res.get("is_sql_valid")
|
|
267
|
+
reasoning_status = generate_res.get("reasoning_status")
|
|
258
268
|
if not is_sql_valid and not self._should_validate_sql:
|
|
259
269
|
is_sql_valid = True
|
|
260
270
|
|
|
@@ -293,6 +303,7 @@ class ExecuteTimbrQueryChain(Chain):
|
|
|
293
303
|
"schema": schema_name,
|
|
294
304
|
"concept": concept_name,
|
|
295
305
|
"error": error if not is_sql_valid else None,
|
|
306
|
+
"reasoning_status": reasoning_status,
|
|
296
307
|
self.usage_metadata_key: usage_metadata,
|
|
297
308
|
}
|
|
298
309
|
|
|
@@ -39,6 +39,8 @@ class GenerateTimbrSqlChain(Chain):
|
|
|
39
39
|
is_jwt: Optional[bool] = False,
|
|
40
40
|
jwt_tenant_id: Optional[str] = None,
|
|
41
41
|
conn_params: Optional[dict] = None,
|
|
42
|
+
with_reasoning: Optional[bool] = config.with_reasoning,
|
|
43
|
+
reasoning_steps: Optional[int] = config.reasoning_steps,
|
|
42
44
|
debug: Optional[bool] = False,
|
|
43
45
|
**kwargs,
|
|
44
46
|
):
|
|
@@ -64,6 +66,9 @@ class GenerateTimbrSqlChain(Chain):
|
|
|
64
66
|
:param is_jwt: Whether to use JWT authentication (default is False).
|
|
65
67
|
:param jwt_tenant_id: JWT tenant ID for multi-tenant environments (required when is_jwt=True).
|
|
66
68
|
:param conn_params: Extra Timbr connection parameters sent with every request (e.g., 'x-api-impersonate-user').
|
|
69
|
+
:param with_reasoning: Whether to enable reasoning during SQL generation (default is False).
|
|
70
|
+
:param reasoning_steps: Number of reasoning steps to perform if reasoning is enabled (default is 2).
|
|
71
|
+
:param debug: Whether to enable debug mode for detailed logging
|
|
67
72
|
:param kwargs: Additional arguments to pass to the base
|
|
68
73
|
|
|
69
74
|
## Example
|
|
@@ -129,6 +134,8 @@ class GenerateTimbrSqlChain(Chain):
|
|
|
129
134
|
self._jwt_tenant_id = jwt_tenant_id
|
|
130
135
|
self._debug = to_boolean(debug)
|
|
131
136
|
self._conn_params = conn_params or {}
|
|
137
|
+
self._with_reasoning = to_boolean(with_reasoning)
|
|
138
|
+
self._reasoning_steps = to_integer(reasoning_steps)
|
|
132
139
|
|
|
133
140
|
|
|
134
141
|
@property
|
|
@@ -184,6 +191,8 @@ class GenerateTimbrSqlChain(Chain):
|
|
|
184
191
|
note=self._note,
|
|
185
192
|
db_is_case_sensitive=self._db_is_case_sensitive,
|
|
186
193
|
graph_depth=self._graph_depth,
|
|
194
|
+
with_reasoning=self._with_reasoning,
|
|
195
|
+
reasoning_steps=self._reasoning_steps,
|
|
187
196
|
debug=self._debug,
|
|
188
197
|
)
|
|
189
198
|
|
|
@@ -197,5 +206,6 @@ class GenerateTimbrSqlChain(Chain):
|
|
|
197
206
|
"concept": concept,
|
|
198
207
|
"is_sql_valid": generate_res.get("is_sql_valid"),
|
|
199
208
|
"error": generate_res.get("error"),
|
|
209
|
+
"reasoning_status": generate_res.get("reasoning_status"),
|
|
200
210
|
self.usage_metadata_key: generate_res.get("usage_metadata"),
|
|
201
211
|
}
|
{langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/langchain/timbr_sql_agent.py
RENAMED
|
@@ -6,6 +6,7 @@ from langchain.schema import AgentAction, AgentFinish
|
|
|
6
6
|
from ..utils.general import parse_list, to_boolean, to_integer
|
|
7
7
|
from .execute_timbr_query_chain import ExecuteTimbrQueryChain
|
|
8
8
|
from .generate_answer_chain import GenerateAnswerChain
|
|
9
|
+
from .. import config
|
|
9
10
|
|
|
10
11
|
class TimbrSqlAgent(BaseSingleActionAgent):
|
|
11
12
|
def __init__(
|
|
@@ -34,6 +35,8 @@ class TimbrSqlAgent(BaseSingleActionAgent):
|
|
|
34
35
|
is_jwt: Optional[bool] = False,
|
|
35
36
|
jwt_tenant_id: Optional[str] = None,
|
|
36
37
|
conn_params: Optional[dict] = None,
|
|
38
|
+
with_reasoning: Optional[bool] = config.with_reasoning,
|
|
39
|
+
reasoning_steps: Optional[int] = config.reasoning_steps,
|
|
37
40
|
debug: Optional[bool] = False
|
|
38
41
|
):
|
|
39
42
|
"""
|
|
@@ -61,6 +64,8 @@ class TimbrSqlAgent(BaseSingleActionAgent):
|
|
|
61
64
|
:param is_jwt: Whether to use JWT authentication (default is False).
|
|
62
65
|
:param jwt_tenant_id: JWT tenant ID for multi-tenant environments (required when is_jwt=True).
|
|
63
66
|
:param conn_params: Extra Timbr connection parameters sent with every request (e.g., 'x-api-impersonate-user').
|
|
67
|
+
:param with_reasoning: Whether to enable reasoning during SQL generation (default is False).
|
|
68
|
+
:param reasoning_steps: Number of reasoning steps to perform if reasoning is enabled (default is 2).
|
|
64
69
|
|
|
65
70
|
## Example
|
|
66
71
|
```
|
|
@@ -113,6 +118,8 @@ class TimbrSqlAgent(BaseSingleActionAgent):
|
|
|
113
118
|
is_jwt=to_boolean(is_jwt),
|
|
114
119
|
jwt_tenant_id=jwt_tenant_id,
|
|
115
120
|
conn_params=conn_params,
|
|
121
|
+
with_reasoning=to_boolean(with_reasoning),
|
|
122
|
+
reasoning_steps=to_integer(reasoning_steps),
|
|
116
123
|
debug=to_boolean(debug),
|
|
117
124
|
)
|
|
118
125
|
self._generate_answer = to_boolean(generate_answer)
|
|
@@ -173,6 +180,7 @@ class TimbrSqlAgent(BaseSingleActionAgent):
|
|
|
173
180
|
"sql": None,
|
|
174
181
|
"schema": None,
|
|
175
182
|
"concept": None,
|
|
183
|
+
"reasoning_status": None,
|
|
176
184
|
"usage_metadata": {},
|
|
177
185
|
},
|
|
178
186
|
log="Empty input received"
|
|
@@ -200,6 +208,7 @@ class TimbrSqlAgent(BaseSingleActionAgent):
|
|
|
200
208
|
"schema": result.get("schema", ""),
|
|
201
209
|
"concept": result.get("concept", ""),
|
|
202
210
|
"error": result.get("error", None),
|
|
211
|
+
"reasoning_status": result.get("reasoning_status", None),
|
|
203
212
|
"usage_metadata": usage_metadata,
|
|
204
213
|
},
|
|
205
214
|
log=f"Successfully executed query on concept: {result.get('concept', '')}"
|
|
@@ -214,6 +223,7 @@ class TimbrSqlAgent(BaseSingleActionAgent):
|
|
|
214
223
|
"sql": None,
|
|
215
224
|
"schema": None,
|
|
216
225
|
"concept": None,
|
|
226
|
+
"reasoning_status": None,
|
|
217
227
|
"usage_metadata": {},
|
|
218
228
|
},
|
|
219
229
|
log=error_context
|
|
@@ -234,6 +244,7 @@ class TimbrSqlAgent(BaseSingleActionAgent):
|
|
|
234
244
|
"sql": None,
|
|
235
245
|
"schema": None,
|
|
236
246
|
"concept": None,
|
|
247
|
+
"reasoning_status": None,
|
|
237
248
|
"usage_metadata": {},
|
|
238
249
|
},
|
|
239
250
|
log="Empty or whitespace-only input received"
|
|
@@ -274,6 +285,7 @@ class TimbrSqlAgent(BaseSingleActionAgent):
|
|
|
274
285
|
"schema": result.get("schema", ""),
|
|
275
286
|
"concept": result.get("concept", ""),
|
|
276
287
|
"error": result.get("error", None),
|
|
288
|
+
"reasoning_status": result.get("reasoning_status", None),
|
|
277
289
|
"usage_metadata": usage_metadata,
|
|
278
290
|
},
|
|
279
291
|
log=f"Successfully executed query on concept: {result.get('concept', '')}"
|
|
@@ -288,6 +300,7 @@ class TimbrSqlAgent(BaseSingleActionAgent):
|
|
|
288
300
|
"sql": None,
|
|
289
301
|
"schema": None,
|
|
290
302
|
"concept": None,
|
|
303
|
+
"reasoning_status": None,
|
|
291
304
|
"usage_metadata": {},
|
|
292
305
|
},
|
|
293
306
|
log=error_context
|
|
@@ -332,6 +345,8 @@ def create_timbr_sql_agent(
|
|
|
332
345
|
is_jwt: Optional[bool] = False,
|
|
333
346
|
jwt_tenant_id: Optional[str] = None,
|
|
334
347
|
conn_params: Optional[dict] = None,
|
|
348
|
+
with_reasoning: Optional[bool] = config.with_reasoning,
|
|
349
|
+
reasoning_steps: Optional[int] = config.reasoning_steps,
|
|
335
350
|
debug: Optional[bool] = False
|
|
336
351
|
) -> AgentExecutor:
|
|
337
352
|
"""
|
|
@@ -361,6 +376,8 @@ def create_timbr_sql_agent(
|
|
|
361
376
|
:param is_jwt: Whether to use JWT authentication (default is False).
|
|
362
377
|
:param jwt_tenant_id: JWT tenant ID for multi-tenant environments (required when is_jwt=True).
|
|
363
378
|
:param conn_params: Extra Timbr connection parameters sent with every request (e.g., 'x-api-impersonate-user').
|
|
379
|
+
:param with_reasoning: Whether to enable reasoning during SQL generation (default is False).
|
|
380
|
+
:param reasoning_steps: Number of reasoning steps to perform if reasoning is enabled (default is 2).
|
|
364
381
|
|
|
365
382
|
Returns:
|
|
366
383
|
AgentExecutor: Configured agent executor ready to use
|
|
@@ -427,6 +444,8 @@ def create_timbr_sql_agent(
|
|
|
427
444
|
is_jwt=is_jwt,
|
|
428
445
|
jwt_tenant_id=jwt_tenant_id,
|
|
429
446
|
conn_params=conn_params,
|
|
447
|
+
with_reasoning=with_reasoning,
|
|
448
|
+
reasoning_steps=reasoning_steps,
|
|
430
449
|
debug=debug,
|
|
431
450
|
)
|
|
432
451
|
|
|
@@ -3,7 +3,7 @@ from langchain.llms.base import LLM
|
|
|
3
3
|
from langgraph.graph import StateGraph
|
|
4
4
|
|
|
5
5
|
from ..langchain.execute_timbr_query_chain import ExecuteTimbrQueryChain
|
|
6
|
-
|
|
6
|
+
from .. import config
|
|
7
7
|
|
|
8
8
|
class ExecuteSemanticQueryNode:
|
|
9
9
|
"""
|
|
@@ -36,6 +36,8 @@ class ExecuteSemanticQueryNode:
|
|
|
36
36
|
is_jwt: Optional[bool] = False,
|
|
37
37
|
jwt_tenant_id: Optional[str] = None,
|
|
38
38
|
conn_params: Optional[dict] = None,
|
|
39
|
+
with_reasoning: Optional[bool] = config.with_reasoning,
|
|
40
|
+
reasoning_steps: Optional[int] = config.reasoning_steps,
|
|
39
41
|
debug: Optional[bool] = False,
|
|
40
42
|
**kwargs,
|
|
41
43
|
):
|
|
@@ -63,6 +65,8 @@ class ExecuteSemanticQueryNode:
|
|
|
63
65
|
:param is_jwt: Whether to use JWT authentication (default is False).
|
|
64
66
|
:param jwt_tenant_id: JWT tenant ID for multi-tenant environments (required when is_jwt=True).
|
|
65
67
|
:param conn_params: Extra Timbr connection parameters sent with every request (e.g., 'x-api-impersonate-user').
|
|
68
|
+
:param with_reasoning: Whether to enable reasoning during SQL generation (default is False).
|
|
69
|
+
:param reasoning_steps: Number of reasoning steps to perform if reasoning is enabled (default is 2).
|
|
66
70
|
:return: A list of rows from the Timbr query
|
|
67
71
|
"""
|
|
68
72
|
self.chain = ExecuteTimbrQueryChain(
|
|
@@ -89,6 +93,8 @@ class ExecuteSemanticQueryNode:
|
|
|
89
93
|
is_jwt=is_jwt,
|
|
90
94
|
jwt_tenant_id=jwt_tenant_id,
|
|
91
95
|
conn_params=conn_params,
|
|
96
|
+
with_reasoning=with_reasoning,
|
|
97
|
+
reasoning_steps=reasoning_steps,
|
|
92
98
|
debug=debug,
|
|
93
99
|
**kwargs,
|
|
94
100
|
)
|
|
@@ -20,6 +20,7 @@ class GenerateResponseNode:
|
|
|
20
20
|
is_jwt: Optional[bool] = False,
|
|
21
21
|
jwt_tenant_id: Optional[str] = None,
|
|
22
22
|
conn_params: Optional[dict] = None,
|
|
23
|
+
note: Optional[str] = '',
|
|
23
24
|
debug: Optional[bool] = False,
|
|
24
25
|
**kwargs,
|
|
25
26
|
):
|
|
@@ -31,6 +32,7 @@ class GenerateResponseNode:
|
|
|
31
32
|
:param is_jwt: Whether to use JWT authentication (default is False).
|
|
32
33
|
:param jwt_tenant_id: JWT tenant ID for multi-tenant environments (required when is_jwt=True).
|
|
33
34
|
:param conn_params: Extra Timbr connection parameters sent with every request (e.g., 'x-api-impersonate-user').
|
|
35
|
+
:param note: Optional additional note to extend our llm prompt
|
|
34
36
|
"""
|
|
35
37
|
self.chain = GenerateAnswerChain(
|
|
36
38
|
llm=llm,
|
|
@@ -40,6 +42,7 @@ class GenerateResponseNode:
|
|
|
40
42
|
is_jwt=is_jwt,
|
|
41
43
|
jwt_tenant_id=jwt_tenant_id,
|
|
42
44
|
conn_params=conn_params,
|
|
45
|
+
note=note,
|
|
43
46
|
debug=debug,
|
|
44
47
|
**kwargs,
|
|
45
48
|
)
|
|
@@ -3,6 +3,7 @@ from langchain.llms.base import LLM
|
|
|
3
3
|
from langgraph.graph import StateGraph
|
|
4
4
|
|
|
5
5
|
from ..langchain.generate_timbr_sql_chain import GenerateTimbrSqlChain
|
|
6
|
+
from .. import config
|
|
6
7
|
|
|
7
8
|
class GenerateTimbrSqlNode:
|
|
8
9
|
"""
|
|
@@ -32,6 +33,8 @@ class GenerateTimbrSqlNode:
|
|
|
32
33
|
is_jwt: Optional[bool] = False,
|
|
33
34
|
jwt_tenant_id: Optional[str] = None,
|
|
34
35
|
conn_params: Optional[dict] = None,
|
|
36
|
+
with_reasoning: Optional[bool] = config.with_reasoning,
|
|
37
|
+
reasoning_steps: Optional[int] = config.reasoning_steps,
|
|
35
38
|
debug: Optional[bool] = False,
|
|
36
39
|
**kwargs,
|
|
37
40
|
):
|
|
@@ -57,6 +60,8 @@ class GenerateTimbrSqlNode:
|
|
|
57
60
|
:param is_jwt: Whether to use JWT authentication (default: False)
|
|
58
61
|
:param jwt_tenant_id: Tenant ID for JWT authentication when using multi-tenant setup
|
|
59
62
|
:param conn_params: Extra Timbr connection parameters sent with every request (e.g., 'x-api-impersonate-user').
|
|
63
|
+
:param with_reasoning: Whether to enable reasoning during SQL generation (default is False).
|
|
64
|
+
:param reasoning_steps: Number of reasoning steps to perform if reasoning is enabled (default is 2).
|
|
60
65
|
"""
|
|
61
66
|
self.chain = GenerateTimbrSqlChain(
|
|
62
67
|
llm=llm,
|
|
@@ -80,6 +85,8 @@ class GenerateTimbrSqlNode:
|
|
|
80
85
|
is_jwt=is_jwt,
|
|
81
86
|
jwt_tenant_id=jwt_tenant_id,
|
|
82
87
|
conn_params=conn_params,
|
|
88
|
+
with_reasoning=with_reasoning,
|
|
89
|
+
reasoning_steps=reasoning_steps,
|
|
83
90
|
debug=debug,
|
|
84
91
|
**kwargs,
|
|
85
92
|
)
|
{langchain_timbr-2.1.4 → langchain_timbr-2.1.6}/src/langchain_timbr/llm_wrapper/llm_wrapper.py
RENAMED
|
@@ -15,6 +15,7 @@ class LlmTypes(Enum):
|
|
|
15
15
|
Snowflake = 'snowflake-cortex'
|
|
16
16
|
Databricks = 'chat-databricks'
|
|
17
17
|
VertexAI = 'chat-vertexai'
|
|
18
|
+
Bedrock = 'amazon_bedrock_converse_chat'
|
|
18
19
|
Timbr = 'timbr'
|
|
19
20
|
|
|
20
21
|
|
|
@@ -252,6 +253,28 @@ class LlmWrapper(LLM):
|
|
|
252
253
|
credentials=creds,
|
|
253
254
|
**params,
|
|
254
255
|
)
|
|
256
|
+
elif is_llm_type(llm_type, LlmTypes.Bedrock):
|
|
257
|
+
from langchain_aws import ChatBedrockConverse
|
|
258
|
+
llm_model = model or "openai.gpt-oss-20b-1:0"
|
|
259
|
+
params = self._add_temperature(LlmTypes.Bedrock.name, llm_model, **llm_params)
|
|
260
|
+
|
|
261
|
+
aws_region = pop_param_value(params, ['aws_region', 'llm_region', 'region'])
|
|
262
|
+
if aws_region:
|
|
263
|
+
params['region_name'] = aws_region
|
|
264
|
+
aws_access_key_id = pop_param_value(params, ['aws_access_key_id', 'llm_access_key_id', 'access_key_id'])
|
|
265
|
+
if aws_access_key_id:
|
|
266
|
+
params['aws_access_key_id'] = aws_access_key_id
|
|
267
|
+
aws_secret_access_key = pop_param_value(params, ['aws_secret_access_key', 'llm_secret_access_key', 'secret_access_key'], default=api_key)
|
|
268
|
+
if aws_secret_access_key:
|
|
269
|
+
params['aws_secret_access_key'] = aws_secret_access_key
|
|
270
|
+
aws_session_token = pop_param_value(params, ['aws_session_token', 'llm_session_token', 'session_token'])
|
|
271
|
+
if aws_session_token:
|
|
272
|
+
params['aws_session_token'] = aws_session_token
|
|
273
|
+
|
|
274
|
+
return ChatBedrockConverse(
|
|
275
|
+
model=llm_model,
|
|
276
|
+
**params,
|
|
277
|
+
)
|
|
255
278
|
else:
|
|
256
279
|
raise ValueError(f"Unsupported LLM type: {llm_type}")
|
|
257
280
|
|
|
@@ -324,6 +347,31 @@ class LlmWrapper(LLM):
|
|
|
324
347
|
if self.client.credentials:
|
|
325
348
|
client = genai.Client(credentials=self.client.credentials, vertexai=True, project=self.client.project, location=self.client.location)
|
|
326
349
|
models = [m.name.split('/')[-1] for m in client.models.list()]
|
|
350
|
+
elif is_llm_type(self._llm_type, LlmTypes.Bedrock):
|
|
351
|
+
import boto3
|
|
352
|
+
|
|
353
|
+
# Extract SecretStr values properly
|
|
354
|
+
aws_access_key_id = getattr(self.client, 'aws_access_key_id', None)
|
|
355
|
+
if aws_access_key_id and hasattr(aws_access_key_id, '_secret_value'):
|
|
356
|
+
aws_access_key_id = aws_access_key_id._secret_value
|
|
357
|
+
|
|
358
|
+
aws_secret_access_key = getattr(self.client, 'aws_secret_access_key', None)
|
|
359
|
+
if aws_secret_access_key and hasattr(aws_secret_access_key, '_secret_value'):
|
|
360
|
+
aws_secret_access_key = aws_secret_access_key._secret_value
|
|
361
|
+
|
|
362
|
+
aws_session_token = getattr(self.client, 'aws_session_token', None)
|
|
363
|
+
if aws_session_token and hasattr(aws_session_token, '_secret_value'):
|
|
364
|
+
aws_session_token = aws_session_token._secret_value
|
|
365
|
+
|
|
366
|
+
bedrock_client = boto3.client(
|
|
367
|
+
service_name='bedrock',
|
|
368
|
+
region_name=getattr(self.client, 'region_name', None),
|
|
369
|
+
aws_access_key_id=aws_access_key_id,
|
|
370
|
+
aws_secret_access_key=aws_secret_access_key,
|
|
371
|
+
aws_session_token=aws_session_token,
|
|
372
|
+
)
|
|
373
|
+
response = bedrock_client.list_foundation_models()
|
|
374
|
+
models = [model['modelId'] for model in response.get('modelSummaries', [])]
|
|
327
375
|
|
|
328
376
|
except Exception:
|
|
329
377
|
# If model list fetching throws an exception, return default value using get_supported_models
|
|
@@ -341,6 +389,9 @@ class LlmWrapper(LLM):
|
|
|
341
389
|
|
|
342
390
|
|
|
343
391
|
def _call(self, prompt, **kwargs):
|
|
392
|
+
# TODO: Remove this condition on next langchain-timbr major release
|
|
393
|
+
if is_llm_type(self._llm_type, LlmTypes.Bedrock):
|
|
394
|
+
return self.client.invoke(prompt, **kwargs)
|
|
344
395
|
return self.client(prompt, **kwargs)
|
|
345
396
|
|
|
346
397
|
|