Commit Graph

483 Commits (main)

Author SHA1 Message Date
Harrison Chase e9ef08862d
validate template (#865) 1 year ago
Harrison Chase 364b771743
sql return direct (#864) 1 year ago
Harrison Chase 483441d305
pass kwargs through to loading (#863) 1 year ago
Harrison Chase 8df6b68093
fix length based example selector (#862) 1 year ago
Harrison Chase 3f48eed5bd
Harrison/milvus (#856)
Signed-off-by: Filip Haltmayer <filip.haltmayer@zilliz.com>
Signed-off-by: Frank Liu <frank.liu@zilliz.com>
Co-authored-by: Filip Haltmayer <81822489+filip-halt@users.noreply.github.com>
Co-authored-by: Frank Liu <frank@frankzliu.com>
1 year ago
Ankush Gola 933441cc52
Add retry to OpenAI llm (#849)
add ability to retry when certain exceptions are raised by
`openai.Completions.create`

Test plan: ran all OpenAI integration tests.
1 year ago
kahkeng 4a8f5cdf4b
Add alternative token-based text splitter (#816)
This does not involve a separator, and will naively chunk input text at
the appropriate boundaries in token space.

This is helpful if we have strict token length limits that we need to
strictly follow the specified chunk size, and we can't use aggressive
separators like spaces to guarantee the absence of long strings.

CharacterTextSplitter will let these strings through without splitting
them, which could cause overflow errors downstream.

Splitting at arbitrary token boundaries is not ideal but is hopefully
mitigated by having a decent overlap quantity. Also this results in
chunks which has exact number of tokens desired, instead of sometimes
overcounting if we concatenate shorter strings.

Potentially also helps with #528.
1 year ago
Harrison Chase 23d5f64bda
Harrison/ngram example (#846)
Co-authored-by: Sean Spriggens <ssprigge@syr.edu>
1 year ago
Harrison Chase 0de55048b7
return code for pal (#844) 1 year ago
Harrison Chase d564308e0f
rfc: instruct embeddings (#811)
Co-authored-by: seanaedmiston <seane999@gmail.com>
1 year ago
Nick Furlotte 576609e665
Update PAL to allow passing local and global context to PythonREPL (#774)
Passing additional variables to the python environment can be useful for
example if you want to generate code to analyze a dataset.

I also added a tracker for the executed code - `code_history`.
1 year ago
Harrison Chase 3f952eb597
add from string method (#820) 1 year ago
Ikko Eltociear Ashimine ba26a879e0
Fix typo in crawler.py (#842)
seperator -> separator
1 year ago
Jonas Ehrenstein f3508228df
Minor fix for google search util: it's uncertain if "snippet" in results exists (#830)
The results from Google search may not always contain a "snippet". 

Example:
`{'kind': 'customsearch#result', 'title': 'FEMA Flood Map', 'htmlTitle':
'FEMA Flood Map', 'link': 'https://msc.fema.gov/portal/home',
'displayLink': 'msc.fema.gov', 'formattedUrl':
'https://msc.fema.gov/portal/home', 'htmlFormattedUrl':
'https://<b>msc</b>.fema.gov/portal/home'}`

This will cause a KeyError at line 99
`snippets.append(result["snippet"])`.
1 year ago
Zach Schillaci b4eb043b81
Minor fix to SQLDatabaseChain doc (#826) 1 year ago
Raza Habib 9f8e05ffd4
Update __init__.py (#827)
Remove duplicate APIChain
1 year ago
Johanna Appel ebea40ce86
Add 'truncate' parameter for CohereEmbeddings (#798)
Currently, the 'truncate' parameter of the cohere API is not supported.

This means that by default, if trying to generate and embedding that is
too big, the call will just fail with an error (which is frustrating if
using this embedding source e.g. with GPT-Index, because it's hard to
handle it properly when generating a lot of embeddings).
With the parameter, one can decide to either truncate the START or END
of the text to fit the max token length and still generate an embedding
without throwing the error.

In this PR, I added this parameter to the class.

_Arguably, there should be a better way to handle this error, e.g. by
optionally calling a function or so that gets triggered when the token
limit is reached and can split the document or some such. Especially in
the use case with GPT-Index, its often hard to estimate the token counts
for each document and I'd rather sort out the troublemakers or simply
split them than interrupting the whole execution.
Thoughts?_

---------

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
1 year ago
Harrison Chase 7b4882a2f4
Harrison/tf embeddings (#817)
Co-authored-by: Ryohei Kuroki <10434946+yakigac@users.noreply.github.com>
1 year ago
Harrison Chase 5d4b6e4d4e
conversational agent fix (#818) 1 year ago
Harrison Chase 94ae126747
return sql intermediate steps (#792) 1 year ago
bair82 ae5695ad32
Update cohere.py (#795)
When stop tokens are set in Cohere LLM constructor, they are currently
not stripped from the response, and they should be stripped
1 year ago
Johanna Appel cacf4091c0
Fix documentation for 'model' parameter in CohereEmbeddings (#797)
Currently, the class parameter 'model_name' of the CohereEmbeddings
class is not supported, but 'model' is. The class documentation is
inconsistent with this, though, so I propose to either fix the
documentation (this PR right now) or fix the parameter.

It will create the following error:
```
ValidationError: 1 validation error for CohereEmbeddings
model_name
  extra fields not permitted (type=value_error.extra)
```
1 year ago
Jason Liu 54f9e4287f
Pass kwargs from initialize_agent into agent classmethod (#799)
# Problem
I noticed that in order to change the prefix of the prompt in the
`zero-shot-react-description` agent
we had to dig around to subset strings deep into the agent's attributes.
It requires the user to inspect a long chain of attributes and classes.

`initialize_agent -> AgentExecutor -> Agent -> LLMChain -> Prompt from
Agent.create_prompt`

``` python
agent = initialize_agent(
    tools=tools,
    llm=fake_llm,
    agent="zero-shot-react-description"
)
prompt_str = agent.agent.llm_chain.prompt.template
new_prompt_str = change_prefix(prompt_str)
agent.agent.llm_chain.prompt.template = new_prompt_str
```

# Implemented Solution

`initialize_agent` accepts `**kwargs` but passes it to `AgentExecutor`
but not `ZeroShotAgent`, by simply giving the kwargs to the agent class
methods we can support changing the prefix and suffix for one agent
while allowing future agents to take advantage of `initialize_agent`.


```
agent = initialize_agent(
    tools=tools,
    llm=fake_llm,
    agent="zero-shot-react-description",
    agent_kwargs={"prefix": prefix, "suffix": suffix}
)
```

To be fair, this was before finding docs around custom agents here:
https://langchain.readthedocs.io/en/latest/modules/agents/examples/custom_agent.html?highlight=custom%20#custom-llmchain
but i find that my use case just needed to change the prefix a little.


# Changes

* Pass kwargs to Agent class method
* Added a test to check suffix and prefix

---------

Co-authored-by: Jason Liu <jason@jxnl.coA>
1 year ago
Roy Williams 6086292252
Centralize logic for loading from LangChainHub, add ability to pin dependencies (#805)
It's generally considered to be a good practice to pin dependencies to
prevent surprise breakages when a new version of a dependency is
released. This commit adds the ability to pin dependencies when loading
from LangChainHub.

Centralizing this logic and using urllib fixes an issue identified by
some windows users highlighted in this video -
https://youtu.be/aJ6IQUh8MLQ?t=537
1 year ago
Harrison Chase b3916f74a7
enable mmr search (#807) 1 year ago
Harrison Chase f46f1d28af
expose memory key name (#808) 1 year ago
Harrison Chase 1ad7973cc6
Harrison/tool decorator (#790)
Co-authored-by: Jason Liu <jxnl@users.noreply.github.com>
Co-authored-by: Jason Liu <jason@jxnl.coA>
1 year ago
Harrison Chase 5f73d06502
Harrison/fix caching bug (#788)
Co-authored-by: thepok <richterthepok@yahoo.de>
1 year ago
Harrison Chase 248c297f1b
Sample row in table info for SQLDatabase (#769) (#782)
The agents usually benefit from understanding what the data looks like
to be able to filter effectively. Sending just one row in the table info
allows the agent to understand the data before querying and get better
results.

---------

Co-authored-by: Francisco Ingham <>

---------

Co-authored-by: Francisco Ingham <fpingham@gmail.com>
1 year ago
Francisco Ingham 213c2e33e5
Sql prompt improvement (#787)
Co-authored-by: Francisco Ingham <>
1 year ago
Harrison Chase 2e0219cac0
fixing bash util (#779) 1 year ago
Harrison Chase 966611bbfa
add model kwargs to handle stop token from cohere (#773) 1 year ago
Harrison Chase 7198a1cb22
Harrison/refactor agent (#781)
Co-authored-by: Amos Ng <me@amos.ng>
1 year ago
Harrison Chase 5bb2952860
Harrison/hf pipeline (#780)
Co-authored-by: Parth Chadha <parth29@gmail.com>
1 year ago
Harrison Chase c658f0aed3
Harrison/add to search (#778)
Co-authored-by: Enrico Shippole <enricoship@gmail.com>
1 year ago
Bill Kish 309d86e339
increase text-davinci-003 contextsize to 4097 (#748)
text-davinci-003 supports a context size of 4097 tokens so return 4097
instead of 4000 in modelname_to_contextsize() for text-davinci-003

Co-authored-by: Bill Kish <bill@cogniac.co>
1 year ago
Albert Ziegler 5198d6f541
Add missing verb (#768)
Mini drive-by PR:

I came across this sentence in a stack trace for an error I had, and it
confused me because the verb I missing. So I added the verb.
1 year ago
Harrison Chase a5d003f0c9
update notebook and make backwards compatible (#772) 1 year ago
Harrison Chase 924b7ecf89
pass kwargs and bump (#770) 1 year ago
Samantha Whitmore be7de427ca
Serialize all the chains! (#761)
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
1 year ago
Harrison Chase e2a7fed890
Harrison/serialize from llm and tools (#760) 1 year ago
Harrison Chase 12dc7f26cc
load agents from hub (#759) 1 year ago
Harrison Chase 7129f23511
output parser serialization (#758) 1 year ago
Harrison Chase f273c50d62
add loading chains from hub (#757) 1 year ago
Harrison Chase 1b89a438cf
(wip) Harrison/serialize agents (#725) 1 year ago
Harrison Chase cc70565886
add prompt type (#730) 1 year ago
Francisco Ingham 374e510f94
Upper bound on number of iterations (#754)
Some custom agents might continue to iterate until they find the correct
answer, getting stuck on loops that generate request after request and
are really expensive for the end user. Putting an upper bound for the
number of iterations
by default controls this and can be explicitly tweaked by the user if
necessary.

Co-authored-by: Francisco Ingham <>
1 year ago
Smit Shah 28efbb05bf
Add params to reduce K dynamically to reduce it below token limit (#739)
Referring to #687, I implemented the functionality to reduce K if it
exceeds the token limit.

Edit: I should have ran make lint locally. Also, this only applies to
`StuffDocumentChain`
1 year ago
Roy Williams d2f882158f
Add type information for crawler.py (#738)
Added type information to `crawler.py` to make it safer to use and
understand.
1 year ago
Ankush Gola 57609845df
add tracing support to langchain (#741)
* add implementations of `BaseCallbackHandler` to support tracing:
`SharedTracer` which is thread-safe and `Tracer` which is not and is
meant to be used locally.
* Tracers persist runs to locally running `langchain-server`

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
1 year ago
Harrison Chase 7f76a1189c
bump version to 0.0.70 (#744) 1 year ago
Harrison Chase 2ba1128095
Harrison/backwards compat (#740) 1 year ago
Francisco Ingham f9ddcb5705
Hotfix: distance_func and collection_name must not be in kwargs (#735)
If `distance_func` and `collection_name` are in `kwargs` they are sent
to the `QdrantClient` which results in an error being raised.

Co-authored-by: Francisco Ingham <>
1 year ago
Amos Ng fa6826e417
Fix sqlalchemy warnings when running tests (#733)
This has been bugging me when running my own tests that call langchain
methods :P
1 year ago
Harrison Chase 9194a8be89
add stop to stream (#729) 1 year ago
scadEfUr e3df8ab6dc
move hyde into chains (#728)
Co-authored-by: scadEfUr <>
1 year ago
Harrison Chase 0ffeabd14f
Harrison/serialize llm chain (#671) 1 year ago
Feynman Liang 2824f36401
Add namespace to Pinecone.from_index (#716)
Resolves https://github.com/hwchase17/langchain/issues/718
1 year ago
Kacper Łukawski d4f719c34b
Convert numpy arrays to lists in HuggingFaceEmbeddings (#714)
`SentenceTransformer` returns a NumPy array, not a `List[List[float]]`
or `List[float]` as specified in the interface of `Embeddings`. That PR
makes it consistent with the interface.
1 year ago
Kacper Łukawski 97c3544a1e
Hotfix: Qdrant.from_text embeddings (#713)
I'm providing a hotfix for Qdrant integration. Calculating a single
embedding to obtain the vector size was great idea. However, that change
introduced a bug trying to put only that single embedding into the
database. It's fixed. Right now all the embeddings will be pushed to
Qdrant.
1 year ago
Feynman Liang 3a38604f07
Fix typo (#705) 1 year ago
Harrison Chase fc4ad2db0f
langchain hub docs (#704)
Co-authored-by: scadEfUr <123224380+scadEfUr@users.noreply.github.com>
1 year ago
Scott Leibrand 34932dd211
remove legacy embedding model name (#703)
Now that OpenAI has deprecated all embeddings models except
text-embedding-ada-002, we should stop specifying a legacy embedding
model in the example. This will also avoid confusion from people (like
me) trying to specify model="text-embedding-ada-002" and having that
erroneously expanded to text-search-text-embedding-ada-002-query-001
1 year ago
scadEfUr 4aba0abeaa
added common prompt load method (#699)
Co-authored-by: scadEfUr
1 year ago
xloem 36b6b3cdf6
HuggingFacePipeline: Forward model_kwargs. (#696)
Since the tokenizer and model are constructed manually, model_kwargs
needs to
be passed to their constructors. Additionally, the pipeline has a
specific
named parameter to pass these with, which can provide forward
compatibility if
they are used for something other than tokenizer or model construction.
1 year ago
Harrison Chase 3a30e6daa8
Harrison/openai callback (#684) 1 year ago
Harrison Chase aef82f5d59
fix whitespace for conversational agent (#690) 1 year ago
Harrison Chase 86dbdb118b
Harrison/serpapi extra tools (#691)
Co-authored-by: Bruno Bornsztein <bruno.bornsztein@gmail.com>
1 year ago
Harrison Chase cbc146720b
verbose flag (#683) 1 year ago
Harrison Chase 27cef0870d
bump version to 0.0.67 (#689) 1 year ago
Samantha Whitmore 77e3d58922
ConversationEntityMemory: Chain which uses an entity extraction & sum… (#678)
…marization prompt to maintain a key-value store of memory information

cc @devennavani

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
1 year ago
dham e04b063ff4
add faiss local saving/loading (#676)
- This uses the faiss built-in `write_index` and `load_index` to save
and load faiss indexes locally
- Also fixes #674
- The save/load functions also use the faiss library, so I refactored
the dependency into a function
1 year ago
Harrison Chase e45f7e40e8
Harrison/few shot yaml (#682)
Co-authored-by: vintro <77507980+vintrocode@users.noreply.github.com>
1 year ago
Harrison Chase a2eeaf3d43
strip whitespace (#680) 1 year ago
Harrison Chase 3d41af0aba
Harrison/load tools kwargs (#681)
Co-authored-by: Bruno Bornsztein <bruno.bornsztein@gmail.com>
1 year ago
Harrison Chase 0b204d8c21
Harrison/quadrant (#665)
Co-authored-by: Kacper Łukawski <kacperlukawski@users.noreply.github.com>
1 year ago
Harrison Chase 983b73f47c
add search kwargs (#664) 1 year ago
vertinski 65f3a341b0
Prompt fix for empty intermediate steps in summarization (#660)
Adding quotation marks around {text} avoids generating empty or
completely random responses from OpenAI davinci-003. Empty or completely
unrelated intermediate responses in summarization messes up the final
result or makes it very inaccurate.
The error from OpenAI would be: "The model predicted a completion that
begins with a stop sequence, resulting in no output. Consider adjusting
your prompt or stop sequences."
This fix corrects the prompting for summarization chain. This works on
API too, the images are for demonstrative purposes.
This approach can be applied to other similar prompts too. 

Examples:

1) Without quotation marks
![Screenshot from 2023-01-20
07-18-19](https://user-images.githubusercontent.com/22897470/213624365-9dfc18f9-5f3f-45d2-abe1-56de67397e22.png)

2) With quotation marks
![Screenshot from 2023-01-20
07-18-35](https://user-images.githubusercontent.com/22897470/213624478-c958e742-a4a7-46fe-a163-eca6326d9dae.png)
1 year ago
iocuydi 69998b5fad
Add ids parameter for pinecone from_texts / add_texts (#659)
Allow optionally specifying a list of ids for pinecone rather than
having them randomly generated.
This also permits editing the embedding/metadata of existing pinecone
entries, by id.
1 year ago
Harrison Chase 54d7f1c933
fix caching (#658) 1 year ago
Harrison Chase d0fdc6da11
Harrison/bing wrapper (#656)
Co-authored-by: Enrico Shippole <henryshippole@gmail.com>
1 year ago
iocuydi 207e319a70
Add search_kwargs option for VectorDBQAWithSourcesChain (#657)
Allows for passing additional vectorstore params like namespace, etc. to
VectorDBQAWithSourcesChain

Example:
`chain = VectorDBQAWithSourcesChain.from_llm(OpenAI(temperature=0),
vectorstore=store, search_kwargs={"namespace": namespace})`
1 year ago
Harrison Chase 052c361031
pinecone docstring (#654) 1 year ago
Harrison Chase 95720adff5
Add documentation for custom prompts for Agents (#631) (#640)
- Added a comment interpreting regex for `ZeroShotAgent`
- Added a note to the `Custom Agent` notebook

Co-authored-by: Sam Ching <samuel@duolingo.com>
1 year ago
Harrison Chase 6be5f4e4c4
Harrison/sql db chain (#641)
Co-authored-by: Bruno Bornsztein <bruno.bornsztein@gmail.com>
1 year ago
Harrison Chase 4d4cff0530
Harrison/cohere experimental (#638)
Co-authored-by: inyourhead <44607279+xettrisomeman@users.noreply.github.com>
1 year ago
Sasmitha Manathunga 5c97f70bf1
Fix CohereError: embed is not an available endpoint on this model (#637)
Running the Cohere embeddings example from the docs:

```python
from langchain.embeddings import CohereEmbeddings
embeddings = CohereEmbeddings(cohere_api_key= cohere_api_key)

text = "This is a test document."
query_result = embeddings.embed_query(text)
doc_result = embeddings.embed_documents([text])
```

I get the error:

```bash
CohereError(message=res['message'], http_status=response.status_code, headers=response.headers)      
cohere.error.CohereError: embed is not an available endpoint on this model
```

This is because the `model` string is set to `medium` which is not
currently available.

From the Cohere docs:

> Currently available models are small and large (default)
1 year ago
Francisco Ingham b929fd9f59
Exclude reference to 'example' in api prompt (#629)
Co-authored-by: lesscomfortable <pancho_ingham@hotmail.com>
1 year ago
Harrison Chase 3d43906572
Harrison/new api chain (#623)
Co-authored-by: Francisco Ingham <fpingham@gmail.com>
Co-authored-by: lesscomfortable <pancho_ingham@hotmail.com>
1 year ago
Harrison Chase 1c71fadfdc
more complex sql chain (#619)
add a more complex sql chain that first subsets the necessary tables
1 year ago
Harrison Chase 49b3d6c78c
Harrison/wiki update (#622)
Co-authored-by: Rubens Mau <rubensmau@gmail.com>
1 year ago
Harrison Chase 1ac3319e45
simplify parsing of the final answer (#621) 1 year ago
Harrison Chase 2a54e73fec
bump version to 0063 (#616) 1 year ago
Nicolas 91d7fd20ae
feat: add custom prompt for QAEvalChain chain (#610)
I originally had only modified the `from_llm` to include the prompt but
I realized that if the prompt keys used on the custom prompt didn't
match the default prompt, it wouldn't work because of how `apply` works.

So I made some changes to the evaluate method to check if the prompt is
the default and if not, it will check if the input keys are the same as
the prompt key and update the inputs appropriately.

Let me know if there is a better way to do this.

Also added the custom prompt to the QA eval notebook.
1 year ago
Francisco Ingham 1787c473b8
Custom prompt option for llm_bash and api chains (#612)
Co-authored-by: lesscomfortable <pancho_ingham@hotmail.com>
1 year ago
Harrison Chase 67808bad0e
expose more serpapi parameters (#609) 1 year ago
Harrison Chase 9f9afbb6a8
add custom prompt for LLMMathChain and SQLDatabase chain (#605) 1 year ago
Smit Shah a87a2aacaa
[Minor Fix] Fix spacy TextSplitter init (#606) 1 year ago
babbldev b5eb91536a
Added filter argument to pinecone queries, fixes #600 (#601)
Added filter argument to similarity_search() and
similarity_search_with_score()

Co-authored-by: Sam Cartford (MBP) <cartford@hey.com>
1 year ago
Harrison Chase d574bf0a27
add documentation on how to load different chain types (#595) 1 year ago
Harrison Chase 8ab09c18a1
Return source documents option in VectorDBQA (#585) (#592)
Co-authored-by: lesscomfortable <pancho_ingham@hotmail.com>

Co-authored-by: Francisco Ingham <fpingham@gmail.com>
Co-authored-by: lesscomfortable <pancho_ingham@hotmail.com>
1 year ago
Harrison Chase 4c6c5f0391
wolfram alpha improvements (#591)
Co-authored-by: Nicolas <nicolascamara29@gmail.com>
1 year ago
Harrison Chase a5ee7de650
pinecone changes (#590)
Co-authored-by: Smit Shah <who828@gmail.com>
Co-authored-by: iocuydi <46613640+iocuydi@users.noreply.github.com>
1 year ago
Harrison Chase 3f2ea5c35e
Harrison/load from hub (#580) 1 year ago
Harrison Chase f74ce7a104
Harrison/combine memories (#582)
Signed-off-by: Diwank Singh Tomer <diwank.singh@gmail.com>
Co-authored-by: Diwank Singh Tomer <diwank.singh@gmail.com>
1 year ago
Harrison Chase 2aa08631cb
add similarity score method to faiss (#574)
adds `similarity_search_with_score` to faiss wrapper
1 year ago
Harrison Chase 5ba46f6d0c
Harrison/namespace pinecone (#581)
Co-authored-by: mmorzywolek <89693033+mmorzywolek@users.noreply.github.com>
1 year ago
Harrison Chase ffc7e04d44
Harrison/wolfram alpha (#579)
Co-authored-by: Nicolas <nicolascamara29@gmail.com>
1 year ago
Yong723 94c06c55e8
modify docstring (#569)
Sorry for the detail. this is a correction to the docstring.
1 year ago
Yong723 e1f3871a78
fix typo (#570)
I found a typo, which might be important for a conversational Agent.

if My PR is wrong, I am so sorry
1 year ago
Harrison Chase 1511606799
Harrison/fix splitting (#563)
fix issue where text splitting could possibly create empty docs
1 year ago
Harrison Chase 1192cc0767
smart text splitter (#530)
smart text splitter that iteratively tries different separators until it
works!
1 year ago
Harrison Chase 8dfad874a2
map rerank chain (#516)
add a chain that applies a prompt to all inputs and then returns not
only an answer but scores it

add examples for question answering and question answering with sources
1 year ago
Harrison Chase 823a44ef80
bump to 0058 (#556) 1 year ago
Benjamin 42d5d988fa
add openai logit bias (#553)
Add
[`logit_bias`](https://beta.openai.com/docs/api-reference/completions/create#completions/create-logit_bias)
params to OpenAI

See [here](https://beta.openai.com/tokenizer) for the tokenizer.

NB: I see that others (like Cohere) have the same parameter, but since I
don't have an access to it, I don't want to make a mistake.

---

Just to make sure the default "{}" works for openai:
```
from langchain.llms import OpenAI

OPENAI_API_KEY="XXX"

llm = OpenAI(openai_api_key=OPENAI_API_KEY)
llm.generate('Write "test":')

llm = OpenAI(openai_api_key=OPENAI_API_KEY, logit_bias={'9288': -100, '1332': -100, '14402': -100, '6208': -100})
llm.generate('Write "test":')
```
1 year ago
Harrison Chase 9833fcfe32
fix caching (#555) 1 year ago
Harrison Chase 74932f2516
RFC: conversational agent (#464)
Co-authored-by: Bruno Bornsztein <bruno.bornsztein@gmail.com>
1 year ago
Harrison Chase 330a5b42d4
fix map reduce chain (#550) 1 year ago
Diwank Singh Tomer ba0cbb4a41
Add finish reason to Generation for usage downstream (#526)
Add `finish_reason` to `Generation` as well as extend
`BaseOpenAI._generate` to include it in the output. This can be useful
for usage in downstream tasks when we need to filter for only
generations that finished because of `"stop"` for example. Maybe we
should add this to `LLMChain` as well?

For more details, see
https://beta.openai.com/docs/guides/completion/best-practices

Signed-off-by: Diwank Singh Tomer <diwank.singh@gmail.com>
1 year ago
Harrison Chase 4974f49bb7
add return_direct flag to tool (#537)
adds a return_direct flag to tools, which just returns the tool output
as the final output
1 year ago
Harrison Chase 0c2f7d8da1
changes to qa chain (#543) 1 year ago
Harrison Chase 5aefc2b7ce
add handling on error (#541) 1 year ago
Harrison Chase 1631981f84
Harrison/fix and test caching (#538) 1 year ago
Harrison Chase 73f7ebd9d1
Harrison/sqlalchemy cache store (#536)
Co-authored-by: Jason Gill <jasongill@gmail.com>
1 year ago
Yongtae723 f48ab642be
replace forbid into ignore (#539)
this is the second PR of #519.
in #519 I suggested deleting Extra.forbid.
I was very confused but I replaced Extra.forbid to Extra.ignore, which
is the default of pydantic.


Since the
[BaseLLM](4b7b8229de/langchain/llms/base.py (L20))
from which it is inherited is set in Extra.forbid, I wanted to avoid
having the Extra.forbid settings inherited by simply deleting it.
1 year ago
Yongtae723 4b7b8229de
add logger (#529)
As talking #519, I made 2 PRs.

this is the first PR for adding a logger.

I am concerned about the following two points and would appreciate your
opinion.

1. Since the logger is not formatted, the statement itself is output
like a print statement, and I thought it was difficult to understand
that it was a warning, so I put WARNING! at the beginning of the warning
statement. After the logger formatting is done properly, the word
WARNING can be repeated.
2. Statement `Please confirm that {field_name} is what you intended.`
can be replaced like `If {field_name} is intended parameters, enter it
to model_kwargs`
thank you!

Yongtae
1 year ago
Harrison Chase 9e04c34e20
Add BaseCallbackHandler and CallbackManager (#478)
Co-authored-by: Ankush Gola <9536492+agola11@users.noreply.github.com>
1 year ago
Harrison Chase 0db05b6725
Harrison/add human prefix (#520)
Co-authored-by: Andrew Huang <jhuang16888@gmail.com>
1 year ago
Harrison Chase 03f185bcd5
more robust handling for max iterations (#514)
add a `generate` method which makes one final forward pass through the
llm
1 year ago
Harrison Chase 40326c698c
unify argument name (#513)
unify names in map reduce and refine chains to just be
return_intermediate_steps

also unify the return key
1 year ago
Harrison Chase 985496f4be
Docs refactor (#480)
Big docs refactor! Motivation is to make it easier for people to find
resources they are looking for. To accomplish this, there are now three
main sections:

- Getting Started: steps for getting started, walking through most core
functionality
- Modules: these are different modules of functionality that langchain
provides. Each part here has a "getting started", "how to", "key
concepts" and "reference" section (except in a few select cases where it
didnt easily fit).
- Use Cases: this is to separate use cases (like summarization, question
answering, evaluation, etc) from the modules, and provide a different
entry point to the code base.

There is also a full reference section, as well as extra resources
(glossary, gallery, etc)

Co-authored-by: Shreya Rajpal <ShreyaR@users.noreply.github.com>
1 year ago
Keiji Kanazawa c5f0af9398
Minor docstring update (#507)
Update `model=` to `model_name=`.

No need to credit me for this 😄
1 year ago
Harrison Chase 0072686aab
Harrison/new search engine (#477)
Co-authored-by: Nicolas <nicolascamara29@gmail.com>
1 year ago
Harrison Chase 3e41ab7bff
check keys before using (#475) 1 year ago
Harrison Chase 0f1df0dc2c
bump to version 0.0.52 (#470) 1 year ago
Parth Chadha e88e66f982
Pass verbose argument to LLMChains when using *DocumentsChain (#458)
When using chains such as Summarization chain (`load_summarize_chain`),
the verbose flag wasn't propagated to the `LLMChain`.
1 year ago
Harrison Chase d0f194de73
add logic for agent stopping (#420) 1 year ago
Harrison Chase c65efd2986
fix llm math prompt (#466)
basically, it didnt realize that the question was over after the input
and would some times hallucinate more input
1 year ago
Harrison Chase 95157d0aad
Add schema property to sql database utility class (#448) (#462)
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>

Signed-off-by: Diwank Singh Tomer <diwank.singh@gmail.com>
Co-authored-by: Nuno Campos <nuno@boringbits.io>
Co-authored-by: Diwank Singh Tomer <diwank.singh@gmail.com>
1 year ago
Harrison Chase 2b84e5cda3
Harrison/fix memory and serp (#457)
Co-authored-by: Bruno Bornsztein <bruno.bornsztein@gmail.com>
1 year ago
Harrison Chase 55007e71be
add output key for memory (#443)
this allows chains that return multiple values to use memory
1 year ago
Harrison Chase 5208bb8c36
make tools editable (#445)
use dataclass instead of namedtuple, which makes it editable

add example in notebook
1 year ago
Harrison Chase 5cc6bf1a9c
fix regex parser (#446) 1 year ago
Ikko Ashimine f3c3288761
chore: fix typo in prompt.py (#447)
seperator -> separator
1 year ago
Harrison Chase 9ec01dfc16
regex output parser (#435) 1 year ago
Harrison Chase c994ce6b7f
Harrison/serp api imp (#444)
improve serp api

Co-authored-by: Bruno Bornsztein <bruno.bornsztein@gmail.com>
1 year ago
Harrison Chase ffe35c396c
unify return types across map-reduce and refine (#442) 1 year ago
Harrison Chase 0c5d3fd894
version 0.0.49 (#436) 1 year ago
Harrison Chase f8b605293f
Harrison/improve memory (#432)
add AI prefix

add new type of memory

Co-authored-by: Jason <chisanch@usc.edu>
1 year ago
Harrison Chase 150b67de10
Harrison/weaviate improvements (#433)
Co-authored-by: Connor Shorten <connorshorten300@gmail.com>
1 year ago
Harrison Chase b7566b5ec3
Harrison/return intermediate steps (#428) 1 year ago
Harrison Chase b50a56830d
Harrison/evaluation notebook (#426) 1 year ago
Harrison Chase 97f4000d3a
fix react docstore (#427) 1 year ago
Harrison Chase ee3b8e89b3
better parsing of agent output (#418) 1 year ago
Harrison Chase 0d7aa1ee99
Harrison/docs to index (#419)
Add method for going directly from documents to VectorStores

Update notebook to showcase this functionality
1 year ago
Harrison Chase 20959d8c36
check memory variables (#411)
can have multiple input keys, if some come from memory
1 year ago
altryne f990395211
Readme typos (#409)
I was honored by the twitter mention, so used PyCharm to try and... help
docs even a little bit.
Mostly typo-s and correct spellings. 

PyCharm really complains about "really good" being used all the time and
recommended alternative wordings haha
1 year ago
Shreya Rajpal f40b3ce347
Updated VectorDBQA docs to updated argument name (#405) 1 year ago
Samantha Whitmore 6bc8ae63ef
Add Redis cache implementation (#397)
I'm using a hash function for the key just to make sure its length
doesn't get out of hand, otherwise the implementation is quite similar.
1 year ago
mrbean 136f759492
Mrbean/support timeout (#398)
Add support for passing in a request timeout to the API
1 year ago
Harrison Chase 6b60c509ac
(WIP) add HyDE (#393)
Co-authored-by: cameronccohen <cameron.c.cohen@gmail.com>
Co-authored-by: Cameron Cohen <cameron.cohen@quantco.com>
1 year ago
Keiji Kanazawa 543db9c2df
Add Azure OpenAI LLM (#395)
Hi!  This PR adds support for the Azure OpenAI service to LangChain.

I've tried to follow the contributing guidelines.

Co-authored-by: Keiji Kanazawa <{ID}+{username}@users.noreply.github.com>
1 year ago
Harrison Chase c104d507bf
Harrison/improve data augmented generation docs (#390)
Co-authored-by: cameronccohen <cameron.c.cohen@gmail.com>
Co-authored-by: Cameron Cohen <cameron.cohen@quantco.com>
1 year ago
Harrison Chase 6be5747466
RFC: add cache override to LLM class (#379) 1 year ago
Harrison Chase 46c428234f
MMR example selector (#377)
implement max marginal relevance example selector
1 year ago
Harrison Chase ffed5e0056
Harrison/jinja formatter (#385)
Co-authored-by: Benjamin <BenderV@users.noreply.github.com>
1 year ago
mrbean fc66a32c6f
fix docstring (#383)
![Screenshot 2022-12-19 at 11 06 48
AM](https://user-images.githubusercontent.com/43734688/208468970-5cb9bafb-f535-486e-b41f-312a2f9ffffb.png)
1 year ago
Harrison Chase cf98f219f9
Harrison/tools exp (#372) 1 year ago
Harrison Chase e7b625fe03
fix text splitter (#375) 1 year ago
Harrison Chase 3474f39e21
Harrison/improve cache (#368)
make it so everything goes through generate, which removes the need for
two types of caches
1 year ago
Ankush Gola 8d0869c6d3
change run to use args and kwargs (#367)
Before, `run` was not able to be called with multiple arguments. This
expands the functionality.
1 year ago
Harrison Chase a7084ad6e4
Harrison/version 0040 (#366) 1 year ago
mrbean 50257fce59
Support Streaming Tokens from OpenAI (#364)
https://github.com/hwchase17/langchain/issues/363

@hwchase17 how much does this make you want to cry?
1 year ago
mrbean fe6695b9e7
Add HuggingFacePipeline LLM (#353)
https://github.com/hwchase17/langchain/issues/354

Add support for running your own HF pipeline locally. This would allow
you to get a lot more dynamic with what HF features and models you
support since you wouldn't be beholden to what is hosted in HF hub. You
could also do stuff with HF Optimum to quantize your models and stuff to
get pretty fast inference even running on a laptop.
1 year ago
Benjamin 85c1bd2cd0
add sqlalchemy generic cache (#361)
Created a generic SQLAlchemyCache class to plug any database supported
by SQAlchemy. (I am using Postgres).
I also based the class SQLiteCache class on this class SQLAlchemyCache.

As a side note, I'm questioning the need for two distinct class
LLMCache, FullLLMCache. Shouldn't we merge both ?
1 year ago
Harrison Chase 809a9f485f
Harrison/new version (#362) 1 year ago
Harrison Chase 750edfb440
add optional collapse prompt (#358) 1 year ago
Harrison Chase 2dd895d98c
add openai tokenizer (#355) 1 year ago
Harrison Chase c1b50b7b13
Harrison/map reduce merge (#344)
Co-authored-by: John Nay <JohnNay@users.noreply.github.com>
1 year ago
Harrison Chase ed143b598f
improve openai embeddings (#351)
add more formal support for explicitly specifying each model, but in a
backwards compatible way
1 year ago
Harrison Chase 78b31e5966
Harrison/cache (#343) 1 year ago
Harrison Chase 8cf62ce06e
Harrison/single input (#347)
allow passing of single input into chain

Co-authored-by: thepok <richterthepok@yahoo.de>
1 year ago
Harrison Chase e26b6f9c89
fix batching (#339) 1 year ago
Harrison Chase 996b5a3dfb
Harrison/llm final stuff (#332) 1 year ago
Harrison Chase 9bb7195085
Harrison/llm saving (#331)
Co-authored-by: Akash Samant <70665700+asamant21@users.noreply.github.com>
1 year ago
Harrison Chase 595cc1ae1a
RFC: more complete return (#313)
Co-authored-by: Andrew Williamson <awilliamson10@indstate.edu>
Co-authored-by: awilliamson10 <aw.williamson10@gmail.com>
1 year ago
Harrison Chase 8861770bd0
expose get_num_tokens method (#327) 1 year ago
thepok 137356dbec
-1 max token description for openai (#330) 1 year ago
Harrison Chase a7c8e37e77
Harrison/token counts (#311)
Co-authored-by: thepok <richterthepok@yahoo.de>
1 year ago
Shobith Alva 19a9fa16a9
Add `clear()` method for `Memory` (#305)
a simple helper to clear the buffer in `Conversation*Memory` classes
1 year ago
Harrison Chase e02d6b2288
beta: logger (#307) 1 year ago
Harrison Chase 36b4c58acf
expose more stuff (#306) 1 year ago
Harrison Chase 7827f0a844
fix typing (int -> float) (#308) 1 year ago
Harrison Chase 853894dd47
add moderation chain (#299) 1 year ago
andersenchen 5267ebce2d
Add LLMCheckerChain (#281)
Implementation of https://github.com/jagilley/fact-checker. Works pretty
well.

<img width="993" alt="Screenshot 2022-12-07 at 4 41 47 PM"
src="https://user-images.githubusercontent.com/101075607/206302751-356a19ff-d000-4798-9aee-9c38b7f532b9.png">

Verifying this manually:
1. "Only two kinds of egg-laying mammals are left on the planet
today—the duck-billed platypus and the echidna, or spiny anteater."
https://www.scientificamerican.com/article/extreme-monotremes/
2. "An [Echidna] egg weighs 1.5 to 2 grams (0.05 to 0.07
oz)[[19]](https://en.wikipedia.org/wiki/Echidna#cite_note-19) and is
about 1.4 centimetres (0.55 in) long."
https://en.wikipedia.org/wiki/Echidna#:~:text=sleep%20is%20suppressed.-,Reproduction,a%20reptile%2Dlike%20egg%20tooth.
3. "A [platypus] lays one to three (usually two) small, leathery eggs
(similar to those of reptiles), about 11 mm (7⁄16 in) in diameter and
slightly rounder than bird eggs."
https://en.wikipedia.org/wiki/Platypus#:~:text=It%20lays%20one%20to%20three,slightly%20rounder%20than%20bird%20eggs.
4. Therefore, an Echidna is the mammal that lays the biggest eggs.


cc @hwchase17
1 year ago
Samantha Whitmore b10be842f6
ChatGPT Clone: adding ConversationBufferWindowMemory to replicate vir… (#288)
…tual env example
1 year ago
Harrison Chase e2e501aa06
Harrison/version 0032 (#283) 1 year ago
Harrison Chase e9b1c8cdfa
Harrison/base combine doc chain (#264) 1 year ago
Harrison Chase 834b391792
update notebooks (#275) 1 year ago
Harrison Chase 3c1c7ba672
update branch name in gha (#274) 1 year ago