Commit Graph

1114 Commits

Author SHA1 Message Date
Zoltan Fedor
1b7cfd7222
Bugfix: Redis lrange() retrieves records in opposite order of inseerting (#2167)
The new functionality of Redis backend for chat message history
([see](https://github.com/hwchase17/langchain/pull/2122)) uses the Redis
list object to store messages and then uses the `lrange()` to retrieve
the list of messages
([see](https://github.com/hwchase17/langchain/blob/master/langchain/memory/chat_message_histories/redis.py#L50)).

Unfortunately this retrieves the messages as a list sorted in the
opposite order of how they were inserted - meaning the last inserted
message will be first in the retrieved list - which is not what we want.

This PR fixes that as it changes the order to match the order of
insertion.
2023-03-29 22:09:01 -07:00
7859245fc5
doc: more details on BaseOutputParser docstrings (#2171)
Co-authored-by: blob42 <spike@w530>
2023-03-29 22:07:05 -07:00
Ankush Gola
529a1f39b9
make tool verbosity override agent verbosity (#2173)
Currently, if a tool is set to verbose, an agent can override it by
passing in its own verbose flag. This is not ideal if we want to stream
back responses from agents, as we want the llm and tools to be sending
back events but nothing else. This also makes the behavior consistent
with ts.
2023-03-29 22:05:58 -07:00
Harrison Chase
f5a4bf0ce4
remove prep (#2136)
agents should be stateless or async stuff may not work
2023-03-29 14:38:21 -07:00
sergerdn
a0453ebcf5
docs: update docstrings in ElasticVectorSearch class (#2141)
This merge includes updated comments in the ElasticVectorSearch class to
provide information on how to connect to `Elasticsearch` instances that
require login credentials, including Elastic Cloud, without any
functional changes.

The `ElasticVectorSearch` class now inherits from the `ABC` abstract
base class, which does not break or change any functionality. This
allows for easy subclassing and creation of custom implementations in
the future or for any users, especially for me 😄

I confirm that before pushing these changes, I ran:
```bash
make format && make lint
```

To ensure that the new documentation is rendered correctly I ran
```bash
make docs_build
```

To ensure that the new documentation has no broken links, I ran a check
```bash
make docs_linkcheck
```


![Capture](https://user-images.githubusercontent.com/64213648/228541688-38f17c7b-b012-4678-86b9-4dd607469062.JPG)

Also take a look at https://github.com/hwchase17/langchain/issues/1865

P.S. Sorry for spamming you with force-pushes. In the future, I will be
smarter.
2023-03-29 16:20:29 -04:00
Ankush Gola
ffb7de34ca
Fix docstring (#2147) (#2160)
Somehow docstring was doubled. A minor fix for this

---------

Co-authored-by: Piotr Mazurek <piotr635@gmail.com>
2023-03-29 16:17:54 -04:00
Shota Terashita
09085c32e3
Add temperature to ChatOpenAI (#2152)
Just add `temperature` parameter to ChatOpenAI class.


https://python.langchain.com/en/latest/getting_started/getting_started.html#building-a-language-model-application-chat-models
There are descriptions like `chat = ChatOpenAI(temperature=0)` in the
documents, but it is confusing because it is not supported as an
explicit parameter.
2023-03-29 16:04:44 -04:00
Harrison Chase
8b91a21e37
fix memory docs (#2157) 2023-03-29 11:39:06 -07:00
Harrison Chase
55b52bad21
bump version to 126 (#2155) 2023-03-29 11:36:52 -07:00
Harrison Chase
b35260ed47
Harrison/memory base (#2122)
@3coins + @zoltan-fedor.... heres the pr + some minor changes i made.
thoguhts? can try to get it into tmrws release

---------

Co-authored-by: Zoltan Fedor <zoltan.0.fedor@gmail.com>
Co-authored-by: Piyush Jain <piyushjain@duck.com>
2023-03-29 10:10:09 -07:00
Patrick Storm
7bea3b302c
Add ability for GoogleDrive loader to load google sheets (#2135)
Currently only google documents and pdfs can be loaded from google
drive. This PR implements the latest recommended method for getting
google sheets including all tabs.

It currently parses the google sheet data the exact same way as the csv
loader - the only difference is that the gdrive sheets loader is not
using the `csv` library since the data is already in a list.
2023-03-29 07:56:04 -07:00
Chase Adams
b5449a866d
docs: tiny fix on docs verbiage (#2124)
Changed `RecursiveCharaterTextSplitter` =>
`RecursiveCharacterTextSplitter`. GH's diff doesn't handle the long
string well.
2023-03-28 22:56:29 -07:00
Jonathan Page
8441cbfc03
Add successful request count to OpenAI callback (#2128)
I've found it useful to track the number of successful requests to
OpenAI. This gives me a better sense of the efficiency of my prompts and
helps compare map_reduce/refine on a cheaper model vs. stuffing on a
more expensive model with higher capacity.
2023-03-28 22:56:17 -07:00
Sebastien Kerbrat
4ab66c4f52
Strip sitemap entries (#2132)
Loading this sitemap didn't work for me
https://www.alzallies.com/sitemap.xml

Changing this fixed it and it seems like a good idea to do it in
general.

Integration tests pass
2023-03-28 22:56:07 -07:00
Harrison Chase
27f80784d0
fix link (#2123) 2023-03-28 22:51:36 -07:00
031e32f331
searx: implement async + helper tool providing json results (#2129)
- implemented `arun` and `aresults`. Reuses aiosession if available.
- helper tools `SearxSearchRun` and `SearxSearchResults`
- update doc

Co-authored-by: blob42 <spike@w530>
2023-03-28 22:49:02 -07:00
Ankush Gola
ccee1aedd2
add async support for anthropic (#2114)
should not be merged in before
https://github.com/anthropics/anthropic-sdk-python/pull/11 gets released
2023-03-28 22:49:14 -04:00
Harrison Chase
e2c26909f2
Harrison/memory check (#2119)
Co-authored-by: JIAQIA <jqq1716@gmail.com>
2023-03-28 15:40:36 -07:00
Harrison Chase
3e879b47c1
Harrison/gitbook (#2044)
Co-authored-by: Irene López <45119610+ireneisdoomed@users.noreply.github.com>
2023-03-28 15:28:33 -07:00
Walter Beller-Morales
859502b16c
Fix issue#1712: Update BaseQAWithSourcesChain to handle space & newline after SOURCES: (#2118)
Fix the issue outlined in #1712 to ensure the `BaseQAWithSourcesChain`
can properly separate the sources from an agent response even when they
are delineated by a newline.

This will ensure the `BaseQAWithSourcesChain` can reliably handle both
of these agent outputs:

* `"This Agreement is governed by English law.\nSOURCES: 28-pl"` ->
`"This Agreement is governed by English law.\n`, `"28-pl"`
* `"This Agreement is governed by English law.\nSOURCES:\n28-pl"` ->
`"This Agreement is governed by English law.\n`, `"28-pl"`

I couldn't find any unit tests for this but please let me know if you'd
like me to add any test coverage.
2023-03-28 15:28:20 -07:00
Saurabh Misra
c33e055f17
Improve ConversationKGMemory and its function load_memory_variables (#1999)
1. Removed the `summaries` dictionary in favor of directly appending to
the summary_strings list, which avoids the unnecessary double-loop.
2. Simplified the logic for populating the `context` variable.

Co-created with GPT-4 @agihouse
2023-03-28 15:19:48 -07:00
Harrison Chase
a5bf8c9b9d
Harrison/aleph alpha embeddings (#2117)
Co-authored-by: Piotr Mazurek <piotr635@gmail.com>
Co-authored-by: PiotrMazurek <piotr.mazurek@aleph-alpha.com>
2023-03-28 15:18:03 -07:00
Nick
0874872dee
add token reduction to ConversationalRetrievalChain (#2075)
This worked for me, but I'm not sure if its the right way to approach
something like this, so I'm open to suggestions.

Adds class properties `reduce_k_below_max_tokens: bool` and
`max_tokens_limit: int` to the `ConversationalRetrievalChain`. The code
is basically copied from
[`RetreivalQAWithSourcesChain`](46d141c6cb/langchain/chains/qa_with_sources/retrieval.py (L24))
2023-03-28 15:07:31 -07:00
Alex Telon
ef25904ecb
Fixed 1 missing line in getting_started.md (#2107)
Seems like a copy paste error. The very next example does have this
line.

Please tell me if I missed something in the process and should have
created an issue or something first!
2023-03-28 15:03:28 -07:00
Francis Felici
9d6f649ba5
fix typo in docs (#2115)
simple typo
2023-03-28 15:03:17 -07:00
Harrison Chase
c58932e8fd
Harrison/better async (#2112)
Co-authored-by: Ammar Husain <ammo700@gmail.com>
2023-03-28 13:28:04 -07:00
Harrison Chase
6e85cbcce3
Harrison/unstructured validation (#2111)
Co-authored-by: kravetsmic <79907559+kravetsmic@users.noreply.github.com>
2023-03-28 13:27:52 -07:00
Tim Asp
b25dbcb5b3
add missing source field to pymupdf output (#2110)
To be consistent with other loaders for use with the `Sources` vector
workflows.
2023-03-28 13:22:05 -07:00
Harrison Chase
a554e94a1a
v125 (#2109)
for hackathon tonight!
2023-03-28 13:12:41 -07:00
Michael Gokhman
5f34dffedc
fix(llms): update default AI21 model to j2, as j1 being deprecated (#2108)
the j1-* models are marked as [Legacy] in the docs and are expected to
be deprecated in 2023-06-01 according to
https://docs.ai21.com/docs/jurassic-1-models-legacy

ensured `tests/integration_tests/llms/test_ai21.py` pass.

empirically observed that `j2-jumbo-instruct` works better the
`j2-jumbo` in various simple agent chains, as also expected given the
prompt templates are mostly zero shot.

Co-authored-by: Michael Gokhman <michaelg@ai21.com>
2023-03-28 13:07:05 -07:00
Honkware
aff33d52c5
Add OpenWeatherMap API Tool (#2083)
Added tool for OpenWeatherMap API
2023-03-28 12:02:14 -07:00
Charlie Holtz
f16c1fb6df
Add replicate take 2 (#2077)
This PR adds a replicate integration to langchain. 

It's an updated version of
https://github.com/hwchase17/langchain/pull/1993, but with updates to
match latest replicate-python code.
https://github.com/replicate/replicate-python.

---------

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
Co-authored-by: Zeke Sikelianos <zeke@sikelianos.com>
2023-03-28 11:56:57 -07:00
Harrison Chase
a9e1043673
bump version 124 (#2101) 2023-03-28 08:58:52 -07:00
Harrison Chase
f281033362
rm pandas dependency (#2102) 2023-03-28 08:38:19 -07:00
Harrison Chase
410bf37fb8
Harrison/big query (#2100)
Co-authored-by: lu-cashmoney <lucas.corley@gmail.com>
2023-03-28 08:17:22 -07:00
Harrison Chase
eff5eed719
Harrison/jina (#2043)
Co-authored-by: numb3r3 <wangfelix87@gmail.com>
Co-authored-by: felix-wang <35718120+numb3r3@users.noreply.github.com>
2023-03-28 08:16:17 -07:00
Klein Tahiraj
d0a56f47ee
add ConversationalChatAgent to agent.__init__ (fix #2093) (#2098)
As pointed out in #2093, ConversationalChatAgent was missing from
agent.__init__. This PR fixes that.
2023-03-28 08:14:21 -07:00
Harrison Chase
9e74df2404
Fix issue#1645: Parse llm_output even there's newline (#2092) (#2099)
Fix issue#1645: Parse either whitespace or newline after 'Action Input:'
in llm_output in mrkl agent.
Unittests added accordingly.

Co-authored-by: ₿ingnan.ΞTH <brillliantz@outlook.com>
2023-03-28 08:14:09 -07:00
Stéphane Busso
0bee219cb3
feat: Add Notion database document loader (#2056)
This PR adds Notion DB loader for langchain. 

It reads content from pages within a Notion Database. It uses the Notion
API to query the database and read the pages. It also reads the metadata
from the pages and stores it in the Document object.
2023-03-28 08:07:09 -07:00
Harrison Chase
923a7dde5a
Harrison/llama index loader (#2097)
Co-authored-by: Jerry Liu <jerryjliu98@gmail.com>
2023-03-28 08:06:27 -07:00
Harrison Chase
4cd5cf2e95
notebook for tokens (#2086) 2023-03-28 07:59:40 -07:00
33ebb05251
include the tool name for on_tool_end callback (#2000)
This is useful if you rely on the `on_tool_end` callback to detect which
tool has finished in a multi agents scenario.

For example, I'm working on a project where I consume the `on_tool_end`
event where the event could be emitted by many agents or tools. Right
now the only way to know which tool has finished would be set a marker
on the `on_tool_start` and catch it on `on_tool_end`.

I didn't want to break the signature of the function, but what would
have been cleaner would be to pass the same details as in
`on_tool_start`

Co-authored-by: blob42 <spike@w530>
2023-03-28 10:23:04 -04:00
Clark
e0331b55bb
fix(sql_database): related to #2020 (#2021)
Fixed https://github.com/hwchase17/langchain/issues/2020

Co-authored-by: qianjun.wqj <qianjun.wqj@alibaba-inc.com>
2023-03-27 23:45:50 -07:00
Harrison Chase
d5825bd3e8
Harrison/whatsapp loader (#2085)
Co-authored-by: Moshe <hello@moshemalka.me>
2023-03-27 23:43:45 -07:00
iocuydi
e8d9cbca3f
Add prompt and completion token tracking (#2080)
Tracking the breakdown of token usage is useful when using GPT-4, where
prompt and completion tokens are priced differently.
2023-03-27 23:41:25 -07:00
Michael Gokhman
b5020c7d9c
docs: fix promptlayer link typo (#2005)
tiny typo, just stumbled upon it when reading the docs

Co-authored-by: Michael Gokhman <michaelg@ai21.com>
2023-03-27 23:35:54 -07:00
Deepankar Mahapatro
5bea731fb4
docs(deployment): add langchain-serve (#2006)
Adds documentation to deploy Langchain Chains & Agents using Jina.

Repo: https://github.com/jina-ai/langchain-serve
2023-03-27 23:32:04 -07:00
Harrison Chase
0e3b0c827e
Harrison/ai plugin (#2084)
Co-authored-by: Xupeng (Tony) Tong <tongxupeng.cpu@gmail.com>
2023-03-27 23:31:53 -07:00
Harrison Chase
365669a7fd
Harrison/fix save context (#2082)
Co-authored-by: Saurabh Misra <misra.saurabh1@gmail.com>
2023-03-27 23:10:46 -07:00
b7f392fdd6
[agent_executor] convenience func: lookup tool by name (#2001)
A quick convenience function to lookup a tool by name

Co-authored-by: blob42 <spike@w530>
2023-03-27 23:10:34 -07:00