Compare commits

...

223 Commits

Author SHA1 Message Date
Bagatur
35c7c1f050 bump 317 (#11986) 2023-10-18 09:25:18 -07:00
Bagatur
122af2effe fix chroma from_texts bug (#11984) 2023-10-18 09:24:04 -07:00
Erick Friis
c149954cc5 Hub Runnable (#11946)
Adds `langchain.runnables.hub.HubRunnable` for pulling configurable
objects from the hub
2023-10-18 09:21:45 -07:00
Owen
9e24626e87 chore: remove duplicated export variables (#11962)
- **Description:** remove duplicated `__all__` variables
2023-10-18 12:08:50 -04:00
Nuno Campos
6bd9c1d2b3 Make prompt validation opt-in (#11973)
By default replace input_variables with the correct value

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-18 16:28:47 +01:00
Nuno Campos
9bc7e1851a Ensure dict() does not raise not implemented error, which should instead be raised in our custom method save() (#11970)
.dict() is a Pydantic method that cannot raise exceptions, as it is used
eg. in `__eq__`

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-18 16:28:33 +01:00
Nuno Campos
653cf56e0e Lint 2023-10-18 16:02:00 +01:00
Predrag Gruevski
debcf053eb Fix invalid escape sequence warnings by using raw strings for regexes. (#11943)
This code also generates warnings when our users' apps hit it, which is
annoying and doesn't look great. Let's fix it.
2023-10-18 10:55:17 -04:00
Nuno Campos
e4ae690244 Sort order 2023-10-18 15:42:13 +01:00
Bagatur
8e1b1db90d bearly api key docs (#11981) 2023-10-18 07:26:10 -07:00
Nuno Campos
b753bf3323 Make prompt validation opt-in
By default replace input_variables with the correct value
2023-10-18 10:46:22 +01:00
Nuno Campos
202acce0c9 Ensure dict() does not raise not implemented error, which should instead be raised in our custom method save() 2023-10-18 09:44:41 +01:00
Predrag Gruevski
392df7b2e3 Type hints on varargs and kwargs that take anything should be Any. (#11950)
Type hinting `*args` as `List[Any]` means that each positional argument
should be a list. Type hinting `**kwargs` as `Dict[str, Any]` means that
each keyword argument should be a dict of strings.

This is almost never what we actually wanted, and doesn't seem to be
what we want in any of the cases I'm replacing here.
2023-10-17 21:31:44 -04:00
volodymyr-memsql
7f17ce3742 SingleStoreDBChatMessageHistory: Add jupiter notebook with usage example (#11941)
The Docs folder changed its structure, and the notebook example for
SingleStoreDChatMessageHistory has not been copied to the new place due
to a merge conflict. Adding the example to the correct place.

Co-authored-by: Volodymyr Tkachuk <vtkachuk-ua@singlestore.com>
2023-10-17 21:31:19 -04:00
Eugene Yurtsev
908c7bf33e Add documentation to tools (#11938)
Add security notes to tools

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
2023-10-17 21:27:59 -04:00
Eugene Yurtsev
43dc669332 Update playwright documentation (#11949)
Add security note to playwright tool
2023-10-17 21:22:26 -04:00
Daniel Chalef
2beb767ae5 zep: Memory Retriever MMR Support & Docs Updates (#11954)
- Update Zep Memory and Retriever docstrings
- Zep Memory Retriever: Add support for native MMR
- Add MMR example to existing ZepRetriever Notebook

@baskaryan
2023-10-17 16:35:11 -07:00
William FH
a27fa9bf10 Use traceable context (#11896)
Example

```
from langchain.schema.runnable import RunnableLambda
from langsmith import traceable

chain = RunnableLambda(lambda x: x)

@traceable(run_type = "chain")
def my_traceable(a):
    chain.invoke(a)
my_traceable(5)
```

Would have a nested result.

This would NOT work for interleaving chains and traceables. E.g., things
like thiswould still not work well

```
from langchain.schema.runnable import RunnableLambda
from langsmith import traceable

@traceable()
def other_traceable(a):
    return a

def foo(x):
    return other_traceable(x)
    
chain = RunnableLambda(foo)

@traceable(run_type = "chain")
def my_traceable(a):
    chain.invoke(a)
my_traceable(5)
```
2023-10-17 15:10:20 -07:00
Predrag Gruevski
dcd0392423 Upgrade to newer black (23.10) and ruff (first 0.1.x!) versions. (#11944)
Minor lint dependency version upgrade to pick up latest functionality.

Ruff's new v0.1 version comes with lots of nice features, like
fix-safety guarantees and a preview mode for not-yet-stable features:
https://astral.sh/blog/ruff-v0.1.0
2023-10-17 17:24:51 -04:00
Trayan Azarov
1fd21ed21c Chroma batching (#11203)
- **Description:** Chroma >= 0.4.10 added support for batch sizes
validation of add/upsert. This batch size is dependent on the SQLite
limits of the target system and varies. In this change, for
Chroma>=0.4.10 batch splitting was added as the aforementioned
validation is starting to surface in the Chroma community (users using
LC)
 - **Issue:** N/A
 - **Dependencies:** N/A
 - **Tag maintainer:** @eyurtsev
 - **Twitter handle:** t_azarov
2023-10-17 13:59:42 -07:00
Guy Korland
9373b9c004 Add Graph interface (#11012)
Replace this entire comment with:
  - **Description:** Add a Graph interface
  - **Tag maintainer:** @baskaryan @hwchase17 
  - **Twitter handle:** @g_korland
2023-10-17 13:54:05 -07:00
DanielZzz
b647505280 feat: support ChatModels Qianfan QianfanChatEndpoint function_call (#11107)
- **Description:** 
* feature for `QianfanChatEndpoint` function_call ability, add
integration_test for it
    * add `model`, `endpoint` supported in calling params
    * add raw response in ChatModel Message
- **Issue:** 
    * #10867 
    * #11105 
    * #10215
- **Dependencies:** no
- **Tag maintainer:** @baskaryan 
- **Twitter handle:** no
2023-10-17 13:33:55 -07:00
M Bharat lal
67300567d3 GCSFileLoader retrieve blob custom metadata and append to document metadata (#11066)
- **Description:** GCSFileLoader retrieve blob's custom metadata and
append to document's metadata
- **Issue:** #9975,
- **Tag maintainer:** @baskaryan please review

Co-authored-by: b0l00ib <bharat.lal@walmart.com>
2023-10-17 12:17:59 -07:00
staoxiao
23c261ba57 Update bge_huggingface.ipynb (#8960)
- Description: Considering the similarity computation method of
[BGE](https://github.com/FlagOpen/FlagEmbedding) model is cosine
similarity, set normalize_embeddings to be True.
- Tag maintainer: @baskaryan

Co-authored-by: Erick Friis <erick@langchain.dev>
2023-10-17 11:58:29 -07:00
billytrend-cohere
f4742dce50 Add Cohere retrieval augmented generation to retrievers (#11483)
Add Cohere retrieval augmented generation to retrievers

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-17 11:51:04 -07:00
刘 方瑞
0a24ac7388 Revised notebook and add delete to MyScale vector store (#11848)
- **Description:** 
  - Add `.delete` to myscale vector store. 
  - Revised vector store notebooks
- **Tag maintainer:** @baskaryan 
- **Twitter handle:** @myscaledb @mpsk_liu
2023-10-17 11:42:21 -07:00
John Mai
3fb5e4d185 Add Baichuan chat model (#11923)
Description: A large language models developed by Baichuan Intelligent
Technology,https://www.baichuan-ai.com/home
Issue: None
Dependencies: None
Tag maintainer:
Twitter handle:
2023-10-17 11:30:57 -07:00
Eugene Yurtsev
9ecb7240a4 Add security note to recursive url loader (#11934)
Add security note to recursive loader
2023-10-17 13:41:43 -04:00
maks-operlejn-ds
42dcc502c7 Anonymizer small fixes (#11915) 2023-10-17 10:27:29 -07:00
Eugene Yurtsev
90e9ec6962 Sitemap specify default filter url (#11925)
Specify default filter URL in sitemap loader and add a security note

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
2023-10-17 13:19:27 -04:00
Bagatur
ba0d729961 bump 316 (#11928) 2023-10-17 09:47:57 -07:00
Eugene Yurtsev
83162649bb Add runnables to api reference (#11520)
Need to look at preview whether this works.
2023-10-17 11:46:08 -04:00
Eugene Yurtsev
12d7eaa0c2 Add security notices to toolkits (#11900)
This adds security notices to toolkits init, and to several toolkits.
We'll need to continue documenting the rest of the toolkits.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-17 11:45:09 -04:00
Eugene Yurtsev
5f4a697ce3 Add deprecation warnings (#11899)
Add deprecation warnings

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-17 10:59:38 -04:00
Nuno Campos
8b79cf9566 Add lock for using global config enum weak map (#11920)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-17 15:50:35 +01:00
Nuno Campos
2a8ded6c8c Export merge_configs function (#11916)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-17 15:36:11 +01:00
Nuno Campos
57a02929d5 Add validation for configurable keys passed to .with_config() (#11910)
- Fix some typing issues found while doing that

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-17 15:34:49 +01:00
Nuno Campos
42cd2ef329 Ensure that configurable fields with enums support deduplication (#11909)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-17 15:30:38 +01:00
Nuno Campos
778e7c526e Add comment 2023-10-17 15:29:39 +01:00
Nuno Campos
19319e1746 Allow configs with None values 2023-10-17 15:23:58 +01:00
Nuno Campos
b0d5882fe1 Export merge_configs function 2023-10-17 13:22:07 +01:00
Nuno Campos
12596b9a9b Add validation for configurable keys passed to .with_config()
- Fix some typing issues found while doing that
2023-10-17 08:50:31 +01:00
Nuno Campos
754aca794f remove print 2023-10-17 08:46:07 +01:00
Nuno Campos
cf448a6314 Ensure that configurable fields with enums support deduplication 2023-10-17 08:25:21 +01:00
Leonid Ganeline
31f264169d evaluation criteria (#11681)
the updated value was:
` Criteria.MISOGYNY: "Is the submission misogynistic? If so, respond Y."
`
The " If so, respond Y." should not be here. This sub-string is not
presented in any other criteria and should not be presented here.
I also added a synonym to "misogynistic" as it done in many other
criteria.
2023-10-16 21:05:08 -07:00
Lance Martin
eca8a5e5b8 Flesh out semi-structured cookbook (#11904) 2023-10-16 20:50:15 -07:00
Dmitry Tyumentsev
e8c1850369 Add YandexGPT LLM and Chat model (#11703)
**Description:** Introducing an ability to work with the
[YandexGPT](https://cloud.yandex.com/en/services/yandexgpt) language
model.
2023-10-16 20:30:07 -07:00
eryk-dsai
c4341463e8 Include information on the tools for creating gbnf grammar files in the llama-cpp notebook (#11764)
Hi,

I recently experimented with grammar-based sampling and discovered two
methods for speeding up the creation of gbnf grammar files:
1. [Online grammar generator
app](https://github.com/ggerganov/llama.cpp/discussions/2494) introduced
[here](https://github.com/ggerganov/llama.cpp/discussions/2494)
2.
[Script](https://github.com/ggerganov/llama.cpp/blob/master/examples/json-schema-to-grammar.py)
for parsing json schema to gbnf grammar

I believe it is a good idea to include the information that leads to
them in the `llama-cpp` notebook.

***

Codespell check fails but due to the unrelated script

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-16 20:28:32 -07:00
Bagatur
c15701eebf Revert "Add baichuan model" (#11901)
cc @cloudscool, apologies your PR wasn't actually passing CI
2023-10-16 20:01:12 -07:00
cloudscool
c1d811c4bc Add baichuan model 2023-10-16 19:27:35 -07:00
John Mai
0169d45ba8 Supported OutputFixingParser max_retries (#11754)
Description: Supported OutputFixingParser max_retries
 - max_retries: Maximum number of retries to parser.

Issue: None
Dependencies: None
Tag maintainer: @baskaryan
Twitter handle: @JohnMai95

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-16 19:25:47 -07:00
Leonid Ganeline
c87b5c209d docs safety update (#11789)
The current ToC on the index page and on navbar don't match. Page titles
and Titles in ToC doesn't match
Changes:
- made ToCs equal
- made titles equal
- updated some page formattings.
2023-10-16 19:14:21 -07:00
Surav Shrestha
321506fcd1 fix typos in cookbook/sales_agent_with_context.ipynb (#11790)
I have fixed some typos in file
`cookbook/sales_agent_with_context.ipynb`. I kindly request the repo
maintainers to review and merge it. Thanks!
2023-10-16 19:10:40 -07:00
Surav Shrestha
be04695554 fix typos in cookbook/Semi_structured_multi_modal_RAG_LLaMA2.ipynb (#11791)
I have fixed some typos in file
`cookbook/Semi_structured_multi_modal_RAG_LLaMA2.ipynb`. I kindly
request the repo maintainers to review and merge it. Thanks!
2023-10-16 19:09:20 -07:00
Surav Shrestha
e69218504b fix typos in cookbook/self_query_hotel_search.ipynb (#11792)
I have fixed some typos in file
`cookbook/self_query_hotel_search.ipynb`. I kindly request the repo
maintainers to review and merge it. Thanks!
2023-10-16 19:09:05 -07:00
Surav Shrestha
7f0145315a fix typos in cookbook/Semi_structured_and_multi_modal_RAG.ipynb (#11794)
I have fixed some typos in file
`cookbook/Semi_structured_and_multi_modal_RAG.ipynb`. I kindly request
the repo maintainers to review and merge it. Thanks!
2023-10-16 19:07:21 -07:00
Surav Shrestha
ab145d85ec fix typos in docs/docs/expression_language/cookbook/prompt_llm_parser.ipynb (#11796)
trasform -> transform
2023-10-16 19:07:03 -07:00
volodymyr-memsql
ff8e6981ff SingleStoreDBChatMessageHistory: Add singlestoredb support for ChatMessageHistory (#11705)
**Description**

- Added the `SingleStoreDBChatMessageHistory` class that inherits
`BaseChatMessageHistory` and allows to use of a SingleStoreDB database
as a storage for chat message history.
- Added integration test to check that everything works (requires
`singlestoredb` to be installed)
- Added notebook with usage example
- Removed custom retriever for SingleStoreDB vector store (as it is
useless)

---------

Co-authored-by: Volodymyr Tkachuk <vtkachuk-ua@singlestore.com>
2023-10-16 21:59:45 -04:00
Mohammad Mohtashim
634ccb8ccd test_stream_log_retriever Unit Test + Tool names fix (#11808)
## Description



| Tool         | Original Tool Name       |
|-----------------------------|---------------------------|
| open-meteo-api              | Open Meteo API            |
| news-api                    | News API                  |
| tmdb-api                    | TMDB API                  |
| podcast-api                 | Podcast API               |
| golden_query                | Golden Query              |
| dall-e-image-generator      | Dall-E Image Generator    |
| twilio                      | Text Message              |
| searx_search_results        | Searx Search Results      |
| dataforseo                  | DataForSeo Results JSON   |

When using these tools through `load_tools`, I encountered the following
validation error:

```console
openai.error.InvalidRequestError: 'TMDB API' does not match '^[a-zA-Z0-9_-]{1,64}$' - 'functions.0.name'
```

In order to avoid this error, I replaced spaces with hyphens in the tool
names:

| Tool           | Corrected Tool Name       |
|-----------------------------|---------------------------|
| open-meteo-api              | Open-Meteo-API            |
| news-api                    | News-API                  |
| tmdb-api                    | TMDB-API                  |
| podcast-api                 | Podcast-API               |
| golden_query                | Golden-Query              |
| dall-e-image-generator      | Dall-E-Image-Generator    |
| twilio                      | Text-Message              |
| searx_search_results        | Searx-Search-Results      |
| dataforseo                  | DataForSeo-Results-JSON   |

This correction resolved the validation error.

Additionally, a unit test,
`tests/unit_tests/schema/runnable/test_runnable.py::test_stream_log_retriever`,
was failing at random. Upon further investigation, I confirmed that the
failure was not related to the above-mentioned changes. The `stream_log`
variable was generating the order of logs in two ways at random The
reason for this behavior is unclear, but in the assertion, I included
both possible orders to account for this variability.
2023-10-16 18:46:19 -07:00
VAS
a1120e2685 Fixed a typo in bittensor.ipynb (#11821)
Fixed a typo : 

benifits -> benefits

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
2023-10-16 18:43:29 -07:00
VAS
2a6d4acc9d Fixed a typo in anyscale.ipynb (#11822)
Fixed a typo : 

"asyncrhonized" > "asynchronized"

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-16 18:43:15 -07:00
Predrag Gruevski
7c0f1bf23f Upgrade experimental package dependencies and use Poetry 1.6.1. (#11339)
Part of upgrading our CI to use Poetry 1.6.1.
2023-10-16 21:13:31 -04:00
Eugene Yurtsev
c2c0814a94 Add security notice to file management tool (#11878)
Add security notice to file management tool

---------

Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
2023-10-16 21:12:13 -04:00
zhaoshengbo
cb7e12f6ba Adapt to the latest version of Alibaba Cloud OpenSearch vector store API (#11849)
Hello Folks,

Alibaba Cloud OpenSearch has released a new version of the vector
storage engine, which has significantly improved performance compared to
the previous version. At the same time, the sdk has also undergone
changes, requiring adjustments alibaba opensearch vector store code to
adapt.

This PR includes:

Adapt to the latest version of Alibaba Cloud OpenSearch API.
More comprehensive unit testing.
Improve documentation.

I have read your contributing guidelines. And I have passed the tests
below

- [x] make format
- [x]  make lint
- [x]  make coverage
- [x]  make test

---------

Co-authored-by: zhaoshengbo <shengbo.zsb@alibaba-inc.com>
2023-10-16 18:07:24 -07:00
Javier Aranda Santos
96e3e06d50 Fix HuggingFace notebook link (#11863)
- **Description:** While reading the docs
(https://python.langchain.com/docs/integrations/providers/huggingface),
I noticed the notebook linked in
https://python.langchain.com/docs/use_cases/evaluation/huggingface_datasets.html
was giving back 404. I made a search in the docs to see whether it was
available, so this PR updates the link in the docs.
  - **Issue:** I haven't opened an issue for this change.
  - **Dependencies:** -
  - **Tag maintainer:** -,
  - **Twitter handle:** -

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-16 18:03:47 -07:00
standby24x7
40d188948e Fix spelling typos in learned_prompt_optimization.ipynb (#11862)
This patch fixes some spelling typo in
learned_prompt_optimization.ipynb.
It only changed messages, no logic changed.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
2023-10-16 18:01:48 -07:00
Lee
e669f9d731 Fix: Sitemap Document Loader Tests and Documentation (#11866)
**Description:**
While working on the Docusaurus site loader #9138, I noticed some
outdated docs and tests for the Sitemap Loader.

**Issue:** 
This is tangentially related to #6691 in reference to doc links. I plan
on digging in to a few of these issue when I find time next.
2023-10-16 17:42:10 -07:00
DJZevenbergen
8bb8c56f74 Fix missing word (#11868)
- **Description:** added one missing word to a doc, 
  - **Dependencies:** N/A
2023-10-16 17:10:31 -07:00
Nuno Campos
9fdf1059a4 Fix issues in runnable docs examples (#11883) 2023-10-16 17:08:28 -07:00
Jean-Louis Queguiner
8b697ff0ee feat(llm): add together.xyz as an LLM provider (#11892)
- **Description:** added together.xyz as an LLM provider, 
  - **Issues:** fix some linting issues
  - twitter handle @jilijeanlouis 

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-16 17:08:04 -07:00
Leonid Kuligin
d269dd2e2f added a multiturn search based on Vertex AI Search (#11885)
Replace this entire comment with:
- **Description:** Added a retriever based on multi-turn Vertex AI
Search
  - **Twitter handle:** lkuligin
2023-10-16 17:05:12 -07:00
Leonid Kuligin
38ed55245f added Vertex examples as attributes (#11890)
- **Description:** added examples to Vertex chat models as optional
class attributes, so that a model with examples can be used inside a
chain
  - **Twitter handle:** lkuligin
2023-10-16 16:55:45 -07:00
eryk-dsai
5019f59724 fix: more robust check whether the HF model is quantized (#11891)
Removes the check of `model.is_quantized` and adds more robust way of
checking for 4bit and 8bit quantization in the `huggingface_pipeline.py`
script. I had to make the original change on the outdated version of
`transformers`, because the models had this property before. Seems
redundant now.

Fixes: https://github.com/langchain-ai/langchain/issues/11809 and
https://github.com/langchain-ai/langchain/issues/11759
2023-10-16 16:54:20 -07:00
Bagatur
efa9ef75c0 add LCEL to retriever doc (#11888) 2023-10-16 16:44:25 -07:00
Bagatur
d62369f478 Add LCEL to chain doc (#11895) 2023-10-16 16:44:12 -07:00
Harrison Chase
52bf03d786 add how to configure documentation (#11889) 2023-10-16 16:01:47 -07:00
Eugene Yurtsev
3be76ee2fa Add security.md (#11881)
Add security markdown file
2023-10-16 17:41:21 -04:00
Leonid Ganeline
ea0982eede update CONTRIBUTING.md (#11872)
Adding description of the `View deployment` button on the PR page. This
nice feature was not documented.

---------

Co-authored-by: Erick Friis <erickfriis@gmail.com>
2023-10-16 14:21:36 -07:00
Lance Martin
18a4fdded6 Add deps and minor cleaning to cookbooks (#11886) 2023-10-16 13:37:51 -07:00
Bagatur
e3664272f0 Add LCEL to output parser doc (#11880) 2023-10-16 12:35:18 -07:00
Bagatur
049a0357e7 Add LCEL to prompt doc (#11875) 2023-10-16 11:34:31 -07:00
Eugene Yurtsev
210a48cfb5 Add security considerations (#11869)
Add security considerations to existing graph tools.
2023-10-16 12:23:48 -04:00
Lance Martin
201b7ce9af Update SQL cookbook (#11870) 2023-10-16 09:12:03 -07:00
Bagatur
25b1d65305 bump 315 (#11850) 2023-10-16 00:50:54 -07:00
Bagatur
ece22b6b6a Add LCEL to LLM intro (#11835) 2023-10-15 14:59:45 -07:00
Bagatur
ffa1b3a758 Add LCEL to chat model intro (#11834) 2023-10-15 14:59:36 -07:00
Nuno Campos
4321d192ea Use a less specific return type for | on Runnables (#11762)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-15 21:15:06 +01:00
Bagatur
6c5bb1b2e1 RM snippets (#11798) 2023-10-15 12:20:58 -07:00
Lance Martin
ccd1400423 Update multi-modal notebooks (#11827) 2023-10-15 09:00:07 -07:00
Lance Martin
8bf16d5275 LLaMA2 SQL Chat cookbook (#11685) 2023-10-15 08:54:09 -07:00
Harrison Chase
a506302772 bearly tool (#11812) 2023-10-14 16:03:58 -07:00
Harrison Chase
4a2f0c51a1 use get_llm_cache and set_llm_cache (#11741)
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-14 09:29:30 -07:00
Harrison Chase
f3ad22e64a pipe default key (#11788) 2023-10-14 08:39:23 +01:00
Bagatur
6e78dacd78 customize rtd build (#11797)
customize readthedocs config so that we can parallelize the api docs
build
2023-10-13 19:50:22 -07:00
Eugene Yurtsev
0d37b4c27d Add python,pandas,xorbits,spark agents to experimental (#11774)
See for contex
https://github.com/langchain-ai/langchain/discussions/11680
2023-10-13 17:36:44 -04:00
Bagatur
d6e34ca2ee fix recent docs integrations file loc (#11782) 2023-10-13 13:58:26 -07:00
Michael Feil
233a904f2e GradientLLM Docs update and model_id renaming. (#10963)
Related to #10800 

- Errors in the Docstring of GradientLLM / Gradient.ai LLM
- Renamed the `model_id` to `model` and adapting this in all tests.
Reason to so is to be in Sync with `GradientEmbeddings` and other LLM's.
- inmproving tests so they check the headers in the sent request.
- making the aiosession a private attribute in the docs, as in the
future `pip install gradientai` will be replacing aiosession.
- adding a example how to fine-tune on the Prompt Template as suggested
in #10800
2023-10-13 13:57:58 -07:00
David
6876b02c87 Move EverlyAI python notebook to the right location (#11779)
Hi,

After submitting https://github.com/langchain-ai/langchain/pull/11357,
we realized that the notebooks are moved to a new location. Sending a
new PR to update the doc.

---------

Co-authored-by: everly-studio <127131037+everly-studio@users.noreply.github.com>
2023-10-13 13:34:27 -07:00
Bagatur
1559ba4bfc fix upstash test import (#11781) 2023-10-13 13:31:36 -07:00
Leonid Kuligin
9f0a718198 added candidate_count for Vertex models (#11729)
- **Description:** added support for `candidate_count` parameter on
Vertex
2023-10-13 13:31:20 -07:00
David
9d200e6cbe Create ChatEverlyAI (#11357)
- Description: Adds the ChatEverlyAI class with llama-2 7b on [EverlyAI
Hosted
Endpoints](https://everlyai.xyz/)
- It inherits from ChatOpenAI and requires openai (probably unnecessary
but it made for a quick and easy implementation)

---------

Co-authored-by: everly-studio <127131037+everly-studio@users.noreply.github.com>
2023-10-13 12:25:11 -07:00
Hristo G
7fb25b4154 Add graceful fallback for ES vectorstore when content field is missing (#11726)
- **Description:**
- If the Elasticsearch field used for Langchain > Document.page_content
is missing because the specific document is
        somehow malformed fail gracefully.

  - **Tag maintainer:** 
    - @joemcelroy
2023-10-13 12:03:32 -07:00
Bagatur
f06fcde0d7 rm duplicate zilliz import (#11777) 2023-10-13 12:01:22 -07:00
Bagatur
a3330c4258 bump 314 (#11773) 2023-10-13 11:09:54 -07:00
Erick Friis
1861cc7100 General anthropic functions, steps towards experimental integration tests (#11727)
To match change in js here
https://github.com/langchain-ai/langchainjs/pull/2892

Some integration tests need a bit more work in experimental:
![Screenshot 2023-10-12 at 12 02 49
PM](https://github.com/langchain-ai/langchain/assets/9557659/262d7d22-c405-40e9-afef-669e8d585307)

Pretty sure the sqldatabase ones are an actual regression or change in
interface because it's returning a placeholder.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-13 09:48:24 -07:00
Lance Martin
98c8516ef1 Semi-structured and Multi-modal RAG cookbooks (#11582) 2023-10-13 08:45:54 -07:00
Nuno Campos
17c69678ab Revert "New add Baichuan Model" (#11761)
Reverts langchain-ai/langchain#11714

This has linting and formatting issues, plus it's added to chat models
folder but doesn't subclass Chat Model base class
2023-10-13 08:23:15 -07:00
cloudscool
56653c53aa New add Baichuan Model (#11714)
Motivation and Context
At present, the Baichuan Large Language Model is relatively popular and
efficient in performance. Due to widespread market recognition, this
model has been added to enhance the scalability of Langchain's ability
to access the big language model, so as to facilitate application access
and usage for interested users.

System Info
langchain: 0.0.295
python:3.8.3
IDE:vs code

Description
Add the following files:

1. Add baichuan_baichuaninc_endpoint.py in the
libs/langchain/langchain/chat_models
2. Modify the __init__.py file,which is located in the
libs/langchain/langchain/chat_models/__init__.py:
a. Add "from langchain.chat_models.baichuan_baichuaninc_endpoint import
BaichuanChatEndpoint"
    b. Add "BaichuanChatEndpoint" In the file's __ All__  method

Your contribution
I am willing to help implement this feature and submit a PR, but I would
appreciate guidance from the maintainers or community to ensure the
changes are made correctly and in line with the project's standards and
practices.
2023-10-12 23:04:28 -07:00
Shreyas S
694d768174 Minor fix (#11748)
changed > to over
2023-10-12 22:36:31 -07:00
Bagatur
8e6fa5f1d7 mv self-query docs to integrations (#11744) 2023-10-12 22:36:07 -07:00
Yang, Bo
9e1e0f54d2 Add TrainableLLM (#11721)
- **Description:** Add `TrainableLLM` for those LLM support fine-tuning
  - **Tag maintainer:** @hwchase17

This PR add training methods to `GradientLLM`

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-12 17:38:33 -07:00
Burak Yılmaz
63e516c2b0 Upstash redis integration (#10871)
- **Description:** Introduced Upstash provider with following wrappers:
UpstashRedisCache, UpstashRedisEntityStore,
UpstashRedisChatMessageHistory, UpstashRedisStore
  - **Issue:** -,
  - **Dependencies:** upstash-redis python package is needed,
  - **Tag maintainer:** @baskaryan 
  - **Twitter handle:** @BurakY744

---------

Co-authored-by: Burak Yılmaz <burakyilmaz@Buraks-MacBook-Pro.local>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-12 17:36:51 -07:00
Bagatur
a9db2b0b92 fix tongyi import (#11745) 2023-10-12 17:24:06 -07:00
Aaron Pham
6c61315067 fix(openllm): update with newer remote client implementation (#11740)
cc @baskaryan

---------

Signed-off-by: Aaron <29749331+aarnphm@users.noreply.github.com>
2023-10-12 17:01:18 -07:00
Richy Wang
11cdfe44af Implement Alibaba Tongyi chat model apis. (#10922)
Hi there
This PR is aim to implement chat model for Alibaba Tongyi LLM model. It
contains work below:
1.Implement ChatTongyi chat model in langchain.chat_models.tongyi. Note
this is different with tongyi llm model to another PR
https://github.com/langchain-ai/langchain/pull/10878.
For detail it implements _generate() and _stream() function in
ChatTongyi.
2. Add some examples in chat/tongyi.ipynb. 
3. Add integration test in chat_models/test_tongyi.py 

Note async completion for the Text API is not yet supported.
Dependencies: dashscope. It will be installed manually cause it is not
need by everyone.
2023-10-12 16:59:37 -07:00
Adam Demjen
008348ce71 Add ElasticsearchChatMessageHistory (#10932)
**Description**

This PR adds the `ElasticsearchChatMessageHistory` implementation that
stores chat message history in the configured
[Elasticsearch](https://www.elastic.co/elasticsearch/) deployment.

```python
from langchain.memory.chat_message_histories import ElasticsearchChatMessageHistory

history = ElasticsearchChatMessageHistory(
    es_url="https://my-elasticsearch-deployment-url:9200", index="chat-history-index", session_id="123"
)

history.add_ai_message("This is me, the AI")
history.add_user_message("This is me, the human")
```

**Dependencies**
- [elasticsearch client](https://elasticsearch-py.readthedocs.io/)
required

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-12 16:51:38 -07:00
Bagatur
d3a5090e12 mv semadb docs (#11743) 2023-10-12 16:31:09 -07:00
Bagatur
acdbdbddb1 clean up doc (#11742)
committed old doc in wrong place
2023-10-12 16:26:55 -07:00
Jonathan Soma
48cf978391 Allow placeholders in OpenAPI endpoints #2938 (#2940)
Use regex matches when checking endpoints instead of exact matches.
`{varname}` becomes `.*`

Fixes #2938

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-12 16:20:32 -07:00
Mateusz Kozak
e42a576cb2 update Qdrant documentation (#3105)
fix `from_documents` method usage for Qdrant in documentation as
previous example doesn't work

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-12 16:20:18 -07:00
Predrag Gruevski
9e32120cbb Deprecate direct access to globals like debug and verbose. (#11311)
Instead of accessing `langchain.debug`, `langchain.verbose`, or
`langchain.llm_cache`, please use the new getter/setter functions in
`langchain.globals`:
- `langchain.globals.set_debug()` and `langchain.globals.get_debug()`
- `langchain.globals.set_verbose()` and
`langchain.globals.get_verbose()`
- `langchain.globals.set_llm_cache()` and
`langchain.globals.get_llm_cache()`

Using the old globals directly will now raise a warning.

---------

Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
2023-10-12 15:48:04 -07:00
Bagatur
01b7b46908 reorder eval docs (#11738)
cc @leo-gan
2023-10-12 15:46:55 -07:00
Richard Adams
35965df20d Rspace doc loader (#11511)
**Description:**

Add a document loader for the RSpace Electronic Lab Notebook
(www.researchspace.com), so that scientific documents and research notes
can be easily pulled into Langchain pipelines.

**Issue**

This is an new contribution, rather than an issue fix.

 **Dependencies:** 
  
There are no new required dependencies.
In order to use the loader, clients will need to install rspace_client
SDK using `pip install rspace_client`

---------

Co-authored-by: richarda23 <richard.c.adams@infinityworks.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-12 15:05:38 -07:00
Ryan Zotti
9d1867c77f Update docs to specify Indexing-API-compatible vectorstores (#11581)
**Description:** Update Indexing API docs to specify vectorstores that
are compatible with the Indexing API. I add a unit test to remind
developers to update the documentation whenever they add or change a
vectorstore in a way that affects compatibility. For the unit test I
repurposed existing code from
[here](https://github.com/langchain-ai/langchain/blob/v0.0.311/libs/langchain/langchain/indexes/_api.py#L245-L257).

This is my first PR to an open source project. This is a trivially
simple PR whose main purpose is to make me more comfortable submitting
Langchain PRs. If this PR goes through I plan to submit PRs with more
substantive changes in the near future.

**Issue:** Resolves
[10482](https://github.com/langchain-ai/langchain/discussions/10482).

**Dependencies:** No new dependencies.

**Twitter handle:** None.
2023-10-12 15:17:44 -04:00
Richard Wang
6402c33299 Let Notion document loader support utf-8 and make it default. (#10613)
Use utf-8 encoding by default
2023-10-12 15:13:41 -04:00
Tomaz Bratanic
3759a34229 Add graph construction to neo4j docs (#11716)
Add graph construction section to Neo4j provider docs
2023-10-12 11:37:42 -07:00
Bagatur
bd74eba152 add azure openai sched tests (#11723) 2023-10-12 10:48:45 -07:00
Nuno Campos
b54727fbad Nc/why lcel (#11717)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-12 17:52:20 +01:00
Bagatur
9c0584be74 bump 313 (#11718) 2023-10-12 09:48:54 -07:00
Johnny Deuss
bb2ed4615c Fix typos (#11663) 2023-10-12 11:44:03 -04:00
sudranga
361f8e1bc6 Add MMR functionality to elasticsearch retriever (#11633)
Allows MMR functionality only for the case where we have access to the
embedding function. Also allows for users to request for fields from
elasticsearch store. These are added to the document metadata.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-12 08:42:32 -07:00
Dmitry Tyumentsev
ead9d5b55c Add yandex stt parser (#11435)
Description: Introducing an ability to load a transcription document of
audio file using [Yandex
SpeechKit](https://cloud.yandex.com/en-ru/services/speechkit)
Issue: None
Dependencies: yandex-speechkit
Tag maintainer: @rlancemartin, @eyurtsev
2023-10-12 08:42:03 -07:00
Janos Tolgyesi
15687a28d5 Use correct tokenizer for Bedrock/Anthropic LLMs (#11561)
**Description**

This PR implements the usage of the correct tokenizer in Bedrock LLMs,
if using anthropic models.

**Issue:** #11560

**Dependencies:** optional dependency on `anthropic` python library.

**Twitter handle:** jtolgyesi


---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-12 08:41:52 -07:00
kYLe
467b082c34 Modify Anyscale integration to work with Anyscale Endpoint (#11569)
**Description:** Modify Anyscale integration to work with [Anyscale
Endpoint](https://docs.endpoints.anyscale.com/)
and it supports invoke, async invoke, stream and async invoke features

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-12 08:41:25 -07:00
plpycoin
51193309ea Update readthedocs.py (#11110)
Only parse .html files
.svg .png favicon.ico will crash processing phase

---------

Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
2023-10-12 11:32:06 -04:00
Shreyas S
70a793ca9d Update zep_memory.ipynb (#11713)
fixed minor typos;
the your > your
on > upon
2023-10-12 10:41:19 -04:00
Surav Shrestha
e61b528c0e Fix typos in docs/docs/use_cases/question_answering/code_understandin… (#11710)
herarchy -> hierarchy
2023-10-12 10:17:23 -04:00
Surav Shrestha
f386ac3bef Fix typos in docs/docs/use_cases/tagging.ipynb (#11712)
funtion -> function
2023-10-12 10:17:10 -04:00
Surav Shrestha
ac73154005 Fix typos in docs/docs/use_cases/question_answering/conversational_re… (#11709)
neccessary -> necessary
2023-10-12 10:16:52 -04:00
Surav Shrestha
af9ce3c224 Fix typos in docs/docs/use_cases/chatbots.ipynb (#11707)
implemet -> implement
2023-10-12 10:16:34 -04:00
Surav Shrestha
77fcaa410a Fix typos in docs/docs/use_cases/extraction.ipynb (#11708)
This PR has a number of typos correction. I kindly request the repo
maintainers to review this PR and merge it.
2023-10-12 10:16:17 -04:00
Nuno Campos
ca9de26f2b Add callback function to RunnablePassthrough (#11564)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-12 15:10:16 +01:00
Nuno Campos
7f4734c0dd Add deploy command to repos generated by cli template (#11711)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-12 15:09:21 +01:00
Nuno Campos
1c0857b53e Fix default impl of aparse_result (#11702)
Should delegate to parse_result, not to aparse, as parse_result is a
method that some output parsers override

<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-12 14:13:59 +01:00
nuric
44da27c07b Add SemaDB VST wrapper (#11484)
- **Description**: Adding vectorstore wrapper for
[SemaDB](https://rapidapi.com/semafind-semadb/api/semadb).
- **Issue**: None
- **Dependencies**: None
- **Twitter handle**: semafind

Checks performed:
- [x] `make format`
- [x] `make lint`
- [x] `make test`
- [x] `make spell_check`
- [x] `make docs_build`

Documentation added:

- SemaDB vectorstore wrapper tutorial
2023-10-11 19:09:38 -07:00
hsuyuming
0b743f005b Feature/enhance huggingfacepipeline to handle different return type (#11394)
**Description:** Avoid huggingfacepipeline to truncate the response if
user setup return_full_text as False within huggingface pipeline.

**Dependencies:** : None
**Tag maintainer:**   Maybe @sam-h-bean ?

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 19:09:03 -07:00
Leonid Kuligin
2aba9ab47e Retriever based on GCP DocAI Warehouse (#11400)
- **Description:** implements a retriever on top of DocAI Warehouse (to
interact with existing enterprise documents)
  https://cloud.google.com/document-ai-warehouse?hl=en
  - **Issue:** new functionality
 
@baskaryan

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 19:08:53 -07:00
mvhensbergen
629d9b78fa Make example work during pydantic transition (#11498)
**Description:**

Make the example extraction code on
https://python.langchain.com/docs/use_cases/extraction work again by
importing the langchain.pydantic_v1 lib instead of the v2.

**Issue:**

Solves issue https://github.com/langchain-ai/langchain/issues/11468

Co-authored-by: Martin van Hensbergen <martin@mvhensbergen.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 18:44:47 -07:00
Erick Friis
a477ddda45 Langsmith in readme update (#11497) 2023-10-11 18:43:52 -07:00
Leonid Kuligin
9e81ab47be Added a better error description if processor name is wrong. (#11488)
Replace this entire comment with:
  - **Description:** added a better error description for this error
  - **Issue:** #11407 
  
  @baskaryan
2023-10-11 18:43:40 -07:00
Robert Yi
e75766b759 fix: incorrect arguments in clickhouse docstring (#11693)
fix docstring for clickhouse
2023-10-11 21:41:21 -04:00
Eugene Yurtsev
17b5090c18 Add type to Agent actions (#11682)
Add `type` to agent actions.
2023-10-11 21:33:24 -04:00
April
c14a8df2ee wrap confluence attachment processing with a try-except block (#11503)
Prevents document loading from erroring out when an attachment is not
found at the url.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 18:13:42 -07:00
Bagatur
17439daa6a add plan execute cookbook (#11690) 2023-10-11 18:03:13 -07:00
eajechiloae
4ba2c8ba75 Fix ClearML callback (#11472)
Handle different field names in dicts/dataframes, fixing the ClearML
callback.

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 17:09:02 -07:00
ElliotKetchup
7ae8b7f065 Llama doc: add 'language' to the response message (#11543)
- **Description:** add 'language' to the reponse message in the Llama
doc,
  - **Issue:** None,
  - **Dependencies:** None,
  - **Tag maintainer:** None,
  - **Twitter handle:** None

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 17:06:04 -07:00
Lawrence Wu
93bb19f69a Fix chains/loading.py error messages (#11688)
- **Description:** make the error messages consistent in
chains/loading.py
  - **Dependencies:** None
2023-10-11 17:05:42 -07:00
Harrison Chase
18ebce2032 fix tool async (#11689) 2023-10-11 16:40:23 -07:00
sudranga
9beb03e771 11474 (#11519)
No relevant documents may be found for a given question. In some use
cases, we could directly respond with a fixed message instead of doing
an LLM call with an empty context. This PR exposes this as an option:
response_if_no_docs_found.

---------

Co-authored-by: Sudharsan Rangarajan <sudranga@nile-global.com>
2023-10-11 16:30:15 -07:00
Shinya Maeda
1f7edcd08b doc: Fix documentation about n-gram overlap (#11549)
Fix the documentation in
https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/ngram_overlap.
It's currently declaring unrelated variables, for example, `examples`
local variable is declared twice and the first one is overwritten
immediately.
  - **Issue:** N/A
  - **Dependencies:** N/A
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
  - **Twitter handle:** @dosuken123
2023-10-11 16:26:56 -07:00
Joaquin Menendez
ef99b06362 feature: add metadata information into the embedding file before uplo… (#11553)
Replace this entire comment with:
- **Description:** In this modified version of the function, if the
metadatas parameter is not None, the function includes the corresponding
metadata in the JSON object for each text. This allows the metadata to
be stored alongside the text's embedding in the vector store.
  - 
  - **Issue:** #10924
  - **Dependencies:** None
  - **Tag maintainer:** @hwchase17
@agola11
  - **Twitter handle:** @MelliJoaco

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 16:05:13 -07:00
maks-operlejn-ds
3c83779661 Qa with anonymization (#11658)
Added demo for QA system with anonymization. It will be part of
LangChain's privacy webinar.

@hwchase17 @baskaryan @nfcampos 

Twitter handle: @MaksOpp

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 15:38:08 -07:00
Marcin Wątroba
51a3a86022 #11655 Add SQLAlchemyMd5Cache implementation (#11660)
- **Description:** Add SQLAlchemyMd5Cache implementation, 
  - **Issue:** the issue # #11655,
  - **Dependencies:** no deps,
  - **Tag maintainer:** @markowanga

---------

Co-authored-by: Marcin Wątroba <marcin.watroba@pwr.edu.pl>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 15:28:09 -07:00
Suresh Kumar Ponnusamy
70f7558db2 langchain-experimental: Add allow_list support in experimental/data_anonymizer (#11597)
- **Description:** Add allow_list support in langchain experimental
data-anonymizer package
  - **Issue:** no
  - **Dependencies:** no
  - **Tag maintainer:** @hwchase17
  - **Twitter handle:**
2023-10-11 14:50:41 -07:00
wemysschen
2363c02cf3 Bos loader (#11525)
**Description:**
Add  BaiduCloud BOS document loader.

---------

Co-authored-by: chenweixu01 <chenweixu01@baidu.com>
Co-authored-by: root <root@icoding-cwx.bcc-szzj.baidu.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 14:43:48 -07:00
Kwanghoon Choi
fbb82608cd Fixed a bug in reporting Python code validation (#11522)
- **Description:** fixed a bug in pal-chain when it reports Python
    code validation errors. When node.func does not have any ids, the
    original code tried to print node.func.id in raising ValueError.
- **Issue:** n/a,
- **Dependencies:** no dependencies,
- **Tag maintainer:** @hazzel-cn, @eyurtsev
- **Twitter handle:** @lazyswamp

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 14:34:28 -07:00
Harrison Chase
9f39c23a13 add input type for convo retrieval chain (#11679) 2023-10-11 17:13:48 -04:00
zhaozhiming
d5e762d328 fix: Change the docs of JSONAgentOutputParser (#11594)
I am merely making some minor adjustments to the function documentation.
I hope to provide a small assistance to LangChain.
- **Description:** Change the docs of JSONAgentOutputParser. It will be
`JSON` better,
  - **Issue:** no,
  - **Dependencies:** no,
  - **Tag maintainer:** @hwchase17,
  - **Twitter handle:** Not worth mentioning.
2023-10-11 14:05:53 -07:00
Shreyas S
3cd0827785 Update kay.ipynb (#11676)
Fixed title display
2023-10-11 14:02:11 -07:00
Vinay Kakade
dd0cd98861 Add support for ChatOpenAI models in Infino callback handler (#11608)
**Description:** This PR adds support for ChatOpenAI models in the
Infino callback handler. In particular, this PR implements
`on_chat_model_start` callback, so that ChatOpenAI models are supported.
With this change, Infino callback handler can be used to track latency,
errors, and prompt tokens for ChatOpenAI models too (in addition to the
support for OpenAI and other non-chat models it has today). The existing
example notebook is updated to show how to use this integration as well.
cc/ @naman-modi @savannahar68

**Issue:** https://github.com/langchain-ai/langchain/issues/11607 

**Dependencies:** None

**Tag maintainer:** @hwchase17 

**Twitter handle:** [@vkakade](https://twitter.com/vkakade)
2023-10-11 14:00:54 -07:00
Israel Ekpo
d0603c86b6 Add Support for Azure Cosmos DB MongoDB vCore Vector Store #11627 (#11632)
This PR adds support for the Azure Cosmos DB MongoDB vCore Vector Store

https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/

https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/vcore/vector-search

Summary:
- **Description:** added vector store integration for Azure Cosmos DB
MongoDB vCore Vector Store,
  - **Issue:** the issue # it fixes #11627,
  - **Dependencies:** pymongo dependency,
  - **Tag maintainer:** @hwchase17,
  - **Twitter handle:** @izzyacademy

---------

Co-authored-by: Israel Ekpo <israel.ekpo@gmail.com>
Co-authored-by: Israel Ekpo <44282278+izzyacademy@users.noreply.github.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-11 13:56:46 -07:00
Erick Friis
28ee6a7c12 Track ChatFireworks time to first_token (#11672) 2023-10-11 13:37:03 -07:00
Erick Friis
2c1e735403 Fix runnable docs link (#11675) 2023-10-11 13:11:23 -07:00
Eugene Yurtsev
539941281d Fix output types for BaseChatModel (#11670)
* Should use non chunked messages for Invoke/Batch
* After this PR, stream output type is not represented, do we want to
use the union?

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
2023-10-11 16:02:03 -04:00
Ikko Eltociear Ashimine
7d0dda7e41 Fix typo in baidu_qianfan_endpoint.ipynb (#11667)
enviroment -> environment
2023-10-11 16:01:18 -04:00
Bagatur
cf86447623 Start cookbook and move stuff from use cases (#11636) 2023-10-11 12:27:13 -07:00
Eugene Yurtsev
99adcdb1c9 Add dedicated type attribute to be used solely for serialization purposes (#11585)
Adds standard `type` field for all messages that will be
serialized/validated by pydantic.

* The presence of `type` makes it easier for developers consuming
schemas to write client code to serialize/deserialize.
* In LangServe `type` will be used for both validation and will appear
in the generated openapi specs
2023-10-11 15:06:42 -04:00
eryk-dsai
06d5971be9 Fix issue #10985 - Skip model.to(device) if it is instantiated with bitsandbytes config (#11009)
Preventing error caused by attempting to move the model that was already
loaded on the GPU using the Accelerate module to the same or another
device. It is not possible to load model with Accelerate/PEFT to CPU for
now

Addresses:
[#10985](https://github.com/langchain-ai/langchain/issues/10985)
2023-10-11 09:28:27 -07:00
Nuno Campos
64969bc8ae Add patch_config(configurable=) arg, make with_config(configurable=) merge it with existing (#11662)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-11 14:45:31 +01:00
Harrison Chase
ce0019b646 make utils conditional (#11646) 2023-10-11 06:11:32 +01:00
Harrison Chase
8f06085b24 make tools conditional (#11647) 2023-10-11 06:11:05 +01:00
Bassem Yacoube
5451b724fc Adds support for llama2 and fixes MPT-7b url (#11465)
- **Description:** This is an update to OctoAI LLM provider that adds
support for llama2 endpoints hosted on OctoAI and updates MPT-7b url
with the current one.
@baskaryan
Thanks!

---------

Co-authored-by: ML Wiz <bassemgeorgi@gmail.com>
2023-10-10 20:34:35 -07:00
Todd Kerpelman
0bff399af1 Make metadata from the url_selenium loader match that of the web_base loader (#11617)
**Description:** I noticed the metadata returned by the url_selenium
loader was missing several values included by the web_base loader. (The
former returned `{source: ...}`, the latter returned `{source: ...,
title: ..., description: ..., language: ...}`.) This change fixes it so
both loaders return all 4 key value pairs.

Files have been properly formatted and all tests are passing. Note,
however, that I am not much of a python expert, so that whole "Adding
the imports inside the code so that tests pass" thing seems weird to me.
Please LMK if I did anything wrong.
2023-10-10 20:32:45 -07:00
Tarun Thotakura
c9d4d53545 Fixed the assignment of custom_llm_provider argument (#11628)
- **Description:** Assigning the custom_llm_provider to the default
params function so that it will be passed to the litellm
- **Issue:** Even though the custom_llm_provider argument is being
defined it's not being assigned anywhere in the code and hence its not
being passed to litellm, therefore any litellm call which uses the
custom_llm_provider as required parameter is being failed. This
parameter is mainly used by litellm when we are doing inference via
Custom API server.
https://docs.litellm.ai/docs/providers/custom_openai_proxy
  - **Dependencies:** No dependencies are required

@krrishdholakia , @baskaryan

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-10 20:29:24 -07:00
Leonid Ganeline
db67ccb0bb docstrings cleanup (#11640)
Added missed docstrings. Some reformatting.
2023-10-10 19:56:47 -07:00
Bagatur
78b4c7d5a0 collapse sidebar peer items (#11639) 2023-10-10 19:56:21 -07:00
Bagatur
6dd7362a54 start cookbook (#11638) 2023-10-10 17:37:23 -07:00
Yang, Bo
3a82bd7bdb Use raise from statement so that users can find detailed error message (#11461)
- **Description:** Use `raise from` statement so that users can find
detailed error message
  - **Tag maintainer:** @baskaryan, @eyurtsev, @hwchase17
2023-10-10 17:25:23 -07:00
Nuno Campos
9a0ed75a95 Add configurable fields with options (#11601)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-10 22:17:22 +01:00
Bagatur
0ca8d4449c add ls guide redirect (#11623) 2023-10-10 12:58:04 -07:00
Bagatur
eedfddac2d Restructure docs (#11620) 2023-10-10 12:55:19 -07:00
Bagatur
7232e082de bump 312 (#11621) 2023-10-10 12:34:49 -07:00
Eugene Yurtsev
58220cda72 Remove LLM Bash and related bash utilities (#11619)
Deprecate LLMBash and related bash utilities
2023-10-10 14:54:09 -04:00
ElliotKetchup
683f4a93b9 Update azureml_chat_endpoint code exemple (#11602)
- **Description:** azureml_chat_endpoint code exemple now takes
endpoint_url and endpoint_api_key parameter into consideration,
  - **Issue:** None),
  - **Dependencies:** None,
  - **Tag maintainer:** None,
  - **Twitter handle:** @ElliotAlladaye
2023-10-10 10:27:28 -07:00
Yong woo Song
fca34eb122 Fix: invalid link to chat model in openai platform docs (#11609)
There is some invalid link in open ai platform
[docs](https://python.langchain.com/docs/integrations/platforms/openai).
So i fixed it to valid links.
- `/docs/integrations/chat_models/openai` ->
`/docs/integrations/chat/openai`
- `/docs/integrations/chat_models/azure_openai` ->
`/docs/integrations/chat/azure_chat_openai`

Thanks! ☺️
2023-10-10 10:22:39 -07:00
Shubham Kushwaha
49de862076 Arcee.ai LLM & Retriever integration (#11579)
- **Description:** This PR introduces a new LLM and Retriever API to
https://arcee.ai for the python client
  - **Issue:** implements the integrations as requested in #11578 ,
  - **Dependencies:** no dependencies are required,
  - **Tag maintainer:** @hwchase17
  - **Twitter handle:** shwooobham 


** `make format`, `make lint` and `make test` runs locally.**
```shell
=========== 1245 passed, 277 skipped, 20 warnings in 16.26s ===========
./scripts/check_pydantic.sh .
./scripts/check_imports.sh
poetry run ruff .
[ "." = "" ] || poetry run black . --check
All done!  🍰 
1818 files would be left unchanged.
[ "." = "" ] || poetry run mypy .
Success: no issues found in 1815 source files
[ "." = "" ] || poetry run black .
All done!  🍰 
1818 files left unchanged.
[ "." = "" ] || poetry run ruff --select I --fix .
poetry run codespell --toml pyproject.toml
poetry run codespell --toml pyproject.toml -w
```


**Contributions**
1. Arcee (langchain/llms), ArceeRetriever (langchain/retrievers),
ArceeWrapper (langchain/utilities)
2. docs for Arcee (llms/arcee.py) and
ArceeRetriever(retrievers/arcee.py)
3.

cc: @jacobsolawetz @ben-epstein

---------

Co-authored-by: Shubham <shubham@sORo.local>
2023-10-10 10:20:45 -07:00
Eugene Yurtsev
b6a2507794 Docs to use LLMSymbolicMath and LLMBash + utilities from experimental (#11614)
Update docs in lieu of:

https://github.com/langchain-ai/langchain/discussions/11352
2023-10-10 13:11:46 -04:00
Eugene Yurtsev
b56ca0c2a4 Deprecate LLMSymbolicMath from langchain core (#11615)
Deprecate LLMSymbolicMath from langchain core package.
2023-10-10 12:33:51 -04:00
Leonid Ganeline
59adeaddb3 docs: update dependents (#11502)
A regular update of dependents.
2023-10-10 09:31:23 -07:00
Eugene Yurtsev
c9bce5bbfb Add version to langchain_experimental (#11613)
Add version to langchain experimental
2023-10-10 11:17:41 -04:00
Predrag Gruevski
22abeb9f6c Disable loading jinja2 PromptTemplate from file. (#10252)
jinja2 templates are not sandboxed and are at risk for arbitrary code
execution. To mitigate this risk:
- We no longer support loading jinja2-formatted prompt template files.
- `PromptTemplate` with jinja2 may still be constructed manually, but
the class carries a security warning reminding the user to not pass
untrusted input into it.

Resolves #4394.
2023-10-10 11:15:42 -04:00
Bagatur
b642d00f9f rm slack from community.md (#11610) 2023-10-10 07:55:26 -07:00
Nuno Campos
c7c03d4709 Fix mutation bugs in callback manager configure (#11603)
<!-- Thank you for contributing to LangChain!

Replace this entire comment with:
  - **Description:** a description of the change, 
  - **Issue:** the issue # it fixes (if applicable),
  - **Dependencies:** any dependencies required for this change,
- **Tag maintainer:** for a quicker response, tag the relevant
maintainer (see below),
- **Twitter handle:** we announce bigger features on Twitter. If your PR
gets announced, and you'd like a mention, we'll gladly shout you out!

Please make sure your PR is passing linting and testing before
submitting. Run `make format`, `make lint` and `make test` to check this
locally.

See contribution guidelines for more information on how to write/run
tests, lint, etc:

https://github.com/langchain-ai/langchain/blob/master/.github/CONTRIBUTING.md

If you're adding a new integration, please include:
1. a test for the integration, preferably unit tests that do not rely on
network access,
2. an example notebook showing its use. It lives in `docs/extras`
directory.

If no one reviews your PR within a few days, please @-mention one of
@baskaryan, @eyurtsev, @hwchase17.
 -->
2023-10-10 14:50:18 +01:00
cccs-eric
e2a9072b80 Fix CohereRerank configuration (#11583)
**Description:** CohereRerank is missing `cohere_api_key` as a field and
since extras are forbidden, it is not possible to pass-in the key. The
only way is to use an env variable named `COHERE_API_KEY`.

For example, if trying to create a compressor like this:
```python
cohere_api_key = "......Cohere api key......"
compressor = CohereRerank(cohere_api_key=cohere_api_key)
```
you will get the following error:
```
  File "/langchain/.venv/lib/python3.10/site-packages/pydantic/v1/main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for CohereRerank
cohere_api_key
  extra fields not permitted (type=value_error.extra)
```
2023-10-09 23:26:34 -07:00
Anar
55fef4b64b implemented add files method in LLMRails (#11518)
This PR provides add files method with LLMRails. Implemented here are:

docs/extras/integrations/vectorstores/llm-rails.ipynb

---------

Co-authored-by: Anar Aliyev <aaliyev@mgmt.cloudnet.services>
2023-10-09 16:29:43 -07:00
unifyh
fd7f129f10 Docs: Fix broken line breaks in snippets (#11523)
**Description:**
This PR fix some code snippets that have raw `\n`'s instead of actual
line breaks.

**Issue:**
Currently some snippets look like this:

![image](https://github.com/langchain-ai/langchain/assets/18213435/355b4911-38e9-4ba4-8570-f928557b6c13)

Affected pages:
-
https://python.langchain.com/docs/integrations/providers/predictionguard#example-usage
-
https://python.langchain.com/docs/modules/agents/how_to/custom_llm_agent#set-up-environment
-
https://python.langchain.com/docs/modules/chains/foundational/llm_chain#get-started
-
https://python.langchain.com/docs/integrations/providers/shaleprotocol#how-to

**Tag maintainer:**
@hwchase17
2023-10-09 15:40:27 -07:00
Stephen Hankinson
316dddc7cd fix wording of query_sql_database_tool_description (#11530)
- **Description:** Fixes minor typo for the
query_sql_database_tool_description in the db toolkit
  - **Issue:** N/A
  - **Dependencies:** N/A
  - **Tag maintainer:** @nfcampos 
  - **Twitter handle:** N/A
2023-10-09 15:32:45 -07:00
Ash Vardanian
1acfe86353 Accelerating Math Utils with SimSIMD (#11566)
LangChain relies on NumPy to compute cosine distances, which becomes a
bottleneck with the growing dimensionality and number of embeddings. To
avoid this bottleneck, in our libraries at
[Unum](https://github.com/unum-cloud), we have created a specialized
package - [SimSIMD](https://github.com/ashvardanian/simsimd), that knows
how to use newer hardware capabilities. Compared to SciPy and NumPy, it
reaches 3x-200x performance for various data types. Since publication,
several LangChain users have asked me if I can integrate it into
LangChain to accelerate their workflows, so here I am 🤗

## Benchmarking

To conduct benchmarks locally, run this in your Jupyter:

```py
import numpy as np
import scipy as sp
import simsimd as simd
import timeit as tt

def cosine_similarity_np(X: np.ndarray, Y: np.ndarray) -> np.ndarray:
    X_norm = np.linalg.norm(X, axis=1)
    Y_norm = np.linalg.norm(Y, axis=1)
    with np.errstate(divide="ignore", invalid="ignore"):
        similarity = np.dot(X, Y.T) / np.outer(X_norm, Y_norm)
    similarity[np.isnan(similarity) | np.isinf(similarity)] = 0.0
    return similarity

def cosine_similarity_sp(X: np.ndarray, Y: np.ndarray) -> np.ndarray:
    return 1 - sp.spatial.distance.cdist(X, Y, metric='cosine')

def cosine_similarity_simd(X: np.ndarray, Y: np.ndarray) -> np.ndarray:
    return 1 - simd.cdist(X, Y, metric='cosine')

X = np.random.randn(1, 1536).astype(np.float32)
Y = np.random.randn(1, 1536).astype(np.float32)
repeat = 1000

print("NumPy: {:,.0f} ops/s, SciPy: {:,.0f} ops/s, SimSIMD: {:,.0f} ops/s".format(
    repeat / tt.timeit(lambda: cosine_similarity_np(X, Y), number=repeat),
    repeat / tt.timeit(lambda: cosine_similarity_sp(X, Y), number=repeat),
    repeat / tt.timeit(lambda: cosine_similarity_simd(X, Y), number=repeat),
))
```

## Results

I ran this on an M2 Pro Macbook for various data types and different
number of rows in `X` and reformatted the results as a table for
readability:

| Data Type | NumPy | SciPy | SimSIMD |
| :--- | ---: | ---: | ---: |
| `f32, 1` | 59,114 ops/s | 80,330 ops/s | 475,351 ops/s |
| `f16, 1` | 32,880 ops/s | 82,420 ops/s | 650,177 ops/s |
| `i8, 1` | 47,916 ops/s | 115,084 ops/s | 866,958 ops/s |
| `f32, 10` | 40,135 ops/s | 24,305 ops/s | 185,373 ops/s |
| `f16, 10` | 7,041 ops/s | 17,596 ops/s | 192,058 ops/s |
| `f16, 10` | 21,989 ops/s | 25,064 ops/s | 619,131 ops/s |
| `f32, 100` | 3,536 ops/s | 3,094 ops/s | 24,206 ops/s |
| `f16, 100` | 900 ops/s | 2,014 ops/s | 23,364 ops/s |
| `i8, 100` | 5,510 ops/s | 3,214 ops/s | 143,922 ops/s |

It's important to note that SimSIMD will underperform if both matrices
are huge.
That, however, seems to be an uncommon usage pattern for LangChain
users.
You can find a much more detailed performance report for different
hardware models here:

- [Apple M2
Pro](https://ashvardanian.com/posts/simsimd-faster-scipy/#appendix-1-performance-on-apple-m2-pro).
- [4th Gen Intel Xeon
Platinum](https://ashvardanian.com/posts/simsimd-faster-scipy/#appendix-2-performance-on-4th-gen-intel-xeon-platinum-8480).
- [AWS Graviton
3](https://ashvardanian.com/posts/simsimd-faster-scipy/#appendix-3-performance-on-aws-graviton-3).
  
## Additional Notes

1. Previous version used `X = np.array(X)`, to repackage lists of lists.
It's an anti-pattern, as it will use double-precision floating-point
numbers, which are slow on both CPUs and GPUs. I have replaced it with
`X = np.array(X, dtype=np.float32)`, but a more selective approach
should be discussed.
2. In numerical computations, it's recommended to explicitly define
tolerance levels, which were previously avoided in
`np.allclose(expected, actual)` calls. For now, I've set absolute
tolerance to distance computation errors as 0.01: `np.allclose(expected,
actual, atol=1e-2)`.

---

  - **Dependencies:** adds `simsimd` dependency
  - **Tag maintainer:** @hwchase17
  - **Twitter handle:** @ashvardanian

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-09 14:56:55 -07:00
benchello
5de64e6d60 Add option to specify metadata columns in CSV loader (#11576)
#### Description
This PR adds the option to specify additional metadata columns in the
CSVLoader beyond just `Source`.

The current CSV loader includes all columns in `page_content` and if we
want to have columns specified for `page_content` and `metadata` we have
to do something like the below.:
```
csv = pd.read_csv(
        "path_to_csv"
    ).to_dict("records")

documents = [
        Document(
            page_content=doc["content"],
            metadata={
                "last_modified_by": doc["last_modified_by"],
                "point_of_contact": doc["point_of_contact"],
            }
        ) for doc in csv
    ]
```
#### Usage
Example Usage:
```
csv_test  =  CSVLoader(
      file_path="path_to_csv", 
      metadata_columns=["last_modified_by", "point_of_contact"]
 )
```
Example CSV:
```
content, last_modified_by, point_of_contact
"hello world", "Person A", "Person B"
```

Example Result:
```
Document {
 page_content: "hello world"
 metadata: {
 row: '0',
 source: 'path_to_csv',
 last_modified_by: 'Person A',
 point_of_contact: 'Person B',
 }
```

---------

Co-authored-by: Ben Chello <bchello@dropbox.com>
Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-10-09 14:56:45 -07:00
Stephen Hankinson
447a523662 fix comments in output format (#11536)
- **Description:** Fixes the comments in the ConvoOutputParser. Because
the \\\\ is escaping a single \\, they render something like:
`"action_input": string \ The input to the action` in the prompt.
Changing this to \\\\\\\\ lets it escape two slashes so that it renders
a proper comment: `"action_input": string \\ The input to the action`
  - **Issue:** N/A
  - **Dependencies:** 
  - **Tag maintainer:** @hwchase17
  - **Twitter handle:**
2023-10-09 14:55:44 -07:00
Michael Landis
8e45f720a8 feat: add momento vector index as a vector store provider (#11567)
**Description**:

- Added Momento Vector Index (MVI) as a vector store provider. This
includes an implementation with docstrings, integration tests, a
notebook, and documentation on the docs pages.
- Updated the Momento dependency in pyproject.toml and the lock file to
enable access to MVI.
- Refactored the Momento cache and chat history session store to prefer
using "MOMENTO_API_KEY" over "MOMENTO_AUTH_TOKEN" for consistency with
MVI. This change is backwards compatible with the previous "auth_token"
variable usage. Updated the code and tests accordingly.

**Dependencies**:

- Updated Momento dependency in pyproject.toml.

**Testing**:

- Run the integration tests with a Momento API key. Get one at the
[Momento Console](https://console.gomomento.com) for free. MVI is
available in AWS us-west-2 with a superuser key.
- `MOMENTO_API_KEY=<your key> poetry run pytest
tests/integration_tests/vectorstores/test_momento_vector_index.py`

**Tag maintainer:**

@eyurtsev

**Twitter handle**:

Please mention @momentohq for this addition to langchain. With the
integration of Momento Vector Index, Momento caching, and session store,
Momento provides serverless support for the core langchain data needs.

Also mention @mlonml for the integration.
2023-10-09 14:02:59 -07:00
Eugene Yurtsev
ca2eed36b7 LangChain cli fix a few bugs (#11573)
Code was assuming that `git` and `poetry` exist. In addition, it was not
ignoring pycache files that get generated during run time
2023-10-09 13:30:16 -07:00
MSFTeegarden
923e9f9596 Add Azure Redis example (#11570)
**Description**
This PR adds an additional Example to the Redis integration
documentation. [The
example](https://learn.microsoft.com/azure/azure-cache-for-redis/cache-tutorial-vector-similarity)
is a step-by-step walkthrough of using Azure Cache for Redis and Azure
OpenAI for vector similarity search, using LangChain extensively
throughout.

**Issue**
Nothing specific, just adding an additional example.

**Dependencies**
None.

**Tag Maintainer**
Tagging @hwchase17 :)
2023-10-09 13:27:03 -07:00
Hugues Chocart
258ae1ba5f [LLMonitor Callback Handler]: Add error handling (#11563)
Wraps every callback handler method in error handlers to avoid breaking
users' programs when an error occurs inside the handler.

Thanks @valdo99 for the suggestion 🙂
2023-10-09 13:26:35 -07:00
Eugene Yurtsev
2aabfafe1e Module documentation for langchain runnables (#11550)
Add in code documentation for langchain runnables module.
2023-10-09 16:02:29 -04:00
Eugene Yurtsev
d8fa94e6fa RunnablePassthrough: In code documentation (#11552)
Add in code documentation for a runnable passthrough
2023-10-09 16:02:16 -04:00
Eugene Yurtsev
b42f218cfc RunnableLambda: Add in code docs (#11521)
Add in code docs for Runnable Lambda
2023-10-09 14:37:46 -04:00
maks-operlejn-ds
f64522fbaf Reset deanonymizer mapping (#11559)
@hwchase17 @baskaryan
2023-10-09 11:11:05 -07:00
maks-operlejn-ds
b14b65d62a Support all presidio entities (#11558)
https://microsoft.github.io/presidio/supported_entities/

@baskaryan @hwchase17
2023-10-09 11:10:46 -07:00
maks-operlejn-ds
4d62def9ff Better deanonymizer matching strategy (#11557)
@baskaryan, @hwchase17
2023-10-09 11:10:29 -07:00
Ash Vardanian
a992b9670d Fix: Missing DuckDuckGo package version (#11535)
[The `duckduckgo-search` v3.9.2 was removed from
PyPi](https://pypi.org/project/duckduckgo-search/#history). That breaks
the build.

  - **Description:** refreshes the Poetry dependency to v3.9.3
  - **Tag maintainer:** @baskaryan
  - **Twitter handle:** @ashvardanian
2023-10-09 10:55:46 -07:00
Bagatur
0a754fa286 redirect langsmith guides (#11562) 2023-10-09 09:58:03 -07:00
Nuno Campos
2f2a5fd582 Update Dockerfile.base (#11556) 2023-10-09 16:43:04 +01:00
1587 changed files with 34838 additions and 14514 deletions

View File

@@ -289,6 +289,13 @@ make docs_linkcheck
make api_docs_linkcheck
```
### Verify Documentation changes
After pushing documentation changes to the repository, you can preview and verify that the changes are
what you wanted by clicking the `View deployment` or `Visit Preview` buttons on the pull request `Conversation` page.
This will take you to a preview of the documentation changes.
This preview is created by [Vercel](https://vercel.com/docs/getting-started-with-vercel).
## 🏭 Release Process
As of now, LangChain has an ad hoc release process: releases are cut with high frequency by

View File

@@ -19,4 +19,4 @@ jobs:
run: |
# We should not encourage imports directly from main init file
# Expect for hub
git grep 'from langchain import' docs/{extras,docs_skeleton,snippets} | grep -vE 'from langchain import (hub)' && exit 1 || exit 0
git grep 'from langchain import' docs/{docs,snippets} | grep -vE 'from langchain import (hub)' && exit 1 || exit 0

View File

@@ -61,6 +61,10 @@ jobs:
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
AZURE_OPENAI_API_VERSION: ${{ secrets.AZURE_OPENAI_API_VERSION }}
AZURE_OPENAI_API_BASE: ${{ secrets.AZURE_OPENAI_API_BASE }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}
AZURE_OPENAI_DEPLOYMENT_NAME: ${{ secrets.AZURE_OPENAI_DEPLOYMENT_NAME }}
run: |
make scheduled_tests

7
.gitignore vendored
View File

@@ -174,6 +174,7 @@ docs/api_reference/*/
!docs/api_reference/_static/
!docs/api_reference/templates/
!docs/api_reference/themes/
docs/docs_skeleton/build
docs/docs_skeleton/node_modules
docs/docs_skeleton/yarn.lock
docs/docs/build
docs/docs/node_modules
docs/docs/yarn.lock
_dist

4
.gitmodules vendored
View File

@@ -1,4 +0,0 @@
[submodule "docs/_docs_skeleton"]
path = docs/_docs_skeleton
url = https://github.com/langchain-ai/langchain-shared-docs
branch = main

View File

@@ -9,9 +9,14 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
pre_build:
commands:
- python -mvirtualenv $READTHEDOCS_VIRTUALENV_PATH
- python -m pip install --upgrade --no-cache-dir pip setuptools
- python -m pip install --upgrade --no-cache-dir sphinx readthedocs-sphinx-ext
- python -m pip install --exists-action=w --no-cache-dir -r docs/api_reference/requirements.txt
- python docs/api_reference/create_api_rst.py
- cat docs/api_reference/conf.py
- python -m sphinx -T -E -b html -d _build/doctrees -c docs/api_reference docs/api_reference $READTHEDOCS_OUTPUT/html -j auto
# Build documentation in the docs/ directory with Sphinx
sphinx:

View File

@@ -15,10 +15,10 @@ docs_build:
docs/.local_build.sh
docs_clean:
rm -r docs/_dist
rm -r _dist
docs_linkcheck:
poetry run linkchecker docs/_dist/docs_skeleton/ --ignore-url node_modules
poetry run linkchecker _dist/docs/ --ignore-url node_modules
api_docs_build:
poetry run python docs/api_reference/create_api_rst.py
@@ -53,4 +53,4 @@ help:
@echo 'api_docs_linkcheck - run linkchecker on the API Reference documentation'
@echo 'spell_check - run codespell on the project'
@echo 'spell_fix - run codespell on the project and fix the errors'
@echo '-- TEST and LINT tasks are within libs/*/ per-package --'
@echo '-- TEST and LINT tasks are within libs/*/ per-package --'

View File

@@ -18,8 +18,9 @@
Looking for the JS/TS version? Check out [LangChain.js](https://github.com/langchain-ai/langchainjs).
**Production Support:** As you move your LangChains into production, we'd love to offer more hands-on support.
Fill out [this form](https://airtable.com/appwQzlErAS2qiP0L/shrGtGaVBVAz7NcV2) to share more about what you're building, and our team will get in touch.
To help you ship LangChain apps to production faster, check out [LangSmith](https://smith.langchain.com).
[LangSmith](https://smith.langchain.com) is a unified developer platform for building, testing, and monitoring LLM applications.
Fill out [this form](https://airtable.com/appwQzlErAS2qiP0L/shrGtGaVBVAz7NcV2) to get off the waitlist or speak with our sales team
## 🚨Breaking Changes for select chains (SQLDatabase) on 7/28/23

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -6,7 +6,7 @@
"source": [
"# Elasticsearch\n",
"\n",
"[![Open In Collab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/langchain-ai/langchain/blob/master/docs/docs_skeleton/docs/use_cases/qa_structured/integrations/elasticsearch.ipynb)\n",
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/langchain-ai/langchain/blob/master/docs/docs/use_cases/qa_structured/integrations/elasticsearch.ipynb)\n",
"\n",
"We can use LLMs to interact with Elasticsearch analytics databases in natural language.\n",
"\n",

View File

@@ -135,9 +135,9 @@
"outputs": [],
"source": [
"# We set this so we can see what exactly is going on\n",
"import langchain\n",
"from langchain.globals import set_verbose\n",
"\n",
"langchain.verbose = True"
"set_verbose(True)"
]
},
{
@@ -489,7 +489,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.10.1"
}
},
"nbformat": 4,

View File

@@ -57,7 +57,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Intialize the RL chain with provided defaults\n",
"##### Initialize the RL chain with provided defaults\n",
"\n",
"The prompt template which will be used to query the LLM needs to be defined.\n",
"It can be anything, but here `{meal}` is being used and is going to be replaced by one of the meals above, the RL chain will try to pick and inject the best meal\n"
@@ -212,9 +212,9 @@
"\n",
"It's important to note that while the RL model can make sophisticated selections, it doesn't inherently recognize concepts like \"vegetarian\" or understand that \"beef enchiladas\" aren't vegetarian-friendly. Instead, it leverages the LLM to ground its choices in common sense.\n",
"\n",
"The way the chain is learning that Tom prefers veggetarian meals is via an AutoSelectionScorer that is built into the chain. The scorer will call the LLM again and ask it to evaluate the selection (`ToSelectFrom`) using the information wrapped in (`BasedOn`).\n",
"The way the chain is learning that Tom prefers vegetarian meals is via an AutoSelectionScorer that is built into the chain. The scorer will call the LLM again and ask it to evaluate the selection (`ToSelectFrom`) using the information wrapped in (`BasedOn`).\n",
"\n",
"You can set `langchain.debug=True` if you want to see the details of the auto-scorer, but you can also define the scoring prompt yourself."
"You can set `set_debug(True)` if you want to see the details of the auto-scorer, but you can also define the scoring prompt yourself."
]
},
{
@@ -286,7 +286,7 @@
" print(event.to_select_from)\n",
"\n",
" # you can build a complex scoring function here\n",
" # it is prefereable that the score ranges between 0 and 1 but it is not enforced\n",
" # it is preferable that the score ranges between 0 and 1 but it is not enforced\n",
"\n",
" selected_meal = event.to_select_from[\"meal\"][event.selected.index]\n",
" print(f\"selected meal: {selected_meal}\")\n",
@@ -617,7 +617,7 @@
"\n",
"### other advanced featurization options\n",
"\n",
"Explictly numerical features can be provided with a colon separator:\n",
"Explicitly numerical features can be provided with a colon separator:\n",
"`age = rl_chain.BasedOn(\"age:32\")`\n",
"\n",
"`ToSelectFrom` can be a bit more complex if the scenario demands it, instead of being a list of strings it can be:\n",
@@ -672,7 +672,7 @@
"\n",
"```\n",
"\n",
"Internally the AutoSelectionScorer adjusted the scoring prompt to make sure that the llm scoring retured a single float.\n",
"Internally the AutoSelectionScorer adjusted the scoring prompt to make sure that the llm scoring returned a single float.\n",
"\n",
"However, if needed, a FULL scoring prompt can also be provided:\n"
]
@@ -730,7 +730,7 @@
"\u001b[32;1m\u001b[1;3m[llm/start]\u001b[0m \u001b[1m[1:chain:LLMChain > 2:llm:OpenAI] Entering LLM run with input:\n",
"\u001b[0m{\n",
" \"prompts\": [\n",
" \"Given ['Vegetarian', 'regular dairy is ok'] rank how good or bad this selection is ['Beef Enchiladas with Feta cheese. Mexican-Greek fusion', 'Chicken Flatbreads with red sauce. Italian-Mexican fusion', 'Veggie sweet potato quesadillas with vegan cheese', 'One-Pan Tortelonni bake with peppers and onions']\\n\\nIMPORANT: you MUST return a single number between -1 and 1, -1 being bad, 1 being good\"\n",
" \"Given ['Vegetarian', 'regular dairy is ok'] rank how good or bad this selection is ['Beef Enchiladas with Feta cheese. Mexican-Greek fusion', 'Chicken Flatbreads with red sauce. Italian-Mexican fusion', 'Veggie sweet potato quesadillas with vegan cheese', 'One-Pan Tortelonni bake with peppers and onions']\\n\\nIMPORTANT: you MUST return a single number between -1 and 1, -1 being bad, 1 being good\"\n",
" ]\n",
"}\n",
"\u001b[36;1m\u001b[1;3m[llm/end]\u001b[0m \u001b[1m[1:chain:LLMChain > 2:llm:OpenAI] [274ms] Exiting LLM run with output:\n",
@@ -778,14 +778,15 @@
],
"source": [
"from langchain.prompts.prompt import PromptTemplate\n",
"import langchain\n",
"langchain.debug = True\n",
"from langchain.globals import set_debug\n",
"\n",
"set_debug(True)\n",
"\n",
"REWARD_PROMPT_TEMPLATE = \"\"\"\n",
"\n",
"Given {preference} rank how good or bad this selection is {meal}\n",
"\n",
"IMPORANT: you MUST return a single number between -1 and 1, -1 being bad, 1 being good\n",
"IMPORTANT: you MUST return a single number between -1 and 1, -1 being bad, 1 being good\n",
"\n",
"\"\"\"\n",
"\n",
@@ -812,9 +813,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "poetry-venv",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "poetry-venv"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
@@ -826,7 +827,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
"version": "3.10.1"
}
},
"nbformat": 4,

View File

@@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 1,
"metadata": {},
"outputs": [
{
@@ -37,13 +37,13 @@
"'Hello World\\n'"
]
},
"execution_count": 9,
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from langchain.chains import LLMBashChain\n",
"from langchain_experimental.llm_bash.base import LLMBashChain\n",
"from langchain.llms import OpenAI\n",
"\n",
"llm = OpenAI(temperature=0)\n",
@@ -65,7 +65,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
@@ -98,7 +98,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 3,
"metadata": {},
"outputs": [
{
@@ -125,7 +125,7 @@
"'Hello World\\n'"
]
},
"execution_count": 11,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -149,7 +149,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -166,28 +166,24 @@
"cd ..\n",
"```\u001b[0m\n",
"Code: \u001b[33;1m\u001b[1;3m['ls', 'cd ..']\u001b[0m\n",
"Answer: \u001b[33;1m\u001b[1;3mapi.html\t\t\tllm_summarization_checker.html\n",
"constitutional_chain.html\tmoderation.html\n",
"llm_bash.html\t\t\topenai_openapi.yaml\n",
"llm_checker.html\t\topenapi.html\n",
"llm_math.html\t\t\tpal.html\n",
"llm_requests.html\t\tsqlite.html\u001b[0m\n",
"Answer: \u001b[33;1m\u001b[1;3mcpal.ipynb llm_bash.ipynb llm_symbolic_math.ipynb\n",
"index.mdx llm_math.ipynb pal.ipynb\u001b[0m\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'api.html\\t\\t\\tllm_summarization_checker.html\\r\\nconstitutional_chain.html\\tmoderation.html\\r\\nllm_bash.html\\t\\t\\topenai_openapi.yaml\\r\\nllm_checker.html\\t\\topenapi.html\\r\\nllm_math.html\\t\\t\\tpal.html\\r\\nllm_requests.html\\t\\tsqlite.html'"
"'cpal.ipynb llm_bash.ipynb llm_symbolic_math.ipynb\\r\\nindex.mdx llm_math.ipynb pal.ipynb'"
]
},
"execution_count": 12,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from langchain.utilities.bash import BashProcess\n",
"from langchain_experimental.llm_bash.bash import BashProcess\n",
"\n",
"\n",
"persistent_process = BashProcess(persistent=True)\n",
@@ -200,7 +196,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -217,18 +213,19 @@
"cd ..\n",
"```\u001b[0m\n",
"Code: \u001b[33;1m\u001b[1;3m['ls', 'cd ..']\u001b[0m\n",
"Answer: \u001b[33;1m\u001b[1;3mexamples\t\tgetting_started.html\tindex_examples\n",
"generic\t\t\thow_to_guides.rst\u001b[0m\n",
"Answer: \u001b[33;1m\u001b[1;3m_category_.yml\tdata_generation.ipynb\t\t self_check\n",
"agents\t\tgraph\n",
"code_writing\tlearned_prompt_optimization.ipynb\u001b[0m\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'examples\\t\\tgetting_started.html\\tindex_examples\\r\\ngeneric\\t\\t\\thow_to_guides.rst'"
"'_category_.yml\\tdata_generation.ipynb\\t\\t self_check\\r\\nagents\\t\\tgraph\\r\\ncode_writing\\tlearned_prompt_optimization.ipynb'"
]
},
"execution_count": 13,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -237,13 +234,6 @@
"# Run the same command again and see that the state is maintained between calls\n",
"bash_chain.run(text)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
@@ -262,7 +252,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.4"
}
},
"nbformat": 4,

View File

@@ -10,12 +10,12 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from langchain.llms import OpenAI\n",
"from langchain.chains.llm_symbolic_math.base import LLMSymbolicMathChain\n",
"from langchain_experimental.llm_symbolic_math.base import LLMSymbolicMathChain\n",
"\n",
"llm = OpenAI(temperature=0)\n",
"llm_symbolic_math = LLMSymbolicMathChain.from_llm(llm)"
@@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 23,
"execution_count": 4,
"metadata": {},
"outputs": [
{
@@ -39,7 +39,7 @@
"'Answer: exp(x)*sin(x) + exp(x)*cos(x)'"
]
},
"execution_count": 23,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -50,7 +50,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -59,7 +59,7 @@
"'Answer: exp(x)*sin(x)'"
]
},
"execution_count": 18,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -79,7 +79,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 6,
"metadata": {},
"outputs": [
{
@@ -88,7 +88,7 @@
"'Answer: Eq(y(t), C2*exp(-t) + (C1 + t/2)*exp(t))'"
]
},
"execution_count": 19,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -99,7 +99,7 @@
},
{
"cell_type": "code",
"execution_count": 21,
"execution_count": 7,
"metadata": {},
"outputs": [
{
@@ -108,7 +108,7 @@
"'Answer: {0, -sqrt(3)*I/3, sqrt(3)*I/3}'"
]
},
"execution_count": 21,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
@@ -119,7 +119,7 @@
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@@ -128,7 +128,7 @@
"'Answer: (3 - sqrt(7), -sqrt(7) - 2, 1 - sqrt(7)), (sqrt(7) + 3, -2 + sqrt(7), 1 + sqrt(7))'"
]
},
"execution_count": 22,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
@@ -140,9 +140,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "venv"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
@@ -154,9 +154,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}

View File

@@ -0,0 +1,252 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "0ddfef23-3c74-444c-81dd-6753722997fa",
"metadata": {},
"source": [
"# Plan-and-execute\n",
"\n",
"Plan-and-execute agents accomplish an objective by first planning what to do, then executing the sub tasks. This idea is largely inspired by [BabyAGI](https://github.com/yoheinakajima/babyagi) and then the [\"Plan-and-Solve\" paper](https://arxiv.org/abs/2305.04091).\n",
"\n",
"The planning is almost always done by an LLM.\n",
"\n",
"The execution is usually done by a separate agent (equipped with tools)."
]
},
{
"cell_type": "markdown",
"id": "a7ecb22a-7009-48ec-b14e-f0fa5aac1cd0",
"metadata": {},
"source": [
"## Imports"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "5fbbd4ee-bfe8-4a25-afe4-8d1a552a3d2e",
"metadata": {},
"outputs": [],
"source": [
"from langchain.agents.tools import Tool\n",
"from langchain.chains import LLMMathChain\n",
"from langchain.chat_models import ChatOpenAI\n",
"from langchain.llms import OpenAI\n",
"from langchain.utilities import DuckDuckGoSearchAPIWrapper\n",
"from langchain_experimental.plan_and_execute import PlanAndExecute, load_agent_executor, load_chat_planner"
]
},
{
"cell_type": "markdown",
"id": "e0e995e5-af9d-4988-bcd0-467a2a2e18cd",
"metadata": {},
"source": [
"## Tools"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "1d789f4e-54e3-4602-891a-f076e0ab9594",
"metadata": {},
"outputs": [],
"source": [
"search = DuckDuckGoSearchAPIWrapper()\n",
"llm = OpenAI(temperature=0)\n",
"llm_math_chain = LLMMathChain.from_llm(llm=llm, verbose=True)\n",
"tools = [\n",
" Tool(\n",
" name=\"Search\",\n",
" func=search.run,\n",
" description=\"useful for when you need to answer questions about current events\"\n",
" ),\n",
" Tool(\n",
" name=\"Calculator\",\n",
" func=llm_math_chain.run,\n",
" description=\"useful for when you need to answer questions about math\"\n",
" ),\n",
"]"
]
},
{
"cell_type": "markdown",
"id": "04dc6452-a07f-49f9-be12-95be1e2afccc",
"metadata": {},
"source": [
"## Planner, Executor, and Agent\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "d8f49c03-c804-458b-8122-c92b26c7b7dd",
"metadata": {},
"outputs": [],
"source": [
"model = ChatOpenAI(temperature=0)\n",
"planner = load_chat_planner(model)\n",
"executor = load_agent_executor(model, tools, verbose=True)\n",
"agent = PlanAndExecute(planner=planner, executor=executor)"
]
},
{
"cell_type": "markdown",
"id": "78ba03dd-0322-4927-b58d-a7e2027fdbb3",
"metadata": {},
"source": [
"## Run example"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "a57f7efe-7866-47a7-bce5-9c7b1047964e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mAction:\n",
"{\n",
" \"action\": \"Search\",\n",
" \"action_input\": \"current prime minister of the UK\"\n",
"}\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mAction:\n",
"```\n",
"{\n",
" \"action\": \"Search\",\n",
" \"action_input\": \"current prime minister of the UK\"\n",
"}\n",
"```\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mBottom right: Rishi Sunak is the current prime minister and the first non-white prime minister. The prime minister of the United Kingdom is the principal minister of the crown of His Majesty's Government, and the head of the British Cabinet. 3 min. British Prime Minister Rishi Sunak asserted his stance on gender identity in a speech Wednesday, stating it was \"common sense\" that \"a man is a man and a woman is a woman\" — a ... The former chancellor Rishi Sunak is the UK's new prime minister. Here's what you need to know about him. He won after running for the second time this year He lost to Liz Truss in September,... Isaeli Prime Minister Benjamin Netanyahu spoke with US President Joe Biden on Wednesday, the prime minister's office said in a statement. Netanyahu \"thanked the President for the powerful words of ... By Yasmeen Serhan/London Updated: October 25, 2022 12:56 PM EDT | Originally published: October 24, 2022 9:17 AM EDT S top me if you've heard this one before: After a tumultuous period of political...\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mThe search results indicate that Rishi Sunak is the current prime minister of the UK. However, it's important to note that this information may not be accurate or up to date.\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mAction:\n",
"```\n",
"{\n",
" \"action\": \"Search\",\n",
" \"action_input\": \"current age of the prime minister of the UK\"\n",
"}\n",
"```\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mHow old is Rishi Sunak? Mr Sunak was born on 12 May, 1980, making him 42 years old. He first became an MP in 2015, aged 34, and has served the constituency of Richmond in Yorkshire ever since. He... Prime Ministers' ages when they took office From oldest to youngest, the ages of the PMs were as follows: Winston Churchill - 65 years old James Callaghan - 64 years old Clement Attlee - 62 years... Anna Kaufman USA TODAY Just a few days after Liz Truss resigned as prime minister, the UK has a new prime minister. Truss, who lasted a mere 45 days in office, will be replaced by Rishi... Advertisement Rishi Sunak is the youngest British prime minister of modern times. Mr. Sunak is 42 and started out in Parliament in 2015. Rishi Sunak was appointed as chancellor of the Exchequer... The first prime minister of the current United Kingdom of Great Britain and Northern Ireland upon its effective creation in 1922 (when 26 Irish counties seceded and created the Irish Free State) was Bonar Law, [10] although the country was not renamed officially until 1927, when Stanley Baldwin was the serving prime minister. [11]\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mBased on the search results, it seems that Rishi Sunak is the current prime minister of the UK. However, I couldn't find any specific information about his age. Would you like me to search again for the current age of the prime minister?\n",
"\n",
"Action:\n",
"```\n",
"{\n",
" \"action\": \"Search\",\n",
" \"action_input\": \"age of Rishi Sunak\"\n",
"}\n",
"```\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mRishi Sunak is 42 years old, making him the youngest person to hold the office of prime minister in modern times. How tall is Rishi Sunak? How Old Is Rishi Sunak? Rishi Sunak was born on May 12, 1980, in Southampton, England. Parents and Nationality Sunak's parents were born to Indian-origin families in East Africa before... Born on May 12, 1980, Rishi is currently 42 years old. He has been a member of parliament since 2015 where he was an MP for Richmond and has served in roles including Chief Secretary to the Treasury and the Chancellor of Exchequer while Boris Johnson was PM. Family Murty, 42, is the daughter of the Indian billionaire NR Narayana Murthy, often described as the Bill Gates of India, who founded the software company Infosys. According to reports, his... Sunak became the first non-White person to lead the country and, at age 42, the youngest to take on the role in more than a century. Like most politicians, Sunak is revered by some and...\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mBased on the search results, Rishi Sunak is currently 42 years old. He was born on May 12, 1980.\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mThought: To calculate the age raised to the power of 0.43, I can use the calculator tool.\n",
"\n",
"Action:\n",
"```json\n",
"{\n",
" \"action\": \"Calculator\",\n",
" \"action_input\": \"42^0.43\"\n",
"}\n",
"```\u001b[0m\n",
"\n",
"\u001b[1m> Entering new LLMMathChain chain...\u001b[0m\n",
"42^0.43\u001b[32;1m\u001b[1;3m```text\n",
"42**0.43\n",
"```\n",
"...numexpr.evaluate(\"42**0.43\")...\n",
"\u001b[0m\n",
"Answer: \u001b[33;1m\u001b[1;3m4.9888126515157\u001b[0m\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"\n",
"Observation: \u001b[33;1m\u001b[1;3mAnswer: 4.9888126515157\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mThe age raised to the power of 0.43 is approximately 4.9888126515157.\n",
"\n",
"Final Answer:\n",
"```json\n",
"{\n",
" \"action\": \"Final Answer\",\n",
" \"action_input\": \"The age raised to the power of 0.43 is approximately 4.9888126515157.\"\n",
"}\n",
"```\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n",
"\n",
"\n",
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mAction:\n",
"```\n",
"{\n",
" \"action\": \"Final Answer\",\n",
" \"action_input\": \"The current prime minister of the UK is Rishi Sunak. His age raised to the power of 0.43 is approximately 4.9888126515157.\"\n",
"}\n",
"```\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'The current prime minister of the UK is Rishi Sunak. His age raised to the power of 0.43 is approximately 4.9888126515157.'"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"agent.run(\"Who is the current prime minister of the UK? What is their current age raised to the 0.43 power?\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0ef78a07-1a2a-46f8-9bc9-ae45f9bd706c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "poetry-venv",
"language": "python",
"name": "poetry-venv"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -12,7 +12,7 @@
"\n",
"SalesGPT is context-aware, which means it can understand what section of a sales conversation it is in and act accordingly.\n",
" \n",
"As such, this agent can have a natural sales conversation with a prospect and behaves based on the conversation stage. Hence, this notebook demonstrates how we can use AI to automate sales development representatives activites, such as outbound sales calls. \n",
"As such, this agent can have a natural sales conversation with a prospect and behaves based on the conversation stage. Hence, this notebook demonstrates how we can use AI to automate sales development representatives activities, such as outbound sales calls. \n",
"\n",
"Additionally, the AI Sales agent has access to tools, which allow it to interact with other systems.\n",
"\n",
@@ -66,7 +66,7 @@
"metadata": {},
"outputs": [],
"source": [
"# install aditional dependencies\n",
"# install additional dependencies\n",
"# ! pip install chromadb openai tiktoken"
]
},
@@ -150,7 +150,7 @@
" {conversation_history}\n",
" ===\n",
"\n",
" Now determine what should be the next immediate conversation stage for the agent in the sales conversation by selecting ony from the following options:\n",
" Now determine what should be the next immediate conversation stage for the agent in the sales conversation by selecting only from the following options:\n",
" 1. Introduction: Start the conversation by introducing yourself and your company. Be polite and respectful while keeping the tone of the conversation professional.\n",
" 2. Qualification: Qualify the prospect by confirming if they are the right person to talk to regarding your product/service. Ensure that they have the authority to make purchasing decisions.\n",
" 3. Value proposition: Briefly explain how your product/service can benefit the prospect. Focus on the unique selling points and value proposition of your product/service that sets it apart from competitors.\n",
@@ -277,7 +277,7 @@
" \n",
" ===\n",
"\n",
" Now determine what should be the next immediate conversation stage for the agent in the sales conversation by selecting ony from the following options:\n",
" Now determine what should be the next immediate conversation stage for the agent in the sales conversation by selecting only from the following options:\n",
" 1. Introduction: Start the conversation by introducing yourself and your company. Be polite and respectful while keeping the tone of the conversation professional.\n",
" 2. Qualification: Qualify the prospect by confirming if they are the right person to talk to regarding your product/service. Ensure that they have the authority to make purchasing decisions.\n",
" 3. Value proposition: Briefly explain how your product/service can benefit the prospect. Focus on the unique selling points and value proposition of your product/service that sets it apart from competitors.\n",

File diff suppressed because it is too large Load Diff

View File

@@ -17,7 +17,7 @@
"\n",
"Note that SmartLLMChains\n",
"- use more LLM passes (ie n+2 instead of just 1)\n",
"- only work then the underlying LLM has the capability for reflection, whicher smaller models often don't\n",
"- only work then the underlying LLM has the capability for reflection, which smaller models often don't\n",
"- only work with underlying models that return exactly 1 output, not multiple\n",
"\n",
"This notebook demonstrates how to use a SmartLLMChain."
@@ -241,7 +241,7 @@
" ideation_llm=ChatOpenAI(temperature=0.9, model_name=\"gpt-4\"),\n",
" llm=ChatOpenAI(\n",
" temperature=0, model_name=\"gpt-4\"\n",
" ), # will be used for critqiue and resolution as no specific llms are given\n",
" ), # will be used for critique and resolution as no specific llms are given\n",
" prompt=prompt,\n",
" n_ideas=3,\n",
" verbose=True,\n",

View File

@@ -1,3 +1,7 @@
# SQL Database Chain
This example demonstrates the use of the `SQLDatabaseChain` for answering questions over a SQL database.
Under the hood, LangChain uses SQLAlchemy to connect to SQL databases. The `SQLDatabaseChain` can therefore be used with any SQL dialect supported by SQLAlchemy, such as MS SQL, MySQL, MariaDB, PostgreSQL, Oracle SQL, [Databricks](/docs/ecosystem/integrations/databricks.html) and SQLite. Please refer to the SQLAlchemy documentation for more information about requirements for connecting to your database. For example, a connection to MySQL requires an appropriate connector such as PyMySQL. A URI for a MySQL connection might look like: `mysql+pymysql://user:pass@some_mysql_db_address/db_name`.
This demonstration uses SQLite and the example Chinook database.
@@ -31,8 +35,8 @@ db_chain.run("How many employees are there?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
How many employees are there?
SQLQuery:
@@ -71,8 +75,8 @@ db_chain.run("How many albums by Aerosmith?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
How many albums by Aerosmith?
SQLQuery:SELECT COUNT(*) FROM Album WHERE ArtistId = 3;
@@ -129,8 +133,8 @@ db_chain.run("How many employees are there in the foobar table?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
How many employees are there in the foobar table?
SQLQuery:SELECT COUNT(*) FROM Employee;
@@ -165,8 +169,8 @@ result["intermediate_steps"]
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
How many employees are there in the foobar table?
SQLQuery:SELECT COUNT(*) FROM Employee;
@@ -313,8 +317,8 @@ db_chain.run("What are some example tracks by composer Johann Sebastian Bach?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
What are some example tracks by composer Johann Sebastian Bach?
SQLQuery:SELECT Name FROM Track WHERE Composer = 'Johann Sebastian Bach' LIMIT 3
@@ -352,23 +356,23 @@ print(db.table_info)
<CodeOutputBlock lang="python">
```
CREATE TABLE "Track" (
"TrackId" INTEGER NOT NULL,
"Name" NVARCHAR(200) NOT NULL,
"AlbumId" INTEGER,
"MediaTypeId" INTEGER NOT NULL,
"GenreId" INTEGER,
"Composer" NVARCHAR(220),
"Milliseconds" INTEGER NOT NULL,
"Bytes" INTEGER,
"UnitPrice" NUMERIC(10, 2) NOT NULL,
PRIMARY KEY ("TrackId"),
FOREIGN KEY("MediaTypeId") REFERENCES "MediaType" ("MediaTypeId"),
FOREIGN KEY("GenreId") REFERENCES "Genre" ("GenreId"),
"TrackId" INTEGER NOT NULL,
"Name" NVARCHAR(200) NOT NULL,
"AlbumId" INTEGER,
"MediaTypeId" INTEGER NOT NULL,
"GenreId" INTEGER,
"Composer" NVARCHAR(220),
"Milliseconds" INTEGER NOT NULL,
"Bytes" INTEGER,
"UnitPrice" NUMERIC(10, 2) NOT NULL,
PRIMARY KEY ("TrackId"),
FOREIGN KEY("MediaTypeId") REFERENCES "MediaType" ("MediaTypeId"),
FOREIGN KEY("GenreId") REFERENCES "Genre" ("GenreId"),
FOREIGN KEY("AlbumId") REFERENCES "Album" ("AlbumId")
)
/*
2 rows from Track table:
TrackId Name AlbumId MediaTypeId GenreId Composer Milliseconds Bytes UnitPrice
@@ -392,8 +396,8 @@ db_chain.run("What are some example tracks by Bach?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
What are some example tracks by Bach?
SQLQuery:SELECT "Name", "Composer" FROM "Track" WHERE "Composer" LIKE '%Bach%' LIMIT 5
@@ -411,7 +415,7 @@ db_chain.run("What are some example tracks by Bach?")
</CodeOutputBlock>
### Custom Table Info
In some cases, it can be useful to provide custom table information instead of using the automatically generated table definitions and the first `sample_rows_in_table_info` sample rows. For example, if you know that the first few rows of a table are uninformative, it could help to manually provide example rows that are more diverse or provide more information to the model. It is also possible to limit the columns that will be visible to the model if there are unnecessary columns.
In some cases, it can be useful to provide custom table information instead of using the automatically generated table definitions and the first `sample_rows_in_table_info` sample rows. For example, if you know that the first few rows of a table are uninformative, it could help to manually provide example rows that are more diverse or provide more information to the model. It is also possible to limit the columns that will be visible to the model if there are unnecessary columns.
This information can be provided as a dictionary with table names as the keys and table information as the values. For example, let's provide a custom definition and sample rows for the Track table with only a few columns:
@@ -419,7 +423,7 @@ This information can be provided as a dictionary with table names as the keys an
```python
custom_table_info = {
"Track": """CREATE TABLE Track (
"TrackId" INTEGER NOT NULL,
"TrackId" INTEGER NOT NULL,
"Name" NVARCHAR(200) NOT NULL,
"Composer" NVARCHAR(220),
PRIMARY KEY ("TrackId")
@@ -448,22 +452,22 @@ print(db.table_info)
<CodeOutputBlock lang="python">
```
CREATE TABLE "Playlist" (
"PlaylistId" INTEGER NOT NULL,
"Name" NVARCHAR(120),
"PlaylistId" INTEGER NOT NULL,
"Name" NVARCHAR(120),
PRIMARY KEY ("PlaylistId")
)
/*
2 rows from Playlist table:
PlaylistId Name
1 Music
2 Movies
*/
CREATE TABLE Track (
"TrackId" INTEGER NOT NULL,
"TrackId" INTEGER NOT NULL,
"Name" NVARCHAR(200) NOT NULL,
"Composer" NVARCHAR(220),
PRIMARY KEY ("TrackId")
@@ -490,8 +494,8 @@ db_chain.run("What are some example tracks by Bach?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
What are some example tracks by Bach?
SQLQuery:SELECT "Name" FROM Track WHERE "Composer" LIKE '%Bach%' LIMIT 5;
@@ -501,31 +505,31 @@ db_chain.run("What are some example tracks by Bach?")
Unless the user specifies in the question a specific number of examples to obtain, query for at most 5 results using the LIMIT clause as per SQLite. You can order the results to return the most informative data in the database.
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (") to denote them as delimited identifiers.
Pay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.
Use the following format:
Question: "Question here"
SQLQuery: "SQL Query to run"
SQLResult: "Result of the SQLQuery"
Answer: "Final answer here"
Only use the following tables:
CREATE TABLE "Playlist" (
"PlaylistId" INTEGER NOT NULL,
"Name" NVARCHAR(120),
"PlaylistId" INTEGER NOT NULL,
"Name" NVARCHAR(120),
PRIMARY KEY ("PlaylistId")
)
/*
2 rows from Playlist table:
PlaylistId Name
1 Music
2 Movies
*/
CREATE TABLE Track (
"TrackId" INTEGER NOT NULL,
"TrackId" INTEGER NOT NULL,
"Name" NVARCHAR(200) NOT NULL,
"Composer" NVARCHAR(220),
PRIMARY KEY ("TrackId")
@@ -537,7 +541,7 @@ db_chain.run("What are some example tracks by Bach?")
2 Balls to the Wall None
3 My favorite song ever The coolest composer of all time
*/
Question: What are some example tracks by Bach?
SQLQuery:SELECT "Name" FROM Track WHERE "Composer" LIKE '%Bach%' LIMIT 5;
SQLResult: [('American Woman',), ('Concerto for 2 Violins in D Minor, BWV 1043: I. Vivace',), ('Aria Mit 30 Veränderungen, BWV 988 "Goldberg Variations": Aria',), ('Suite for Solo Cello No. 1 in G Major, BWV 1007: I. Prélude',), ('Toccata and Fugue in D Minor, BWV 565: I. Toccata',)]
@@ -557,7 +561,7 @@ db_chain.run("What are some example tracks by Bach?")
### SQL Views
In some case, the table schema can be hidden behind a JSON or JSONB column. Adding row samples into the prompt might help won't always describe the data perfectly.
In some case, the table schema can be hidden behind a JSON or JSONB column. Adding row samples into the prompt might help won't always describe the data perfectly.
For this reason, a custom SQL views can help.
@@ -609,19 +613,19 @@ chain.run("How many employees are also customers?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseSequentialChain chain...
Table names to use:
['Employee', 'Customer']
> Entering new SQLDatabaseChain chain...
How many employees are also customers?
SQLQuery:SELECT COUNT(*) FROM Employee e INNER JOIN Customer c ON e.EmployeeId = c.SupportRepId;
SQLResult: [(59,)]
Answer:59 employees are also customers.
> Finished chain.
> Finished chain.
@@ -692,8 +696,8 @@ local_chain("How many customers are there?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
How many customers are there?
SQLQuery:
@@ -879,8 +883,8 @@ print("\n" + yaml_example)
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
List all the customer first names that start with 'a'
SQLQuery:
@@ -900,7 +904,7 @@ print("\n" + yaml_example)
[('François', 'Frantiek', 'Helena', 'Astrid', 'Daan', 'Kara', 'Eduardo', 'Alexandre', 'Fernanda', 'Mark', 'Frank', 'Jack', 'Dan', 'Kathy', 'Heather', 'Frank', 'Richard', 'Patrick', 'Julia', 'Edward', 'Martha', 'Aaron', 'Madalena', 'Hannah', 'Niklas', 'Camille', 'Marc', 'Wyatt', 'Isabelle', 'Ladislav', 'Lucas', 'Johannes', 'Stanisaw', 'Joakim', 'Emma', 'Mark', 'Manoj', 'Puja']
> Finished chain.
*** Query succeeded
answer: '[(''François'', ''Frantiek'', ''Helena'', ''Astrid'', ''Daan'', ''Kara'',
''Eduardo'', ''Alexandre'', ''Fernanda'', ''Mark'', ''Frank'', ''Jack'', ''Dan'',
''Kathy'', ''Heather'', ''Frank'', ''Richard'', ''Patrick'', ''Julia'', ''Edward'',
@@ -931,7 +935,7 @@ print("\n" + yaml_example)
None\tGermany\t70174\t+49 0711 2842222\tNone\tleonekohler@surfeu.de\t5\n3\tFrançois\t\
Tremblay\tNone\t1498 rue Bélanger\tMontréal\tQC\tCanada\tH2G 1A7\t+1 (514) 721-4711\t\
None\tftremblay@gmail.com\t3\n*/"
```
</CodeOutputBlock>
@@ -944,20 +948,20 @@ YAML_EXAMPLES = """
- input: How many customers are not from Brazil?
table_info: |
CREATE TABLE "Customer" (
"CustomerId" INTEGER NOT NULL,
"FirstName" NVARCHAR(40) NOT NULL,
"LastName" NVARCHAR(20) NOT NULL,
"Company" NVARCHAR(80),
"Address" NVARCHAR(70),
"City" NVARCHAR(40),
"State" NVARCHAR(40),
"Country" NVARCHAR(40),
"PostalCode" NVARCHAR(10),
"Phone" NVARCHAR(24),
"Fax" NVARCHAR(24),
"Email" NVARCHAR(60) NOT NULL,
"SupportRepId" INTEGER,
PRIMARY KEY ("CustomerId"),
"CustomerId" INTEGER NOT NULL,
"FirstName" NVARCHAR(40) NOT NULL,
"LastName" NVARCHAR(20) NOT NULL,
"Company" NVARCHAR(80),
"Address" NVARCHAR(70),
"City" NVARCHAR(40),
"State" NVARCHAR(40),
"Country" NVARCHAR(40),
"PostalCode" NVARCHAR(10),
"Phone" NVARCHAR(24),
"Fax" NVARCHAR(24),
"Email" NVARCHAR(60) NOT NULL,
"SupportRepId" INTEGER,
PRIMARY KEY ("CustomerId"),
FOREIGN KEY("SupportRepId") REFERENCES "Employee" ("EmployeeId")
)
sql_cmd: SELECT COUNT(*) FROM "Customer" WHERE NOT "Country" = "Brazil";
@@ -966,8 +970,8 @@ YAML_EXAMPLES = """
- input: list all the genres that start with 'r'
table_info: |
CREATE TABLE "Genre" (
"GenreId" INTEGER NOT NULL,
"Name" NVARCHAR(120),
"GenreId" INTEGER NOT NULL,
"Name" NVARCHAR(120),
PRIMARY KEY ("GenreId")
)
@@ -980,7 +984,7 @@ YAML_EXAMPLES = """
*/
sql_cmd: SELECT "Name" FROM "Genre" WHERE "Name" LIKE 'r%';
sql_result: "[('Rock',), ('Rock and Roll',), ('Reggae',), ('R&B/Soul',)]"
answer: The genres that start with 'r' are Rock, Rock and Roll, Reggae and R&B/Soul.
answer: The genres that start with 'r' are Rock, Rock and Roll, Reggae and R&B/Soul.
"""
```
@@ -1046,8 +1050,8 @@ result = local_chain("How many customers are from Brazil?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
How many customers are from Brazil?
SQLQuery:SELECT count(*) FROM Customer WHERE Country = "Brazil";
@@ -1066,8 +1070,8 @@ result = local_chain("How many customers are not from Brazil?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
How many customers are not from Brazil?
SQLQuery:SELECT count(*) FROM customer WHERE country NOT IN (SELECT country FROM customer WHERE country = 'Brazil')
@@ -1086,8 +1090,8 @@ result = local_chain("How many customers are there in total?")
<CodeOutputBlock lang="python">
```
> Entering new SQLDatabaseChain chain...
How many customers are there in total?
SQLQuery:SELECT count(*) FROM Customer;

View File

@@ -1,3 +1,3 @@
FROM python:latest
FROM python:3.11
RUN pip install langchain

View File

@@ -8,10 +8,11 @@ set -o xtrace
SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd)"
cd "${SCRIPT_DIR}"
mkdir -p _dist/docs_skeleton
cp -r {docs_skeleton,snippets} _dist
cd _dist/docs_skeleton
poetry run nbdoc_build
poetry run python generate_api_reference_links.py
mkdir -p ../_dist
cp -r . ../_dist
cd ../_dist
poetry run python scripts/model_feat_table.py
poetry run nbdoc_build --srcdir docs
poetry run python scripts/generate_api_reference_links.py
yarn install
yarn start

View File

@@ -42,7 +42,7 @@ If you are using GitHub pages for hosting, this command is a convenient way to b
### Continuous Integration
Some common defaults for linting/formatting have been set for you. If you integrate your project with an open source Continuous Integration system (e.g. Travis CI, CircleCI), you may check for issues using the following command.
Some common defaults for linting/formatting have been set for you. If you integrate your project with an open-source Continuous Integration system (e.g. Travis CI, CircleCI), you may check for issues using the following command.
```
$ yarn ci

View File

@@ -122,8 +122,7 @@ def _merge_module_members(
def _load_package_modules(
package_directory: Union[str, Path],
submodule: Optional[str] = None
package_directory: Union[str, Path], submodule: Optional[str] = None
) -> Dict[str, ModuleMembers]:
"""Recursively load modules of a package based on the file system.
@@ -171,7 +170,8 @@ def _load_package_modules(
# different way
if submodule is not None:
module_members = _load_module_members(
f"{package_name}.{submodule}.{namespace}", f"{submodule}.{namespace}"
f"{package_name}.{submodule}.{namespace}",
f"{submodule}.{namespace}",
)
else:
module_members = _load_module_members(
@@ -280,18 +280,9 @@ Functions
return full_doc
def main() -> None:
"""Generate the reference.rst file for each package."""
lc_members = _load_package_modules(PKG_DIR)
# Put some packages at top level
tools = _load_package_modules(PKG_DIR, "tools")
lc_members['tools.render'] = tools['render']
agents = _load_package_modules(PKG_DIR, "agents")
lc_members['agents.output_parsers'] = agents['output_parsers']
lc_members['agents.format_scratchpad'] = agents['format_scratchpad']
lc_doc = ".. _api_reference:\n\n" + _construct_doc("langchain", lc_members)
with open(WRITE_FILE, "w") as f:
f.write(lc_doc)
def _document_langchain_experimental() -> None:
"""Document the langchain_experimental package."""
# Generate experimental_api_reference.rst
exp_members = _load_package_modules(EXP_DIR)
exp_doc = ".. _experimental_api_reference:\n\n" + _construct_doc(
"langchain_experimental", exp_members
@@ -300,5 +291,36 @@ def main() -> None:
f.write(exp_doc)
def _document_langchain_core() -> None:
"""Document the main langchain package."""
# load top level module members
lc_members = _load_package_modules(PKG_DIR)
# Add additional packages
tools = _load_package_modules(PKG_DIR, "tools")
agents = _load_package_modules(PKG_DIR, "agents")
schema = _load_package_modules(PKG_DIR, "schema")
lc_members.update(
{
"agents.output_parsers": agents["output_parsers"],
"agents.format_scratchpad": agents["format_scratchpad"],
"tools.render": tools["render"],
"schema.runnable": schema["runnable"],
}
)
lc_doc = ".. _api_reference:\n\n" + _construct_doc("langchain", lc_members)
with open(WRITE_FILE, "w") as f:
f.write(lc_doc)
def main() -> None:
"""Generate the reference.rst file for each package."""
_document_langchain_core()
_document_langchain_experimental()
if __name__ == "__main__":
main()

View File

Before

Width:  |  Height:  |  Size: 559 KiB

After

Width:  |  Height:  |  Size: 559 KiB

View File

Before

Width:  |  Height:  |  Size: 157 KiB

After

Width:  |  Height:  |  Size: 157 KiB

View File

Before

Width:  |  Height:  |  Size: 235 KiB

After

Width:  |  Height:  |  Size: 235 KiB

View File

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

View File

Before

Width:  |  Height:  |  Size: 3.5 MiB

After

Width:  |  Height:  |  Size: 3.5 MiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 85 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 542 B

After

Width:  |  Height:  |  Size: 542 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 103 KiB

View File

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 136 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,465 @@
# Dependents
Dependents stats for `langchain-ai/langchain`
[![](https://img.shields.io/static/v1?label=Used%20by&message=30534&color=informational&logo=slickpic)](https://github.com/langchain-ai/langchain/network/dependents)
[![](https://img.shields.io/static/v1?label=Used%20by%20(public)&message=451&color=informational&logo=slickpic)](https://github.com/langchain-ai/langchain/network/dependents)
[![](https://img.shields.io/static/v1?label=Used%20by%20(private)&message=30083&color=informational&logo=slickpic)](https://github.com/langchain-ai/langchain/network/dependents)
[![](https://img.shields.io/static/v1?label=Used%20by%20(stars)&message=37822&color=informational&logo=slickpic)](https://github.com/langchain-ai/langchain/network/dependents)
[update: `2023-10-06`; only dependent repositories with Stars > 100]
| Repository | Stars |
| :-------- | -----: |
|[openai/openai-cookbook](https://github.com/openai/openai-cookbook) | 49006 |
|[AntonOsika/gpt-engineer](https://github.com/AntonOsika/gpt-engineer) | 44368 |
|[imartinez/privateGPT](https://github.com/imartinez/privateGPT) | 38300 |
|[LAION-AI/Open-Assistant](https://github.com/LAION-AI/Open-Assistant) | 35327 |
|[hpcaitech/ColossalAI](https://github.com/hpcaitech/ColossalAI) | 34799 |
|[microsoft/TaskMatrix](https://github.com/microsoft/TaskMatrix) | 34161 |
|[streamlit/streamlit](https://github.com/streamlit/streamlit) | 27697 |
|[geekan/MetaGPT](https://github.com/geekan/MetaGPT) | 27302 |
|[reworkd/AgentGPT](https://github.com/reworkd/AgentGPT) | 26805 |
|[OpenBB-finance/OpenBBTerminal](https://github.com/OpenBB-finance/OpenBBTerminal) | 24473 |
|[StanGirard/quivr](https://github.com/StanGirard/quivr) | 23323 |
|[run-llama/llama_index](https://github.com/run-llama/llama_index) | 22151 |
|[openai/chatgpt-retrieval-plugin](https://github.com/openai/chatgpt-retrieval-plugin) | 19741 |
|[mindsdb/mindsdb](https://github.com/mindsdb/mindsdb) | 18062 |
|[PromtEngineer/localGPT](https://github.com/PromtEngineer/localGPT) | 16413 |
|[chatchat-space/Langchain-Chatchat](https://github.com/chatchat-space/Langchain-Chatchat) | 16300 |
|[cube-js/cube](https://github.com/cube-js/cube) | 16261 |
|[mlflow/mlflow](https://github.com/mlflow/mlflow) | 15487 |
|[logspace-ai/langflow](https://github.com/logspace-ai/langflow) | 12599 |
|[GaiZhenbiao/ChuanhuChatGPT](https://github.com/GaiZhenbiao/ChuanhuChatGPT) | 12501 |
|[openai/evals](https://github.com/openai/evals) | 12056 |
|[airbytehq/airbyte](https://github.com/airbytehq/airbyte) | 11919 |
|[go-skynet/LocalAI](https://github.com/go-skynet/LocalAI) | 11767 |
|[databrickslabs/dolly](https://github.com/databrickslabs/dolly) | 10609 |
|[AIGC-Audio/AudioGPT](https://github.com/AIGC-Audio/AudioGPT) | 9240 |
|[aws/amazon-sagemaker-examples](https://github.com/aws/amazon-sagemaker-examples) | 8892 |
|[langgenius/dify](https://github.com/langgenius/dify) | 8764 |
|[gventuri/pandas-ai](https://github.com/gventuri/pandas-ai) | 8687 |
|[jmorganca/ollama](https://github.com/jmorganca/ollama) | 8628 |
|[langchain-ai/langchainjs](https://github.com/langchain-ai/langchainjs) | 8392 |
|[h2oai/h2ogpt](https://github.com/h2oai/h2ogpt) | 7953 |
|[arc53/DocsGPT](https://github.com/arc53/DocsGPT) | 7730 |
|[PipedreamHQ/pipedream](https://github.com/PipedreamHQ/pipedream) | 7261 |
|[joshpxyne/gpt-migrate](https://github.com/joshpxyne/gpt-migrate) | 6349 |
|[bentoml/OpenLLM](https://github.com/bentoml/OpenLLM) | 6213 |
|[mage-ai/mage-ai](https://github.com/mage-ai/mage-ai) | 5600 |
|[zauberzeug/nicegui](https://github.com/zauberzeug/nicegui) | 5499 |
|[wenda-LLM/wenda](https://github.com/wenda-LLM/wenda) | 5497 |
|[sweepai/sweep](https://github.com/sweepai/sweep) | 5489 |
|[embedchain/embedchain](https://github.com/embedchain/embedchain) | 5428 |
|[zilliztech/GPTCache](https://github.com/zilliztech/GPTCache) | 5311 |
|[Shaunwei/RealChar](https://github.com/Shaunwei/RealChar) | 5264 |
|[GreyDGL/PentestGPT](https://github.com/GreyDGL/PentestGPT) | 5146 |
|[gkamradt/langchain-tutorials](https://github.com/gkamradt/langchain-tutorials) | 5134 |
|[serge-chat/serge](https://github.com/serge-chat/serge) | 5009 |
|[assafelovic/gpt-researcher](https://github.com/assafelovic/gpt-researcher) | 4836 |
|[openchatai/OpenChat](https://github.com/openchatai/OpenChat) | 4697 |
|[intel-analytics/BigDL](https://github.com/intel-analytics/BigDL) | 4412 |
|[continuedev/continue](https://github.com/continuedev/continue) | 4324 |
|[postgresml/postgresml](https://github.com/postgresml/postgresml) | 4267 |
|[madawei2699/myGPTReader](https://github.com/madawei2699/myGPTReader) | 4214 |
|[MineDojo/Voyager](https://github.com/MineDojo/Voyager) | 4204 |
|[danswer-ai/danswer](https://github.com/danswer-ai/danswer) | 3973 |
|[RayVentura/ShortGPT](https://github.com/RayVentura/ShortGPT) | 3922 |
|[Azure/azure-sdk-for-python](https://github.com/Azure/azure-sdk-for-python) | 3849 |
|[khoj-ai/khoj](https://github.com/khoj-ai/khoj) | 3817 |
|[langchain-ai/chat-langchain](https://github.com/langchain-ai/chat-langchain) | 3742 |
|[Azure-Samples/azure-search-openai-demo](https://github.com/Azure-Samples/azure-search-openai-demo) | 3731 |
|[marqo-ai/marqo](https://github.com/marqo-ai/marqo) | 3627 |
|[kyegomez/tree-of-thoughts](https://github.com/kyegomez/tree-of-thoughts) | 3553 |
|[llm-workflow-engine/llm-workflow-engine](https://github.com/llm-workflow-engine/llm-workflow-engine) | 3483 |
|[PrefectHQ/marvin](https://github.com/PrefectHQ/marvin) | 3460 |
|[aiwaves-cn/agents](https://github.com/aiwaves-cn/agents) | 3413 |
|[OpenBMB/ToolBench](https://github.com/OpenBMB/ToolBench) | 3388 |
|[shroominic/codeinterpreter-api](https://github.com/shroominic/codeinterpreter-api) | 3218 |
|[whitead/paper-qa](https://github.com/whitead/paper-qa) | 3085 |
|[project-baize/baize-chatbot](https://github.com/project-baize/baize-chatbot) | 3039 |
|[OpenGVLab/InternGPT](https://github.com/OpenGVLab/InternGPT) | 2911 |
|[ParisNeo/lollms-webui](https://github.com/ParisNeo/lollms-webui) | 2907 |
|[Unstructured-IO/unstructured](https://github.com/Unstructured-IO/unstructured) | 2874 |
|[openchatai/OpenCopilot](https://github.com/openchatai/OpenCopilot) | 2759 |
|[OpenBMB/BMTools](https://github.com/OpenBMB/BMTools) | 2657 |
|[homanp/superagent](https://github.com/homanp/superagent) | 2624 |
|[SamurAIGPT/EmbedAI](https://github.com/SamurAIGPT/EmbedAI) | 2575 |
|[GerevAI/gerev](https://github.com/GerevAI/gerev) | 2488 |
|[microsoft/promptflow](https://github.com/microsoft/promptflow) | 2475 |
|[OpenBMB/AgentVerse](https://github.com/OpenBMB/AgentVerse) | 2445 |
|[Mintplex-Labs/anything-llm](https://github.com/Mintplex-Labs/anything-llm) | 2434 |
|[emptycrown/llama-hub](https://github.com/emptycrown/llama-hub) | 2432 |
|[NVIDIA/NeMo-Guardrails](https://github.com/NVIDIA/NeMo-Guardrails) | 2327 |
|[ShreyaR/guardrails](https://github.com/ShreyaR/guardrails) | 2307 |
|[thomas-yanxin/LangChain-ChatGLM-Webui](https://github.com/thomas-yanxin/LangChain-ChatGLM-Webui) | 2305 |
|[yanqiangmiffy/Chinese-LangChain](https://github.com/yanqiangmiffy/Chinese-LangChain) | 2291 |
|[keephq/keep](https://github.com/keephq/keep) | 2252 |
|[OpenGVLab/Ask-Anything](https://github.com/OpenGVLab/Ask-Anything) | 2194 |
|[IntelligenzaArtificiale/Free-Auto-GPT](https://github.com/IntelligenzaArtificiale/Free-Auto-GPT) | 2169 |
|[Farama-Foundation/PettingZoo](https://github.com/Farama-Foundation/PettingZoo) | 2031 |
|[YiVal/YiVal](https://github.com/YiVal/YiVal) | 2014 |
|[hwchase17/notion-qa](https://github.com/hwchase17/notion-qa) | 2014 |
|[jupyterlab/jupyter-ai](https://github.com/jupyterlab/jupyter-ai) | 1977 |
|[paulpierre/RasaGPT](https://github.com/paulpierre/RasaGPT) | 1887 |
|[dot-agent/dotagent-WIP](https://github.com/dot-agent/dotagent-WIP) | 1812 |
|[hegelai/prompttools](https://github.com/hegelai/prompttools) | 1775 |
|[vocodedev/vocode-python](https://github.com/vocodedev/vocode-python) | 1734 |
|[Vonng/pigsty](https://github.com/Vonng/pigsty) | 1693 |
|[psychic-api/psychic](https://github.com/psychic-api/psychic) | 1597 |
|[avinashkranjan/Amazing-Python-Scripts](https://github.com/avinashkranjan/Amazing-Python-Scripts) | 1546 |
|[pinterest/querybook](https://github.com/pinterest/querybook) | 1539 |
|[Forethought-Technologies/AutoChain](https://github.com/Forethought-Technologies/AutoChain) | 1531 |
|[Kav-K/GPTDiscord](https://github.com/Kav-K/GPTDiscord) | 1503 |
|[jina-ai/langchain-serve](https://github.com/jina-ai/langchain-serve) | 1487 |
|[noahshinn024/reflexion](https://github.com/noahshinn024/reflexion) | 1481 |
|[jina-ai/dev-gpt](https://github.com/jina-ai/dev-gpt) | 1436 |
|[ttengwang/Caption-Anything](https://github.com/ttengwang/Caption-Anything) | 1425 |
|[milvus-io/bootcamp](https://github.com/milvus-io/bootcamp) | 1420 |
|[agiresearch/OpenAGI](https://github.com/agiresearch/OpenAGI) | 1401 |
|[greshake/llm-security](https://github.com/greshake/llm-security) | 1381 |
|[jina-ai/thinkgpt](https://github.com/jina-ai/thinkgpt) | 1366 |
|[lunasec-io/lunasec](https://github.com/lunasec-io/lunasec) | 1352 |
|[101dotxyz/GPTeam](https://github.com/101dotxyz/GPTeam) | 1339 |
|[refuel-ai/autolabel](https://github.com/refuel-ai/autolabel) | 1320 |
|[melih-unsal/DemoGPT](https://github.com/melih-unsal/DemoGPT) | 1320 |
|[mmz-001/knowledge_gpt](https://github.com/mmz-001/knowledge_gpt) | 1320 |
|[richardyc/Chrome-GPT](https://github.com/richardyc/Chrome-GPT) | 1315 |
|[run-llama/sec-insights](https://github.com/run-llama/sec-insights) | 1312 |
|[Azure/azureml-examples](https://github.com/Azure/azureml-examples) | 1305 |
|[cofactoryai/textbase](https://github.com/cofactoryai/textbase) | 1286 |
|[dataelement/bisheng](https://github.com/dataelement/bisheng) | 1273 |
|[eyurtsev/kor](https://github.com/eyurtsev/kor) | 1263 |
|[pluralsh/plural](https://github.com/pluralsh/plural) | 1188 |
|[FlagOpen/FlagEmbedding](https://github.com/FlagOpen/FlagEmbedding) | 1184 |
|[juncongmoo/chatllama](https://github.com/juncongmoo/chatllama) | 1144 |
|[poe-platform/server-bot-quick-start](https://github.com/poe-platform/server-bot-quick-start) | 1139 |
|[visual-openllm/visual-openllm](https://github.com/visual-openllm/visual-openllm) | 1137 |
|[griptape-ai/griptape](https://github.com/griptape-ai/griptape) | 1124 |
|[microsoft/X-Decoder](https://github.com/microsoft/X-Decoder) | 1119 |
|[ThousandBirdsInc/chidori](https://github.com/ThousandBirdsInc/chidori) | 1116 |
|[filip-michalsky/SalesGPT](https://github.com/filip-michalsky/SalesGPT) | 1112 |
|[psychic-api/rag-stack](https://github.com/psychic-api/rag-stack) | 1110 |
|[irgolic/AutoPR](https://github.com/irgolic/AutoPR) | 1100 |
|[promptfoo/promptfoo](https://github.com/promptfoo/promptfoo) | 1099 |
|[nod-ai/SHARK](https://github.com/nod-ai/SHARK) | 1062 |
|[SamurAIGPT/Camel-AutoGPT](https://github.com/SamurAIGPT/Camel-AutoGPT) | 1036 |
|[Farama-Foundation/chatarena](https://github.com/Farama-Foundation/chatarena) | 1020 |
|[peterw/Chat-with-Github-Repo](https://github.com/peterw/Chat-with-Github-Repo) | 993 |
|[jiran214/GPT-vup](https://github.com/jiran214/GPT-vup) | 967 |
|[alejandro-ao/ask-multiple-pdfs](https://github.com/alejandro-ao/ask-multiple-pdfs) | 958 |
|[run-llama/llama-lab](https://github.com/run-llama/llama-lab) | 953 |
|[LC1332/Chat-Haruhi-Suzumiya](https://github.com/LC1332/Chat-Haruhi-Suzumiya) | 950 |
|[rlancemartin/auto-evaluator](https://github.com/rlancemartin/auto-evaluator) | 927 |
|[cheshire-cat-ai/core](https://github.com/cheshire-cat-ai/core) | 902 |
|[Anil-matcha/ChatPDF](https://github.com/Anil-matcha/ChatPDF) | 894 |
|[cirediatpl/FigmaChain](https://github.com/cirediatpl/FigmaChain) | 881 |
|[seanpixel/Teenage-AGI](https://github.com/seanpixel/Teenage-AGI) | 876 |
|[xusenlinzy/api-for-open-llm](https://github.com/xusenlinzy/api-for-open-llm) | 865 |
|[ricklamers/shell-ai](https://github.com/ricklamers/shell-ai) | 864 |
|[codeacme17/examor](https://github.com/codeacme17/examor) | 856 |
|[corca-ai/EVAL](https://github.com/corca-ai/EVAL) | 836 |
|[microsoft/Llama-2-Onnx](https://github.com/microsoft/Llama-2-Onnx) | 835 |
|[explodinggradients/ragas](https://github.com/explodinggradients/ragas) | 833 |
|[ajndkr/lanarky](https://github.com/ajndkr/lanarky) | 817 |
|[kennethleungty/Llama-2-Open-Source-LLM-CPU-Inference](https://github.com/kennethleungty/Llama-2-Open-Source-LLM-CPU-Inference) | 814 |
|[ray-project/llm-applications](https://github.com/ray-project/llm-applications) | 804 |
|[hwchase17/chat-your-data](https://github.com/hwchase17/chat-your-data) | 801 |
|[LambdaLabsML/examples](https://github.com/LambdaLabsML/examples) | 759 |
|[kreneskyp/ix](https://github.com/kreneskyp/ix) | 758 |
|[pyspark-ai/pyspark-ai](https://github.com/pyspark-ai/pyspark-ai) | 750 |
|[billxbf/ReWOO](https://github.com/billxbf/ReWOO) | 746 |
|[e-johnstonn/BriefGPT](https://github.com/e-johnstonn/BriefGPT) | 738 |
|[akshata29/entaoai](https://github.com/akshata29/entaoai) | 733 |
|[getmetal/motorhead](https://github.com/getmetal/motorhead) | 717 |
|[ruoccofabrizio/azure-open-ai-embeddings-qna](https://github.com/ruoccofabrizio/azure-open-ai-embeddings-qna) | 712 |
|[msoedov/langcorn](https://github.com/msoedov/langcorn) | 698 |
|[Dataherald/dataherald](https://github.com/Dataherald/dataherald) | 684 |
|[jondurbin/airoboros](https://github.com/jondurbin/airoboros) | 657 |
|[Ikaros-521/AI-Vtuber](https://github.com/Ikaros-521/AI-Vtuber) | 651 |
|[whyiyhw/chatgpt-wechat](https://github.com/whyiyhw/chatgpt-wechat) | 644 |
|[langchain-ai/streamlit-agent](https://github.com/langchain-ai/streamlit-agent) | 637 |
|[SamurAIGPT/ChatGPT-Developer-Plugins](https://github.com/SamurAIGPT/ChatGPT-Developer-Plugins) | 637 |
|[OpenGenerativeAI/GenossGPT](https://github.com/OpenGenerativeAI/GenossGPT) | 632 |
|[AILab-CVC/GPT4Tools](https://github.com/AILab-CVC/GPT4Tools) | 629 |
|[langchain-ai/auto-evaluator](https://github.com/langchain-ai/auto-evaluator) | 614 |
|[explosion/spacy-llm](https://github.com/explosion/spacy-llm) | 613 |
|[alexanderatallah/window.ai](https://github.com/alexanderatallah/window.ai) | 607 |
|[MiuLab/Taiwan-LLaMa](https://github.com/MiuLab/Taiwan-LLaMa) | 601 |
|[microsoft/PodcastCopilot](https://github.com/microsoft/PodcastCopilot) | 600 |
|[Dicklesworthstone/swiss_army_llama](https://github.com/Dicklesworthstone/swiss_army_llama) | 596 |
|[NoDataFound/hackGPT](https://github.com/NoDataFound/hackGPT) | 596 |
|[namuan/dr-doc-search](https://github.com/namuan/dr-doc-search) | 593 |
|[amosjyng/langchain-visualizer](https://github.com/amosjyng/langchain-visualizer) | 582 |
|[microsoft/sample-app-aoai-chatGPT](https://github.com/microsoft/sample-app-aoai-chatGPT) | 581 |
|[yvann-hub/Robby-chatbot](https://github.com/yvann-hub/Robby-chatbot) | 581 |
|[yeagerai/yeagerai-agent](https://github.com/yeagerai/yeagerai-agent) | 547 |
|[tgscan-dev/tgscan](https://github.com/tgscan-dev/tgscan) | 533 |
|[Azure-Samples/openai](https://github.com/Azure-Samples/openai) | 531 |
|[plastic-labs/tutor-gpt](https://github.com/plastic-labs/tutor-gpt) | 531 |
|[xuwenhao/geektime-ai-course](https://github.com/xuwenhao/geektime-ai-course) | 526 |
|[michaelthwan/searchGPT](https://github.com/michaelthwan/searchGPT) | 526 |
|[jonra1993/fastapi-alembic-sqlmodel-async](https://github.com/jonra1993/fastapi-alembic-sqlmodel-async) | 522 |
|[jina-ai/agentchain](https://github.com/jina-ai/agentchain) | 519 |
|[mckaywrigley/repo-chat](https://github.com/mckaywrigley/repo-chat) | 518 |
|[modelscope/modelscope-agent](https://github.com/modelscope/modelscope-agent) | 512 |
|[daveebbelaar/langchain-experiments](https://github.com/daveebbelaar/langchain-experiments) | 504 |
|[freddyaboulton/gradio-tools](https://github.com/freddyaboulton/gradio-tools) | 497 |
|[sidhq/Multi-GPT](https://github.com/sidhq/Multi-GPT) | 494 |
|[continuum-llms/chatgpt-memory](https://github.com/continuum-llms/chatgpt-memory) | 489 |
|[langchain-ai/langchain-aiplugin](https://github.com/langchain-ai/langchain-aiplugin) | 487 |
|[mpaepper/content-chatbot](https://github.com/mpaepper/content-chatbot) | 483 |
|[steamship-core/steamship-langchain](https://github.com/steamship-core/steamship-langchain) | 481 |
|[alejandro-ao/langchain-ask-pdf](https://github.com/alejandro-ao/langchain-ask-pdf) | 474 |
|[truera/trulens](https://github.com/truera/trulens) | 464 |
|[marella/chatdocs](https://github.com/marella/chatdocs) | 459 |
|[opencopilotdev/opencopilot](https://github.com/opencopilotdev/opencopilot) | 453 |
|[poe-platform/poe-protocol](https://github.com/poe-platform/poe-protocol) | 444 |
|[DataDog/dd-trace-py](https://github.com/DataDog/dd-trace-py) | 441 |
|[logan-markewich/llama_index_starter_pack](https://github.com/logan-markewich/llama_index_starter_pack) | 441 |
|[opentensor/bittensor](https://github.com/opentensor/bittensor) | 433 |
|[DjangoPeng/openai-quickstart](https://github.com/DjangoPeng/openai-quickstart) | 425 |
|[CarperAI/OpenELM](https://github.com/CarperAI/OpenELM) | 424 |
|[daodao97/chatdoc](https://github.com/daodao97/chatdoc) | 423 |
|[showlab/VLog](https://github.com/showlab/VLog) | 411 |
|[Anil-matcha/Chatbase](https://github.com/Anil-matcha/Chatbase) | 402 |
|[yakami129/VirtualWife](https://github.com/yakami129/VirtualWife) | 399 |
|[wandb/weave](https://github.com/wandb/weave) | 399 |
|[mtenenholtz/chat-twitter](https://github.com/mtenenholtz/chat-twitter) | 398 |
|[LinkSoul-AI/AutoAgents](https://github.com/LinkSoul-AI/AutoAgents) | 397 |
|[Agenta-AI/agenta](https://github.com/Agenta-AI/agenta) | 389 |
|[huchenxucs/ChatDB](https://github.com/huchenxucs/ChatDB) | 386 |
|[mallorbc/Finetune_LLMs](https://github.com/mallorbc/Finetune_LLMs) | 379 |
|[junruxiong/IncarnaMind](https://github.com/junruxiong/IncarnaMind) | 372 |
|[MagnivOrg/prompt-layer-library](https://github.com/MagnivOrg/prompt-layer-library) | 368 |
|[mosaicml/examples](https://github.com/mosaicml/examples) | 366 |
|[rsaryev/talk-codebase](https://github.com/rsaryev/talk-codebase) | 364 |
|[morpheuslord/GPT_Vuln-analyzer](https://github.com/morpheuslord/GPT_Vuln-analyzer) | 362 |
|[monarch-initiative/ontogpt](https://github.com/monarch-initiative/ontogpt) | 362 |
|[JayZeeDesign/researcher-gpt](https://github.com/JayZeeDesign/researcher-gpt) | 361 |
|[personoids/personoids-lite](https://github.com/personoids/personoids-lite) | 361 |
|[intel/intel-extension-for-transformers](https://github.com/intel/intel-extension-for-transformers) | 357 |
|[jerlendds/osintbuddy](https://github.com/jerlendds/osintbuddy) | 357 |
|[steamship-packages/langchain-production-starter](https://github.com/steamship-packages/langchain-production-starter) | 356 |
|[onlyphantom/llm-python](https://github.com/onlyphantom/llm-python) | 354 |
|[Azure-Samples/miyagi](https://github.com/Azure-Samples/miyagi) | 340 |
|[mrwadams/attackgen](https://github.com/mrwadams/attackgen) | 338 |
|[rgomezcasas/dotfiles](https://github.com/rgomezcasas/dotfiles) | 337 |
|[eosphoros-ai/DB-GPT-Hub](https://github.com/eosphoros-ai/DB-GPT-Hub) | 336 |
|[andylokandy/gpt-4-search](https://github.com/andylokandy/gpt-4-search) | 335 |
|[NimbleBoxAI/ChainFury](https://github.com/NimbleBoxAI/ChainFury) | 330 |
|[momegas/megabots](https://github.com/momegas/megabots) | 329 |
|[Nuggt-dev/Nuggt](https://github.com/Nuggt-dev/Nuggt) | 315 |
|[itamargol/openai](https://github.com/itamargol/openai) | 315 |
|[BlackHC/llm-strategy](https://github.com/BlackHC/llm-strategy) | 315 |
|[aws-samples/aws-genai-llm-chatbot](https://github.com/aws-samples/aws-genai-llm-chatbot) | 312 |
|[Cheems-Seminar/grounded-segment-any-parts](https://github.com/Cheems-Seminar/grounded-segment-any-parts) | 312 |
|[preset-io/promptimize](https://github.com/preset-io/promptimize) | 311 |
|[dgarnitz/vectorflow](https://github.com/dgarnitz/vectorflow) | 309 |
|[langchain-ai/langsmith-cookbook](https://github.com/langchain-ai/langsmith-cookbook) | 309 |
|[CambioML/pykoi](https://github.com/CambioML/pykoi) | 309 |
|[wandb/edu](https://github.com/wandb/edu) | 301 |
|[XzaiCloud/luna-ai](https://github.com/XzaiCloud/luna-ai) | 300 |
|[liangwq/Chatglm_lora_multi-gpu](https://github.com/liangwq/Chatglm_lora_multi-gpu) | 294 |
|[Haste171/langchain-chatbot](https://github.com/Haste171/langchain-chatbot) | 291 |
|[sullivan-sean/chat-langchainjs](https://github.com/sullivan-sean/chat-langchainjs) | 286 |
|[sugarforever/LangChain-Tutorials](https://github.com/sugarforever/LangChain-Tutorials) | 285 |
|[facebookresearch/personal-timeline](https://github.com/facebookresearch/personal-timeline) | 283 |
|[hnawaz007/pythondataanalysis](https://github.com/hnawaz007/pythondataanalysis) | 282 |
|[yuanjie-ai/ChatLLM](https://github.com/yuanjie-ai/ChatLLM) | 280 |
|[MetaGLM/FinGLM](https://github.com/MetaGLM/FinGLM) | 279 |
|[JohnSnowLabs/langtest](https://github.com/JohnSnowLabs/langtest) | 277 |
|[Em1tSan/NeuroGPT](https://github.com/Em1tSan/NeuroGPT) | 274 |
|[Safiullah-Rahu/CSV-AI](https://github.com/Safiullah-Rahu/CSV-AI) | 274 |
|[conceptofmind/toolformer](https://github.com/conceptofmind/toolformer) | 274 |
|[airobotlab/KoChatGPT](https://github.com/airobotlab/KoChatGPT) | 266 |
|[gia-guar/JARVIS-ChatGPT](https://github.com/gia-guar/JARVIS-ChatGPT) | 263 |
|[Mintplex-Labs/vector-admin](https://github.com/Mintplex-Labs/vector-admin) | 262 |
|[artitw/text2text](https://github.com/artitw/text2text) | 262 |
|[kaarthik108/snowChat](https://github.com/kaarthik108/snowChat) | 261 |
|[paolorechia/learn-langchain](https://github.com/paolorechia/learn-langchain) | 260 |
|[shamspias/customizable-gpt-chatbot](https://github.com/shamspias/customizable-gpt-chatbot) | 260 |
|[ur-whitelab/exmol](https://github.com/ur-whitelab/exmol) | 258 |
|[hwchase17/chroma-langchain](https://github.com/hwchase17/chroma-langchain) | 257 |
|[bborn/howdoi.ai](https://github.com/bborn/howdoi.ai) | 255 |
|[ur-whitelab/chemcrow-public](https://github.com/ur-whitelab/chemcrow-public) | 253 |
|[pablomarin/GPT-Azure-Search-Engine](https://github.com/pablomarin/GPT-Azure-Search-Engine) | 251 |
|[gustavz/DataChad](https://github.com/gustavz/DataChad) | 249 |
|[radi-cho/datasetGPT](https://github.com/radi-cho/datasetGPT) | 249 |
|[ennucore/clippinator](https://github.com/ennucore/clippinator) | 247 |
|[recalign/RecAlign](https://github.com/recalign/RecAlign) | 244 |
|[lilacai/lilac](https://github.com/lilacai/lilac) | 243 |
|[kaleido-lab/dolphin](https://github.com/kaleido-lab/dolphin) | 236 |
|[iusztinpaul/hands-on-llms](https://github.com/iusztinpaul/hands-on-llms) | 233 |
|[PradipNichite/Youtube-Tutorials](https://github.com/PradipNichite/Youtube-Tutorials) | 231 |
|[shaman-ai/agent-actors](https://github.com/shaman-ai/agent-actors) | 231 |
|[hwchase17/langchain-streamlit-template](https://github.com/hwchase17/langchain-streamlit-template) | 231 |
|[yym68686/ChatGPT-Telegram-Bot](https://github.com/yym68686/ChatGPT-Telegram-Bot) | 226 |
|[grumpyp/aixplora](https://github.com/grumpyp/aixplora) | 222 |
|[su77ungr/CASALIOY](https://github.com/su77ungr/CASALIOY) | 222 |
|[alvarosevilla95/autolang](https://github.com/alvarosevilla95/autolang) | 222 |
|[arthur-ai/bench](https://github.com/arthur-ai/bench) | 220 |
|[miaoshouai/miaoshouai-assistant](https://github.com/miaoshouai/miaoshouai-assistant) | 219 |
|[AutoPackAI/beebot](https://github.com/AutoPackAI/beebot) | 217 |
|[edreisMD/plugnplai](https://github.com/edreisMD/plugnplai) | 216 |
|[nicknochnack/LangchainDocuments](https://github.com/nicknochnack/LangchainDocuments) | 214 |
|[AkshitIreddy/Interactive-LLM-Powered-NPCs](https://github.com/AkshitIreddy/Interactive-LLM-Powered-NPCs) | 213 |
|[SpecterOps/Nemesis](https://github.com/SpecterOps/Nemesis) | 210 |
|[kyegomez/swarms](https://github.com/kyegomez/swarms) | 210 |
|[wpydcr/LLM-Kit](https://github.com/wpydcr/LLM-Kit) | 208 |
|[orgexyz/BlockAGI](https://github.com/orgexyz/BlockAGI) | 204 |
|[Chainlit/cookbook](https://github.com/Chainlit/cookbook) | 202 |
|[WongSaang/chatgpt-ui-server](https://github.com/WongSaang/chatgpt-ui-server) | 202 |
|[jbrukh/gpt-jargon](https://github.com/jbrukh/gpt-jargon) | 202 |
|[handrew/browserpilot](https://github.com/handrew/browserpilot) | 202 |
|[langchain-ai/web-explorer](https://github.com/langchain-ai/web-explorer) | 200 |
|[plchld/InsightFlow](https://github.com/plchld/InsightFlow) | 200 |
|[alphasecio/langchain-examples](https://github.com/alphasecio/langchain-examples) | 199 |
|[Gentopia-AI/Gentopia](https://github.com/Gentopia-AI/Gentopia) | 198 |
|[SamPink/dev-gpt](https://github.com/SamPink/dev-gpt) | 196 |
|[yasyf/compress-gpt](https://github.com/yasyf/compress-gpt) | 196 |
|[benthecoder/ClassGPT](https://github.com/benthecoder/ClassGPT) | 195 |
|[voxel51/voxelgpt](https://github.com/voxel51/voxelgpt) | 193 |
|[CL-lau/SQL-GPT](https://github.com/CL-lau/SQL-GPT) | 192 |
|[blob42/Instrukt](https://github.com/blob42/Instrukt) | 191 |
|[streamlit/llm-examples](https://github.com/streamlit/llm-examples) | 191 |
|[stepanogil/autonomous-hr-chatbot](https://github.com/stepanogil/autonomous-hr-chatbot) | 190 |
|[TsinghuaDatabaseGroup/DB-GPT](https://github.com/TsinghuaDatabaseGroup/DB-GPT) | 189 |
|[PJLab-ADG/DriveLikeAHuman](https://github.com/PJLab-ADG/DriveLikeAHuman) | 187 |
|[Azure-Samples/azure-search-power-skills](https://github.com/Azure-Samples/azure-search-power-skills) | 187 |
|[microsoft/azure-openai-in-a-day-workshop](https://github.com/microsoft/azure-openai-in-a-day-workshop) | 187 |
|[ju-bezdek/langchain-decorators](https://github.com/ju-bezdek/langchain-decorators) | 182 |
|[hardbyte/qabot](https://github.com/hardbyte/qabot) | 181 |
|[hongbo-miao/hongbomiao.com](https://github.com/hongbo-miao/hongbomiao.com) | 180 |
|[QwenLM/Qwen-Agent](https://github.com/QwenLM/Qwen-Agent) | 179 |
|[showlab/UniVTG](https://github.com/showlab/UniVTG) | 179 |
|[Azure-Samples/jp-azureopenai-samples](https://github.com/Azure-Samples/jp-azureopenai-samples) | 176 |
|[afaqueumer/DocQA](https://github.com/afaqueumer/DocQA) | 174 |
|[ethanyanjiali/minChatGPT](https://github.com/ethanyanjiali/minChatGPT) | 174 |
|[shauryr/S2QA](https://github.com/shauryr/S2QA) | 174 |
|[RoboCoachTechnologies/GPT-Synthesizer](https://github.com/RoboCoachTechnologies/GPT-Synthesizer) | 173 |
|[chakkaradeep/pyCodeAGI](https://github.com/chakkaradeep/pyCodeAGI) | 172 |
|[vaibkumr/prompt-optimizer](https://github.com/vaibkumr/prompt-optimizer) | 171 |
|[ccurme/yolopandas](https://github.com/ccurme/yolopandas) | 170 |
|[anarchy-ai/LLM-VM](https://github.com/anarchy-ai/LLM-VM) | 169 |
|[ray-project/langchain-ray](https://github.com/ray-project/langchain-ray) | 169 |
|[fengyuli-dev/multimedia-gpt](https://github.com/fengyuli-dev/multimedia-gpt) | 169 |
|[ibiscp/LLM-IMDB](https://github.com/ibiscp/LLM-IMDB) | 168 |
|[mayooear/private-chatbot-mpt30b-langchain](https://github.com/mayooear/private-chatbot-mpt30b-langchain) | 167 |
|[OpenPluginACI/openplugin](https://github.com/OpenPluginACI/openplugin) | 165 |
|[jmpaz/promptlib](https://github.com/jmpaz/promptlib) | 165 |
|[kjappelbaum/gptchem](https://github.com/kjappelbaum/gptchem) | 162 |
|[JorisdeJong123/7-Days-of-LangChain](https://github.com/JorisdeJong123/7-Days-of-LangChain) | 161 |
|[retr0reg/Ret2GPT](https://github.com/retr0reg/Ret2GPT) | 161 |
|[menloparklab/falcon-langchain](https://github.com/menloparklab/falcon-langchain) | 159 |
|[summarizepaper/summarizepaper](https://github.com/summarizepaper/summarizepaper) | 158 |
|[emarco177/ice_breaker](https://github.com/emarco177/ice_breaker) | 157 |
|[AmineDiro/cria](https://github.com/AmineDiro/cria) | 156 |
|[morpheuslord/HackBot](https://github.com/morpheuslord/HackBot) | 156 |
|[homanp/vercel-langchain](https://github.com/homanp/vercel-langchain) | 156 |
|[mlops-for-all/mlops-for-all.github.io](https://github.com/mlops-for-all/mlops-for-all.github.io) | 155 |
|[positive666/Prompt-Can-Anything](https://github.com/positive666/Prompt-Can-Anything) | 154 |
|[deeppavlov/dream](https://github.com/deeppavlov/dream) | 153 |
|[flurb18/AgentOoba](https://github.com/flurb18/AgentOoba) | 151 |
|[Open-Swarm-Net/GPT-Swarm](https://github.com/Open-Swarm-Net/GPT-Swarm) | 151 |
|[v7labs/benchllm](https://github.com/v7labs/benchllm) | 150 |
|[Klingefjord/chatgpt-telegram](https://github.com/Klingefjord/chatgpt-telegram) | 150 |
|[Aggregate-Intellect/sherpa](https://github.com/Aggregate-Intellect/sherpa) | 148 |
|[Coding-Crashkurse/Langchain-Full-Course](https://github.com/Coding-Crashkurse/Langchain-Full-Course) | 148 |
|[SuperDuperDB/superduperdb](https://github.com/SuperDuperDB/superduperdb) | 147 |
|[defenseunicorns/leapfrogai](https://github.com/defenseunicorns/leapfrogai) | 147 |
|[menloparklab/langchain-cohere-qdrant-doc-retrieval](https://github.com/menloparklab/langchain-cohere-qdrant-doc-retrieval) | 147 |
|[Jaseci-Labs/jaseci](https://github.com/Jaseci-Labs/jaseci) | 146 |
|[realminchoi/babyagi-ui](https://github.com/realminchoi/babyagi-ui) | 146 |
|[iMagist486/ElasticSearch-Langchain-Chatglm2](https://github.com/iMagist486/ElasticSearch-Langchain-Chatglm2) | 144 |
|[peterw/StoryStorm](https://github.com/peterw/StoryStorm) | 143 |
|[kulltc/chatgpt-sql](https://github.com/kulltc/chatgpt-sql) | 142 |
|[Teahouse-Studios/akari-bot](https://github.com/Teahouse-Studios/akari-bot) | 142 |
|[hirokidaichi/wanna](https://github.com/hirokidaichi/wanna) | 141 |
|[yasyf/summ](https://github.com/yasyf/summ) | 141 |
|[solana-labs/chatgpt-plugin](https://github.com/solana-labs/chatgpt-plugin) | 140 |
|[ssheng/BentoChain](https://github.com/ssheng/BentoChain) | 139 |
|[mallahyari/drqa](https://github.com/mallahyari/drqa) | 139 |
|[petehunt/langchain-github-bot](https://github.com/petehunt/langchain-github-bot) | 139 |
|[dbpunk-labs/octogen](https://github.com/dbpunk-labs/octogen) | 138 |
|[RedisVentures/redis-openai-qna](https://github.com/RedisVentures/redis-openai-qna) | 138 |
|[eunomia-bpf/GPTtrace](https://github.com/eunomia-bpf/GPTtrace) | 138 |
|[langchain-ai/langsmith-sdk](https://github.com/langchain-ai/langsmith-sdk) | 137 |
|[jina-ai/fastapi-serve](https://github.com/jina-ai/fastapi-serve) | 137 |
|[yeagerai/genworlds](https://github.com/yeagerai/genworlds) | 137 |
|[aurelio-labs/arxiv-bot](https://github.com/aurelio-labs/arxiv-bot) | 137 |
|[luisroque/large_laguage_models](https://github.com/luisroque/large_laguage_models) | 136 |
|[ChuloAI/BrainChulo](https://github.com/ChuloAI/BrainChulo) | 136 |
|[3Alan/DocsMind](https://github.com/3Alan/DocsMind) | 136 |
|[KylinC/ChatFinance](https://github.com/KylinC/ChatFinance) | 133 |
|[langchain-ai/text-split-explorer](https://github.com/langchain-ai/text-split-explorer) | 133 |
|[davila7/file-gpt](https://github.com/davila7/file-gpt) | 133 |
|[tencentmusic/supersonic](https://github.com/tencentmusic/supersonic) | 132 |
|[kimtth/azure-openai-llm-vector-langchain](https://github.com/kimtth/azure-openai-llm-vector-langchain) | 131 |
|[ciare-robotics/world-creator](https://github.com/ciare-robotics/world-creator) | 129 |
|[zenml-io/zenml-projects](https://github.com/zenml-io/zenml-projects) | 129 |
|[log1stics/voice-generator-webui](https://github.com/log1stics/voice-generator-webui) | 129 |
|[snexus/llm-search](https://github.com/snexus/llm-search) | 129 |
|[fixie-ai/fixie-examples](https://github.com/fixie-ai/fixie-examples) | 128 |
|[MedalCollector/Orator](https://github.com/MedalCollector/Orator) | 127 |
|[grumpyp/chroma-langchain-tutorial](https://github.com/grumpyp/chroma-langchain-tutorial) | 127 |
|[langchain-ai/langchain-aws-template](https://github.com/langchain-ai/langchain-aws-template) | 127 |
|[prof-frink-lab/slangchain](https://github.com/prof-frink-lab/slangchain) | 126 |
|[KMnO4-zx/huanhuan-chat](https://github.com/KMnO4-zx/huanhuan-chat) | 124 |
|[RCGAI/SimplyRetrieve](https://github.com/RCGAI/SimplyRetrieve) | 124 |
|[Dicklesworthstone/llama2_aided_tesseract](https://github.com/Dicklesworthstone/llama2_aided_tesseract) | 123 |
|[sdaaron/QueryGPT](https://github.com/sdaaron/QueryGPT) | 122 |
|[athina-ai/athina-sdk](https://github.com/athina-ai/athina-sdk) | 121 |
|[AIAnytime/Llama2-Medical-Chatbot](https://github.com/AIAnytime/Llama2-Medical-Chatbot) | 121 |
|[MuhammadMoinFaisal/LargeLanguageModelsProjects](https://github.com/MuhammadMoinFaisal/LargeLanguageModelsProjects) | 121 |
|[Azure/business-process-automation](https://github.com/Azure/business-process-automation) | 121 |
|[definitive-io/code-indexer-loop](https://github.com/definitive-io/code-indexer-loop) | 119 |
|[nrl-ai/pautobot](https://github.com/nrl-ai/pautobot) | 119 |
|[Azure/app-service-linux-docs](https://github.com/Azure/app-service-linux-docs) | 118 |
|[zilliztech/akcio](https://github.com/zilliztech/akcio) | 118 |
|[CodeAlchemyAI/ViLT-GPT](https://github.com/CodeAlchemyAI/ViLT-GPT) | 117 |
|[georgesung/llm_qlora](https://github.com/georgesung/llm_qlora) | 117 |
|[nicknochnack/Nopenai](https://github.com/nicknochnack/Nopenai) | 115 |
|[nftblackmagic/flask-langchain](https://github.com/nftblackmagic/flask-langchain) | 115 |
|[mortium91/langchain-assistant](https://github.com/mortium91/langchain-assistant) | 115 |
|[Ngonie-x/langchain_csv](https://github.com/Ngonie-x/langchain_csv) | 114 |
|[wombyz/HormoziGPT](https://github.com/wombyz/HormoziGPT) | 114 |
|[langchain-ai/langchain-teacher](https://github.com/langchain-ai/langchain-teacher) | 113 |
|[mluogh/eastworld](https://github.com/mluogh/eastworld) | 112 |
|[mudler/LocalAGI](https://github.com/mudler/LocalAGI) | 112 |
|[marimo-team/marimo](https://github.com/marimo-team/marimo) | 111 |
|[trancethehuman/entities-extraction-web-scraper](https://github.com/trancethehuman/entities-extraction-web-scraper) | 111 |
|[xuwenhao/mactalk-ai-course](https://github.com/xuwenhao/mactalk-ai-course) | 111 |
|[dcaribou/transfermarkt-datasets](https://github.com/dcaribou/transfermarkt-datasets) | 111 |
|[rabbitmetrics/langchain-13-min](https://github.com/rabbitmetrics/langchain-13-min) | 111 |
|[dotvignesh/PDFChat](https://github.com/dotvignesh/PDFChat) | 111 |
|[aws-samples/cdk-eks-blueprints-patterns](https://github.com/aws-samples/cdk-eks-blueprints-patterns) | 110 |
|[topoteretes/PromethAI-Backend](https://github.com/topoteretes/PromethAI-Backend) | 110 |
|[jlonge4/local_llama](https://github.com/jlonge4/local_llama) | 110 |
|[RUC-GSAI/YuLan-Rec](https://github.com/RUC-GSAI/YuLan-Rec) | 108 |
|[gh18l/CrawlGPT](https://github.com/gh18l/CrawlGPT) | 107 |
|[c0sogi/LLMChat](https://github.com/c0sogi/LLMChat) | 107 |
|[hwchase17/langchain-gradio-template](https://github.com/hwchase17/langchain-gradio-template) | 107 |
|[ArjanCodes/examples](https://github.com/ArjanCodes/examples) | 106 |
|[genia-dev/GeniA](https://github.com/genia-dev/GeniA) | 105 |
|[nexus-stc/stc](https://github.com/nexus-stc/stc) | 105 |
|[mbchang/data-driven-characters](https://github.com/mbchang/data-driven-characters) | 105 |
|[ademakdogan/ChatSQL](https://github.com/ademakdogan/ChatSQL) | 104 |
|[crosleythomas/MirrorGPT](https://github.com/crosleythomas/MirrorGPT) | 104 |
|[IvanIsCoding/ResuLLMe](https://github.com/IvanIsCoding/ResuLLMe) | 104 |
|[avrabyt/MemoryBot](https://github.com/avrabyt/MemoryBot) | 104 |
|[Azure/azure-sdk-tools](https://github.com/Azure/azure-sdk-tools) | 103 |
|[aniketmaurya/llm-inference](https://github.com/aniketmaurya/llm-inference) | 103 |
|[Anil-matcha/Youtube-to-chatbot](https://github.com/Anil-matcha/Youtube-to-chatbot) | 103 |
|[nyanp/chat2plot](https://github.com/nyanp/chat2plot) | 102 |
|[aws-samples/amazon-kendra-langchain-extensions](https://github.com/aws-samples/amazon-kendra-langchain-extensions) | 101 |
|[atisharma/llama_farm](https://github.com/atisharma/llama_farm) | 100 |
|[Xueheng-Li/SynologyChatbotGPT](https://github.com/Xueheng-Li/SynologyChatbotGPT) | 100 |
_Generated by [github-dependents-info](https://github.com/nvuillam/github-dependents-info)_
`github-dependents-info --repo langchain-ai/langchain --markdownfile dependents.md --minstars 100 --sort stars`

View File

@@ -91,7 +91,7 @@
- [Chat with a `CSV` | `LangChain Agents` Tutorial (Beginners)](https://youtu.be/tjeti5vXWOU) by [Alejandro AO - Software & Ai](https://www.youtube.com/@alejandro_ao)
- [Create Your Own ChatGPT with `PDF` Data in 5 Minutes (LangChain Tutorial)](https://youtu.be/au2WVVGUvc8) by [Liam Ottley](https://www.youtube.com/@LiamOttley)
- [Build a Custom Chatbot with OpenAI: `GPT-Index` & LangChain | Step-by-Step Tutorial](https://youtu.be/FIDv6nc4CgU) by [Fabrikod](https://www.youtube.com/@fabrikod)
- [`Flowise` is an open source no-code UI visual tool to build 🦜🔗LangChain applications](https://youtu.be/CovAPtQPU0k) by [Cobus Greyling](https://www.youtube.com/@CobusGreylingZA)
- [`Flowise` is an open-source no-code UI visual tool to build 🦜🔗LangChain applications](https://youtu.be/CovAPtQPU0k) by [Cobus Greyling](https://www.youtube.com/@CobusGreylingZA)
- [LangChain & GPT 4 For Data Analysis: The `Pandas` Dataframe Agent](https://youtu.be/rFQ5Kmkd4jc) by [Rabbitmetrics](https://www.youtube.com/@rabbitmetrics)
- [`GirlfriendGPT` - AI girlfriend with LangChain](https://youtu.be/LiN3D1QZGQw) by [Toolfinder AI](https://www.youtube.com/@toolfinderai)
- [How to build with Langchain 10x easier | ⛓️ LangFlow & `Flowise`](https://youtu.be/Ya1oGL7ZTvU) by [AI Jason](https://www.youtube.com/@AIJasonZ)

View File

@@ -48,7 +48,6 @@ If youre working on something youre proud of, and think the LangChain comm
Heres where our team hangs out, talks shop, spotlights cool work, and shares what were up to. Wed love to see you there too.
- **[Twitter](https://twitter.com/LangChainAI):** We post about what were working on and what cool things were seeing in the space. If you tag @langchainai in your post, well almost certainly see it, and can show you some love!
- **[Discord](https://discord.gg/6adMQxSpJS):** connect with >30k developers who are building with LangChain
- **[Discord](https://discord.gg/6adMQxSpJS):** connect with over 30,000 developers who are building with LangChain.
- **[GitHub](https://github.com/langchain-ai/langchain):** Open pull requests, contribute to a discussion, and/or contribute
- **[Subscribe to our bi-weekly Release Notes](https://6w1pwbss0py.typeform.com/to/KjZB1auB):** a twice/month email roundup of the coolest things going on in our orbit
- **Slack:** If youre building an application in production at your company, wed love to get into a Slack channel together. Fill out [this form](https://airtable.com/appwQzlErAS2qiP0L/shrGtGaVBVAz7NcV2) and well get in touch about setting one up.

View File

@@ -20,7 +20,7 @@
"from operator import itemgetter\n",
"from langchain.chat_models import ChatOpenAI\n",
"from langchain.memory import ConversationBufferMemory\n",
"from langchain.schema.runnable import RunnablePassthrough\n",
"from langchain.schema.runnable import RunnablePassthrough, RunnableLambda\n",
"from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder\n",
"\n",
"model = ChatOpenAI()\n",
@@ -70,7 +70,7 @@
"outputs": [],
"source": [
"chain = RunnablePassthrough.assign(\n",
" memory=memory.load_memory_variables | itemgetter(\"history\")\n",
" memory=RunnableLambda(memory.load_memory_variables) | itemgetter(\"history\")\n",
") | prompt | model\n"
]
},

View File

@@ -184,7 +184,7 @@
"source": [
"## PromptTemplate + LLM + OutputParser\n",
"\n",
"We can also add in an output parser to easily trasform the raw LLM/ChatModel output into a more workable format"
"We can also add in an output parser to easily transform the raw LLM/ChatModel output into a more workable format"
]
},
{

View File

@@ -42,7 +42,7 @@
"from langchain.chat_models import ChatOpenAI\n",
"from langchain.embeddings import OpenAIEmbeddings\n",
"from langchain.schema.output_parser import StrOutputParser\n",
"from langchain.schema.runnable import RunnablePassthrough\n",
"from langchain.schema.runnable import RunnablePassthrough, RunnableLambda\n",
"from langchain.vectorstores import FAISS\n"
]
},
@@ -338,7 +338,7 @@
"# First we add a step to load memory\n",
"# This adds a \"memory\" key to the input object\n",
"loaded_memory = RunnablePassthrough.assign(\n",
" chat_history=memory.load_memory_variables | itemgetter(\"history\"),\n",
" chat_history=RunnableLambda(memory.load_memory_variables) | itemgetter(\"history\"),\n",
")\n",
"# Now we calculate the standalone question\n",
"standalone_question = {\n",
@@ -363,7 +363,7 @@
" \"docs\": itemgetter(\"docs\"),\n",
"}\n",
"# And now we put it all together!\n",
"final_chain = loaded_memory | expanded_memory | standalone_question | retrieved_documents | answer\n"
"final_chain = loaded_memory | standalone_question | retrieved_documents | answer\n"
]
},
{

View File

@@ -0,0 +1,363 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "79d51519",
"metadata": {},
"source": [
"# Configurable Alternatives\n",
"\n",
"Oftentimes you may want to experiment with, or even expose to the end user, multiple different ways of doing things.\n",
"In order to make this experience as easy as possible, we have defined a `configurable_alternatives` method.\n",
"With this method, you can list out alternatives for any particular runnable that can be set during runtime."
]
},
{
"cell_type": "markdown",
"id": "ac733d35",
"metadata": {},
"source": [
"## With LLMs\n",
"\n",
"Let's take a look at doing this with LLMs"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "430ab8cc",
"metadata": {},
"outputs": [],
"source": [
"from langchain.chat_models import ChatOpenAI, ChatAnthropic\n",
"from langchain.schema.runnable import ConfigurableField\n",
"from langchain.prompts import PromptTemplate"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "71248a9f",
"metadata": {},
"outputs": [],
"source": [
"llm = ChatAnthropic(temperature=0).configurable_alternatives(\n",
" # This gives this field an id\n",
" # When configuring the end runnable, we can then use this id to configure this field\n",
" ConfigurableField(id=\"llm\"),\n",
" # This sets a default_key.\n",
" # If we specify this key, the default LLM (ChatAnthropic initialized above) will be used\n",
" default_key=\"anthropic\",\n",
" # This adds a new option, with name `openai` that is equal to `ChatOpenAI()`\n",
" openai=ChatOpenAI(),\n",
" # This adds a new option, with name `gpt4` that is equal to `ChatOpenAI(model=\"gpt-4\")`\n",
" gpt4=ChatOpenAI(model=\"gpt-4\"),\n",
" # You can add more configuration options here\n",
")\n",
"prompt = PromptTemplate.from_template(\"Tell me a joke about {topic}\")\n",
"chain = prompt | llm"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "e598b1f1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=\" Here's a silly joke about bears:\\n\\nWhat do you call a bear with no teeth?\\nA gummy bear!\")"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# By default it will call Anthropic\n",
"chain.invoke({\"topic\": \"bears\"})"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "48b45337",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=\"Sure, here's a bear joke for you:\\n\\nWhy don't bears wear shoes?\\n\\nBecause they already have bear feet!\")"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We can use `.with_config(configurable={\"llm\": \"openai\"})` to specify an llm to use\n",
"chain.with_config(configurable={\"llm\": \"openai\"}).invoke({\"topic\": \"bears\"})"
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "42647fb7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=\" Here's a silly joke about bears:\\n\\nWhat do you call a bear with no teeth?\\nA gummy bear!\")"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# If we use the `default_key` then it uses the default\n",
"chain.with_config(configurable={\"llm\": \"anthropic\"}).invoke({\"topic\": \"bears\"})"
]
},
{
"cell_type": "markdown",
"id": "a9134559",
"metadata": {},
"source": [
"## With Prompts\n",
"\n",
"We can do a similar thing, but alternate between prompts\n"
]
},
{
"cell_type": "code",
"execution_count": 25,
"id": "9f6a7c6c",
"metadata": {},
"outputs": [],
"source": [
"llm = ChatAnthropic(temperature=0)\n",
"prompt = PromptTemplate.from_template(\"Tell me a joke about {topic}\").configurable_alternatives(\n",
" # This gives this field an id\n",
" # When configuring the end runnable, we can then use this id to configure this field\n",
" ConfigurableField(id=\"prompt\"),\n",
" # This sets a default_key.\n",
" # If we specify this key, the default LLM (ChatAnthropic initialized above) will be used\n",
" default_key=\"joke\",\n",
" # This adds a new option, with name `poem`\n",
" poem=PromptTemplate.from_template(\"Write a short poem about {topic}\"),\n",
" # You can add more configuration options here\n",
")\n",
"chain = prompt | llm"
]
},
{
"cell_type": "code",
"execution_count": 26,
"id": "97eda915",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=\" Here's a silly joke about bears:\\n\\nWhat do you call a bear with no teeth?\\nA gummy bear!\")"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# By default it will write a joke\n",
"chain.invoke({\"topic\": \"bears\"})"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "927297a1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=' Here is a short poem about bears:\\n\\nThe bears awaken from their sleep\\nAnd lumber out into the deep\\nForests filled with trees so tall\\nForaging for food before nightfall \\nTheir furry coats and claws so sharp\\nSniffing for berries and fish to nab\\nLumbering about without a care\\nThe mighty grizzly and black bear\\nProud creatures, wild and free\\nRuling their domain majestically\\nWandering the woods they call their own\\nBefore returning to their dens alone')"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We can configure it write a poem\n",
"chain.with_config(configurable={\"prompt\": \"poem\"}).invoke({\"topic\": \"bears\"})"
]
},
{
"cell_type": "markdown",
"id": "0c77124e",
"metadata": {},
"source": [
"## With Prompts and LLMs\n",
"\n",
"We can also have multiple things configurable!\n",
"Here's an example doing that with both prompts and LLMs."
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "97538c23",
"metadata": {},
"outputs": [],
"source": [
"llm = ChatAnthropic(temperature=0).configurable_alternatives(\n",
" # This gives this field an id\n",
" # When configuring the end runnable, we can then use this id to configure this field\n",
" ConfigurableField(id=\"llm\"),\n",
" # This sets a default_key.\n",
" # If we specify this key, the default LLM (ChatAnthropic initialized above) will be used\n",
" default_key=\"anthropic\",\n",
" # This adds a new option, with name `openai` that is equal to `ChatOpenAI()`\n",
" openai=ChatOpenAI(),\n",
" # This adds a new option, with name `gpt4` that is equal to `ChatOpenAI(model=\"gpt-4\")`\n",
" gpt4=ChatOpenAI(model=\"gpt-4\"),\n",
" # You can add more configuration options here\n",
")\n",
"prompt = PromptTemplate.from_template(\"Tell me a joke about {topic}\").configurable_alternatives(\n",
" # This gives this field an id\n",
" # When configuring the end runnable, we can then use this id to configure this field\n",
" ConfigurableField(id=\"prompt\"),\n",
" # This sets a default_key.\n",
" # If we specify this key, the default LLM (ChatAnthropic initialized above) will be used\n",
" default_key=\"joke\",\n",
" # This adds a new option, with name `poem`\n",
" poem=PromptTemplate.from_template(\"Write a short poem about {topic}\"),\n",
" # You can add more configuration options here\n",
")\n",
"chain = prompt | llm"
]
},
{
"cell_type": "code",
"execution_count": 29,
"id": "1dcc7ccc",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=\"In the forest, where tall trees sway,\\nA creature roams, both fierce and gray.\\nWith mighty paws and piercing eyes,\\nThe bear, a symbol of strength, defies.\\n\\nThrough snow-kissed mountains, it does roam,\\nA guardian of its woodland home.\\nWith fur so thick, a shield of might,\\nIt braves the coldest winter night.\\n\\nA gentle giant, yet wild and free,\\nThe bear commands respect, you see.\\nWith every step, it leaves a trace,\\nOf untamed power and ancient grace.\\n\\nFrom honeyed feast to salmon's leap,\\nIt takes its place, in nature's keep.\\nA symbol of untamed delight,\\nThe bear, a wonder, day and night.\\n\\nSo let us honor this noble beast,\\nIn forests where its soul finds peace.\\nFor in its presence, we come to know,\\nThe untamed spirit that in us also flows.\")"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We can configure it write a poem with OpenAI\n",
"chain.with_config(configurable={\"prompt\": \"poem\", \"llm\": \"openai\"}).invoke({\"topic\": \"bears\"})"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "e4ee9fbc",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=\"Sure, here's a bear joke for you:\\n\\nWhy don't bears wear shoes?\\n\\nBecause they have bear feet!\")"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# We can always just configure only one if we want\n",
"chain.with_config(configurable={\"llm\": \"openai\"}).invoke({\"topic\": \"bears\"})"
]
},
{
"cell_type": "markdown",
"id": "02fc4841",
"metadata": {},
"source": [
"## Saving configurations\n",
"\n",
"We can also easily save configured chains as their own objects"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "5cf53202",
"metadata": {},
"outputs": [],
"source": [
"openai_poem = chain.with_config(configurable={\"llm\": \"openai\"})"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "9486d701",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"AIMessage(content=\"Why don't bears wear shoes?\\n\\nBecause they have bear feet!\")"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"openai_poem.invoke({\"topic\": \"bears\"})"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a43e3b70",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.1"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -101,7 +101,7 @@
"source": [
"Here the input to prompt is expected to be a map with keys \"context\" and \"question\". The user input is just the question. So we need to get the context using our retriever and passthrough the user input under the \"question\" key.\n",
"\n",
"Note that when composing a RunnableMap when another Runnable we don't even need to wrap our dictuionary in the RunnableMap class — the type conversion is handled for us."
"Note that when composing a RunnableMap when another Runnable we don't even need to wrap our dictionary in the RunnableMap class — the type conversion is handled for us."
]
},
{

View File

@@ -31,3 +31,6 @@ How to use core features of LCEL
#### [Cookbook](/docs/expression_language/cookbook)
Examples of common LCEL usage patterns
#### [Why use LCEL](/docs/expression_language/why)
A deeper dive into the benefits of LCEL

Some files were not shown because too many files have changed in this diff Show More