Commit Graph

30 Commits

Author SHA1 Message Date
leo-gan fd69cc7e42 Removed duplicate BaseModel dependencies (#2471)
Removed duplicate BaseModel dependencies in class inheritances.
Also, sorted imports by `isort`.
2023-04-06 12:45:16 -07:00
Harrison Chase 609b14a570 Harrison/sql alchemy (#2216)
Co-authored-by: Jason B. Hart <jasonbhart@users.noreply.github.com>
2023-04-01 12:52:08 -07:00
Harrison Chase b1c4480d7c fix typing (#1807) 2023-03-20 07:50:49 -07:00
Harrison Chase c9b5a30b37 move output parsing (#1605) 2023-03-11 16:41:03 -08:00
Harrison Chase cb04ba0136 Add support for intermediate steps to SQLDatabaseSequentialChain (#1583) (#1601)
for https://github.com/hwchase17/langchain/issues/1582

I simply added the `return_intermediate_steps` and changed the
`output_keys` function.

I added 2 simple tests, 1 for SQLDatabaseSequentialChain without the
intermediate steps and 1 with

Co-authored-by: brad-nemetski <115185478+brad-nemetski@users.noreply.github.com>
2023-03-11 15:44:41 -08:00
Jon Luo 8a35811556 Don't instruct LLM to use the LIMIT clause, which is incompatible with SQL Server (#1242)
The current prompt specifically instructs the LLM to use the `LIMIT`
clause. This will cause issues with MS SQL Server, which uses `SELECT
TOP` instead of `LIMIT`. The generated SQL will use `LIMIT`; the
instruction to "always limit... using the LIMIT clause" seems to
override the "create a syntactically correct mssql query to run"
portion. Reported here:
https://github.com/hwchase17/langchain/issues/1103#issuecomment-1441144224

I don't have access to a SQL Server instance to test, but removing that
part of the prompt in OpenAI Playground results in the correct `SELECT
TOP` syntax, whereas keeping it in results in the `LIMIT` clause, even
when instructing it to generate syntactically correct mssql. It's also
still correctly using `LIMIT` in my MariaDB database. I think in this
case we can assume that the model will select the appropriate method
based on the dialect specified.

In general, it would be nice to be able to test a suite of SQL dialects
for things like dialect-specific syntax and other issues we've run into
in the past, but I'm not quite sure how to best approach that yet.
2023-02-22 22:21:26 -08:00
Harrison Chase ec727bf166 Align table info (#999) (#1034)
Currently the chain is getting the column names and types on the one
side and the example rows on the other. It is easier for the llm to read
the table information if the column name and examples are shown together
so that it can easily understand to which columns do the examples refer
to. For an instantiation of this, please refer to the changes in the
`sqlite.ipynb` notebook.

Also changed `eval` for `ast.literal_eval` when interpreting the results
from the sample row query since it is a better practice.

---------

Co-authored-by: Francisco Ingham <>

---------

Co-authored-by: Francisco Ingham <fpingham@gmail.com>
2023-02-13 21:48:41 -08:00
Zach Schillaci 4c79100b15 Correct prompt typo + update example for SQLDatabaseChain (#868)
See https://github.com/hwchase17/langchain/issues/821
2023-02-03 08:34:41 -08:00
Harrison Chase 364b771743 sql return direct (#864) 2023-02-02 22:07:41 -08:00
Zach Schillaci b4eb043b81 Minor fix to SQLDatabaseChain doc (#826) 2023-02-01 23:37:38 -08:00
Harrison Chase 94ae126747 return sql intermediate steps (#792) 2023-01-30 15:10:48 -08:00
Francisco Ingham 213c2e33e5 Sql prompt improvement (#787)
Co-authored-by: Francisco Ingham <>
2023-01-28 13:34:15 -08:00
Samantha Whitmore be7de427ca Serialize all the chains! (#761)
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
2023-01-27 00:45:17 -08:00
Harrison Chase cbc146720b verbose flag (#683) 2023-01-22 12:44:14 -08:00
Harrison Chase 6be5f4e4c4 Harrison/sql db chain (#641)
Co-authored-by: Bruno Bornsztein <bruno.bornsztein@gmail.com>
2023-01-17 22:32:28 -08:00
Harrison Chase 3d43906572 Harrison/new api chain (#623)
Co-authored-by: Francisco Ingham <fpingham@gmail.com>
Co-authored-by: lesscomfortable <pancho_ingham@hotmail.com>
2023-01-15 18:34:43 -08:00
Harrison Chase 1c71fadfdc more complex sql chain (#619)
add a more complex sql chain that first subsets the necessary tables
2023-01-15 17:07:21 -08:00
Harrison Chase 9f9afbb6a8 add custom prompt for LLMMathChain and SQLDatabase chain (#605) 2023-01-13 06:28:51 -08:00
Harrison Chase 9e04c34e20 Add BaseCallbackHandler and CallbackManager (#478)
Co-authored-by: Ankush Gola <9536492+agola11@users.noreply.github.com>
2023-01-04 07:54:25 -08:00
Harrison Chase 3474f39e21 Harrison/improve cache (#368)
make it so everything goes through generate, which removes the need for
two types of caches
2022-12-18 16:22:42 -05:00
Harrison Chase 9481a23314 stop using chained input except in agent (#249) 2022-12-03 14:15:56 -08:00
Xupeng (Tony) Tong bb4bf9d6d0 chore: minor clean up / formatting (#233)
to get familiarize with the project
2022-12-01 10:50:36 -08:00
Harrison Chase c02eb199b6 add few shot example (#148) 2022-11-19 20:32:45 -08:00
Harrison Chase 9f223e6ccc Harrison/fix lint (#138) 2022-11-14 08:55:59 -08:00
Delip Rao 76cecf8165 A fix for Jupyter environment variable issue (#135)
- fixes the Jupyter environment variable issues mentioned in issue #134 
- fixes format/lint issues in some unrelated files (from make
format/lint)


![image](https://user-images.githubusercontent.com/347398/201599322-090af858-362d-4d69-bf59-208aea65419a.png)
2022-11-14 08:34:01 -08:00
Harrison Chase f23b3ceb49 consolidate run functions (#126)
consolidating logic for when a chain is able to run with single input
text, single output text

open to feedback on naming, logic, usefulness
2022-11-13 18:14:35 -08:00
Samantha Whitmore a5b61d59e1 Refactor prompts into module, add example generation utils (#64) 2022-11-06 15:40:33 -08:00
Harrison Chase f772934108 improve logging (#66) 2022-11-05 15:13:12 -07:00
Harrison Chase 4cc18d6c2a Harrison/pretty print (#57)
make stuff look nice
2022-11-03 00:41:07 -07:00
Harrison Chase af81e9ca9c add sql database (#35) 2022-10-27 23:21:47 -07:00