Replies: 1 comment
-
Hey @SRID45! I'm here to help you with any bugs, questions, or contributions you might have while you wait for a human maintainer. Let's squash those bugs together! 🤖 To improve the performance of the API call using LangChain agents to get SQL results faster when creating an Oracle chatbot with LangChain and SQLAlchemy, you can use a dynamic few-shot prompt with domain-specific knowledge. This approach helps the model make better queries by inserting relevant queries in the prompt that the model can use as reference. Here is how you can set it up:
Additionally, consider the following best practices to further optimize performance:
By using a dynamic few-shot prompt with domain-specific knowledge and following these best practices, you can optimize the performance of your API calls, making the SQL queries more efficient and relevant, thus speeding up the process of getting SQL results [1][2][3][4]. |
Beta Was this translation helpful? Give feedback.
-
Checked other resources
Commit to Help
Example Code
Description
we are trying to create oracle chatbot using langchain and SQLAlchemy.
while executing the above api call, its taking more time for query generation and execution.
Could you please suggest me , how to improve the performance of the api call using langchain agents to get the sql results fastly.
please find the below detail output, while calling the API
[2024-07-08 22:18:54]
select sys_context( 'userenv', 'current_schema' ) from dual
select sys_context( 'userenv', 'current_schema' ) from dual
select sys_context( 'userenv', 'current_schema' ) from dual
SELECT CASE BITAND(t.flag, POWER(2, 28)) WHEN 0 THEN 'READ COMMITTED' ELSE 'SERIALIZABLE' END AS isolation_level FROM v$transaction t WHERE (t.xidusn, t.xidslot, t.xidsqn) = ((:xidusn, :xidslot, :xidsqn))
SELECT value FROM v$parameter WHERE name = 'compatible'
SELECT value FROM v$parameter WHERE name = 'compatible'
SELECT value FROM v$parameter WHERE name = 'compatible'
SELECT 1.1 FROM DUAL
SELECT a_tables.table_name
FROM all_tables a_tables
WHERE (coalesce(a_tables.tablespace_name, :coalesce_1) NOT IN (:coalesce_2_1, :coalesce_2_2)) AND a_tables.owner = :owner_1 AND a_tables.iot_name IS NULL AND a_tables.duration IS NULL MINUS SELECT a_mviews.mview_name AS table_name
FROM all_mviews a_mviews
WHERE a_mviews.owner = :owner_2
SELECT a_tables.table_name
FROM all_tables a_tables
WHERE (coalesce(a_tables.tablespace_name, :coalesce_1) NOT IN (:coalesce_2_1, :coalesce_2_2)) AND a_tables.owner = :owner_1 AND a_tables.iot_name IS NULL AND a_tables.duration IS NULL MINUS SELECT a_mviews.mview_name AS table_name
FROM all_mviews a_mviews
WHERE a_mviews.owner = :owner_2
SELECT a_tables.table_name
FROM all_tables a_tables
WHERE (coalesce(a_tables.tablespace_name, :coalesce_1) NOT IN (:coalesce_2_1, :coalesce_2_2)) AND a_tables.owner = :owner_1 AND a_tables.iot_name IS NULL AND a_tables.duration IS NULL MINUS SELECT a_mviews.mview_name AS table_name
FROM all_mviews a_mviews
WHERE a_mviews.owner = :owner_2
Invoking:
sql_db_list_tables
with{}
Invoking:
sql_db_query_checker
with{'query': 'SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, DEPARTMENT_ID FROM SCOTT.EMPLOYEES ORDER BY EMPLOYEE_ID FETCH FIRST 5 ROWS ONLY'}
Invoking:
sql_db_query
with{'query': 'SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, DEPARTMENT_ID FROM SCOTT.EMPLOYEES ORDER BY EMPLOYEE_ID FETCH FIRST 5 ROWS ONLY'}
ALTER SESSION SET CURRENT_SCHEMA = SCOTT
ALTER SESSION SET CURRENT_SCHEMA = SCOTT
ALTER SESSION SET CURRENT_SCHEMA = SCOTT
[2024-07-08 22:19:26]
System Info
Package versions:
langchain-community==0.2.1
langchain-core==0.2.3
langchain-openai==0.1.8
SQLAlchemy==2.0.29
oracledb==2.2.1
Platform: Windows 10
Python Version: 3.12
Beta Was this translation helpful? Give feedback.
All reactions