Commit Graph

323 Commits

Author SHA1 Message Date
Jacob Lee c8d4e6bf7e Adds structured tool chat agent and DynamicStructuredTool class (#1103)
* [WIP] Structured tool input agent

* Clean up typing

* Update StructuredChatAgent prompt, adds integration test and validation preventing StructuredTools being passed into existing agents

* Undo change to make existing agents less strictly typed, use overload signatures for initialize

* Update parsing logic for retries

* Update test cases

* Progress on structured chat agent

* Pass tool names into structured chat output fixing parser for more reliability

* Revert output parser getFormatInstructions method signature change

* Adds StructuredDynamicTool, docs

* add renderTemplate call to format instructions, change StructuredDynamicTool to DynamicStructuredTool

* Formatting

---------

Co-authored-by: vowelparrot <130414180+vowelparrot@users.noreply.github.com>
Co-authored-by: Jacob Lee <jacob@autocode.com>
Co-authored-by: Nuno Campos <nuno@boringbits.io>
2023-05-19 15:48:09 +01:00
Fan c92ba9beaa feat: add Faiss as VectorStore provider (#685)
* add faiss

* add pickle support

* replace pickle.js with pickleparser package

* yarn install

* update pickleparser

* fix code review

* fix metadata in loadFromPython

* add docs

* add test cases

* port  form python

* Save mapping into JSON file.

* upgrader pickleparser

* upgrade pickleparser

* make loadFromPython work

* upgrade pickleparser

* upgrade pickleparser and use reduce function

* update demo and docs

* fix doc build

* update docs

* add more ut and fix import of pickleparser

* update docs

* add int test for loadFromPython

* add more int test for loadFromPython

* fix merge error

* upgrade pickleparser

* upgrade pickleparser and fix code review

* yarn install

* port #1142

* use chained register

* fix lint

* fix format

* Update examples, update imports, remove extraneous deps from merge

* Undo change to imports

---------

Co-authored-by: Nuno Campos <nuno@boringbits.io>
2023-05-18 18:07:30 +01:00
Nuno Campos 0cc685e5d0 Update sagemaker doc 2023-05-18 16:28:31 +01:00
Nuno Campos 603f243ee0 Add verbose env var (#1317) 2023-05-18 15:15:12 +01:00
David Duong 0f62af5026 Add option to return used SQL in SqlDatabaseChain (#1313)
* Add option to return used SQL in SqlDatabaseChain

* Cleanup examples
2023-05-18 13:46:36 +01:00
Priya X. Pramesi 74e49883bb New feat: Self Query Retriever (#1266)
* self-query with meriyah

* removed builtin translators so end-user needs to specify their own translator, but a basic translator that can be used with pinecone and chroma is included and can be imported

* fixed class name typo

* moved meriyah to main dependency so expression parser can work in test-exports-*

* added back self_query to entrypoints

* moved meriyah to dev/peer dep, fixed unused parser types, minor fixes

* renaming expression type to reflect meriyah better

* removed unused lint disable on self_query/base.ts
2023-05-18 13:11:43 +01:00
Christopher M 6f6d60a642 feat: Add sagemaker endpoint support (#1267)
* feat: Add sagemaker endpoint support

* fix: Add missing export for SagemakerEndpoint

* fix: Align kwargs types with codebase for sagemaker endpoint

* chore: Add integration test for sagemaker_endpoint

* feat: Add docs for sagemaker endpoint llm

* Update SageMaker endpoint args, integration test, imports, docs

* Fix typo

* Use async caller

---------

Co-authored-by: Jacob Lee <jacoblee93@gmail.com>
Co-authored-by: Nuno Campos <nuno@boringbits.io>
2023-05-18 13:11:23 +01:00
Nuno Campos 6dc56f8d0a Update vectorstore toolkit example (#1297)
* Update vectorstore toolkit example

* Improve docs for supabase metadata filtering

* Update hnswlib examples

* Fix links
2023-05-17 20:40:24 +01:00
David Duong d60eae5995 Use a JS based tokenizer for token counting (#1239)
* Use a rewritten tiktoken for token counting

* Fix lint, add test

* Fix type import, typo

* Remove @dqbd/tiktoken as "weak" dependency

* Move JS implementation of tiktoken into a separate package

* Upgrade to js-tiktoken@1.0.2

* Replace all occurrences of @dqbd/tiktoken

* Avoid bundling ranks, fix test with CRA

* Use AsyncCaller, cache promises

* Remove WASM configuration changes

* Upgrade to 1.0.6 for CRA fixes, mark js-tiktoken/lite as an external dependency

* Remove next.config.js
2023-05-17 14:44:29 +01:00
Jacob Lee dc5dee0631 Merge pull request #1285 from dhruv-anand-aintech/dhruv
fix: typo (missing word "simple")
2023-05-16 17:53:41 -07:00
Jacob Lee baa4c9cf43 Update api.mdx 2023-05-16 14:39:42 -07:00
Dhruv Anand 6cb3a7e147 fix: typo (missing word "simple") 2023-05-16 22:54:41 +05:30
RohitMidha23 be3f5cbad1 feat: entity memory (#680)
* init entity_memory

* init tests

* added test

* fixed test

* updated prompts usage

* fixed import

* added test for pre loaded messages

* updated import

* Use object without prototype for safer exists check

* move entity store to its own file, make it async

* Add example, not giving great results for now

* Prompt updates to support reflexive pronouns, keep entity summaries unchanged, support chat models, add docs

* Remove merge artifact

* Fix test

* Format fix

---------

Co-authored-by: Nuno Campos <nuno@boringbits.io>
Co-authored-by: Jacob Lee <jacoblee93@gmail.com>
2023-05-16 18:24:35 +01:00
mvaker fc7fc868aa Add Redis VectorStore (#1153)
* feat: add Redis vectorstore with tests

* fix linting and formatting problems

* docs: add redis vector store

* fix: remove export from deprecated vectorstores index

* docs: add node.js-only compatibility tip to redis vectorstore

* Update types, add more optional config, move examples out of md file

* Use more recent chain in example

* Update tests

* Mark entrypoint as optional dep

* Fix import

* Fix build error

---------

Co-authored-by: Nuno Campos <nuno@boringbits.io>
2023-05-16 18:24:09 +01:00
Jacob Lee 1ed96d124a Merge pull request #1271 from hwchase17/jacoblee/apify
Add Apify integration, update docs
2023-05-15 13:48:09 -07:00
Jacob Lee 6b4b2ca454 Adds examples and docs 2023-05-15 11:52:08 -07:00
Jacob Lee ce5042dd74 Remove ApifyWrapper references 2023-05-15 09:51:33 -07:00
Amijakan 3300abe340 Fixed typo with example
includeTables => includesTables
2023-05-15 10:21:09 -04:00
František Nesveda 32816c04d2 Merge remote-tracking branch 'upstream/main'
# Conflicts:
#	docs/docs/modules/agents/tools/integrations/index.mdx
#	langchain/package.json
#	yarn.lock
2023-05-15 14:48:33 +02:00
Chris Toomey ace3ee7029 Adding Redis Memory Support (#951)
* Merge post upstream sync (#1)

* Added RedisMemory with tests and docs

* fixed Redis test file name

* TODOs for quick refactor

* updated memory to accept a client

* Added TODOS

* ongoing testing

* Updated tests

* Updated tests for memory return option

* finalized tests + updated docs

* Adding docs

* Readded init and cleaned up func

* fixed test typing

* redo yarn lock

* remove yarn.lock

* updated yarn lock and namespaced redis

* fix merge conflict

* updated BaseChatMemoryInput

* Updated with lint fixes

* Fixed docs to match memory instantiation

* yarn format docs

* Merging fixes to address ForkPR comments (#2)

* updating for pr

* Removed redis_memory in favor of chat memory

* Fixed tests and updated docs

* Bump docs

* lint results

* fixes from lint and format

---------

Co-authored-by: Chris Toomey <ctoomey@fb.com>

* Update RedisChatMessageHistory class to initialize a client internally

* Update Redis chat message history docs to reflect the fact that Redis is a peer dependency, allow direct passing of Redis client

* Patch typing issues with passing node-redis client directly into a RedisChatMessageHistory instance

---------

Co-authored-by: Chris Toomey <ctoomey@fb.com>
Co-authored-by: Jacob Lee <jacoblee93@gmail.com>
2023-05-11 17:14:21 +01:00
Pranav Malvawala dad9643c97 fix: typo in schema docs (#1198) 2023-05-11 12:22:11 +01:00
Nuno Campos 7fa918188a Implement cancellation and timeout for all LLMs, allow passing LLM call options via LLMChain (like was already possible for stop) (#1182)
* Implement cancellation and timeout for all LLMs, allow passing LLM call options via LLMChain (like was already possible for stop)

* Update example

* Add declared ParsedCallOptions type for BaseLanguageModels, add signal support for chat models, add tests

* Update docs for chat models

* Update llm and chat examples to remove `run` func

* Add more examples for LLMChain

* Reorganise agent docs, add Additional Functionality doc for Agents

* Add toc in llm chain docs

* Format

---------

Co-authored-by: Jacob Lee <jacoblee93@gmail.com>
2023-05-11 12:21:48 +01:00
Nuno Campos 8200eff813 Merge pull request #1199 from jacoblee93/feature_plan_and_execute
Adds plan-and-execute style agent
2023-05-10 16:31:27 +01:00
Nuno Campos b331d130f9 Docs update 2023-05-10 15:30:03 +01:00
Jacob Lee 5cf0bbd397 Update plan and execute prompt to avoid assumptions on specific tools, add docs 2023-05-09 22:54:48 -07:00
Priya X. Pramesi 3725a91951 Router chain (MultiRetrievalQAChain & MultiPromptChain) (#1150)
* multi-router

* multi router added. before examples and docs

* multi router added.

* added multi prompt and multi qa docs and examples

* rename structured parser instruction function

* changed structured parser _schemaToInstruction schema type. Handle nullable.

* Update utils.ts

change ++ to += 1

* Update llm_router.ts

Removed zod from RouterOutputSchema

* multi retrieval utils zipEntries correct type

* mini formatting

* added multi chains names

* merged with latest main, created JsonMarkdownStructuredOutputParser

* added BaseOutputParser FormatInstructionsOptions

* fixed comment on output_parser

* Lint

* Fix constructor args

---------

Co-authored-by: Nuno Campos <nuno@boringbits.io>
2023-05-09 19:32:32 +01:00
Killinsun - Ryota Takeuchi 24266d80ef [Doc][QuickStart] Move steps forget to move (#1163)
* Remove steps forget to delete

* CR fix

* CR fix

* formatter
2023-05-09 10:22:46 +01:00
ju 9abbd0c24d Add new output parser CustomListOutputParser that allows for more specificity (#1045)
* Add new output parser  allows for more specificity

* Update test

* Update example

---------

Co-authored-by: Nuno Campos <nuno@boringbits.io>
2023-05-08 18:17:50 +01:00
Nuno Campos 3c34856a99 Update wording on vercel install instructions (#1165) 2023-05-08 18:16:20 +01:00
Zak Miller 71a8acbbfc Fix typo in additional_functionality.mdx (#1151)
Typo where "ChatOpenAI" should be "OpenAIEmbeddings"
2023-05-08 16:52:17 +01:00
Soichi Saito 7fa3c963e7 Add dynamodb chat message history (#1016)
* Add dynamodb chat message history

* Some updates to deps and interfaces

* Use list_append method to add messages in DynamoDBChatMessageHistory, docs, tests, and other fixups

* Move DynamoDB message store into its own entrypoint, update docs

* Fix typo

---------

Co-authored-by: Nuno Campos <nuno@boringbits.io>
Co-authored-by: Jacob Lee <jacob@autocode.com>
Co-authored-by: Jacob Lee <jacoblee93@gmail.com>
2023-05-08 16:42:01 +01:00
Killinsun - Ryota Takeuchi dcef8eaa1c [ConversationalRetrievalQAChain] Fix wrong return type in Doc (#1140)
* fix

* Fixed snippets not being interpreted
2023-05-06 15:30:48 +01:00
Jacob Lee 13a37bcd32 MRKL prompt fix, integration test (#1138)
* MRKL prompt fix, integration test

* Lint and format

---------

Co-authored-by: Jacob Lee <jacob@autocode.com>
2023-05-06 14:47:07 +01:00
Nuno Campos b174eb0542 Update azure docs 2023-05-05 17:22:40 +01:00
Mishkin Faustini f6f06e0366 feat: Added filtering ability to supabase (#905)
* Added filtering ability to supabase

* Supabase metadata filter polish: small fix, adds integration test, update docs

* Skip Supabase integration test reliant on outside setup

* Use FakeEmbeddings in unit test

* Update docs

---------

Co-authored-by: Jacob Lee <jacob@autocode.com>
2023-05-05 17:22:06 +01:00
Jacob Lee 4e22af2481 Add API key support to Unstructured loaders (#1128)
* feat: support unstructured api key in loader

* add API key to instructions and examples

* change api key order

* update integration tests

* retrigger build

* default web path to hosted api

* moved api key to an options argument

* interface for unstructured options

* linting, linting, linting

* refactor loaders into mapping

* move webpath to options

* update function calls in test

* fix examples

* linting, linting, linting ...

* Adds shim for existing Unstructured users

* Remove bad content type header from Unstructured API call

* Fix md formatting

* Small fixes

* Move additional UnstructuredDirectoryLoader constructor options into an options object

* Remove extra unnecessary declaration

---------

Co-authored-by: Matt Robinson <mrobinson@unstructuredai.io>
Co-authored-by: Matt Robinson <mrobinson@unstructured.io>
Co-authored-by: Jacob Lee <jacob@autocode.com>
Co-authored-by: Nuno Campos <nuno@boringbits.io>
2023-05-05 16:58:28 +01:00
dersia 3495a79e6f Added implementation for Azure OpenAI (#966)
* added support for Azure OpenAI. Also added other Azure OpenAI parameters to make experience better

* added azure openai to docs and samples

* fixed linting and formatting

* Added tests for exports. merged all different openai input types into a more general types definition

* fixed rebase issues

* cleanup

* Cleanup. Also added two new settings/envvars for azure, so different deployments can be used for chat, completion and embeddings.

* Update embeddings

* Add missing exports

* Do not use types that arent exported

---------

Co-authored-by: Nuno Campos <nuno@boringbits.io>
2023-05-05 16:27:36 +01:00
Nuno Campos bd27d17152 Implementation of a VectorStoreMemory (#452)
* Implementation of a VectorStoreMemory

* Revise implementation to match py, add test

* Add export

* Add example

* Add docs
2023-05-05 10:20:53 +01:00
Nicolas 6dca29768a docs: Mendable search v93 (#1130) 2023-05-05 09:58:23 +01:00
Nuno Campos 7ce27308de Merge pull request #1118 from martinseanhunt/confluence-loader
Confluence loader
2023-05-04 16:48:42 +01:00
Nuno Campos e85d4dd4ae Merge pull request #1099 from jacoblee93/pr_919
Docs fixes, parameter shim for #919
2023-05-04 16:27:00 +01:00
Nuno Campos de5783f8eb Add node-only alter 2023-05-04 16:24:09 +01:00
Nuno Campos 05192061fc Add install dep 2023-05-04 16:21:33 +01:00
Priya X. Pramesi 67e115e224 Added constitutional chain (#992)
* added constitutional chain translated from the main python langchain repo

* added pure for side effect handling

* fixed constitutional chain tests

* forgot formatting last time

* added constitutional chain doc and example
2023-05-04 12:50:43 +01:00
Priya X. Pramesi 9ffb159892 Added moderation chain (#1061)
* added moderation chain

* changed the integration test example to something less extreme

* Use fetch adapater, consistent naming, consistent args

* Use async caller

* added example and docs

* formatting fix

---------

Co-authored-by: Nuno Campos <nuno@boringbits.io>
Co-authored-by: Priya X. Pramesi <ppramesi@visi8.com>
2023-05-04 12:50:16 +01:00
Justin Rahardjo 0fe7aac385 feat: added returnIntermediateSteps flag to MapReduceChain (#1080)
* feat: added returnIntermediateSteps flag to MapReduceChain

* docs: addded extra documentation around the intermediate steps

* fix: linting issue

* docs: set map_reduce in backticks

* feat: added  option to loadQAChain as well

* Populate params via destructuring, adds unit test

* Lint

---------

Co-authored-by: Jacob Lee <jacob@autocode.com>
Co-authored-by: Nuno Campos <nuno@boringbits.io>
2023-05-04 12:43:52 +01:00
katsumata 0eccc85c6d Add TimeWeightedVectorStoreRetriever to retrievers (#911)
* feat: Introduce Time-Weighted Retrieval for Relevant Documents

- Add new file `time_weighted.ts` with functions to retrieve, add, and get documents from a vector store
- Define `TimeWeightedVectorStoreRetriever` class that inherits from `BaseRetriever`
- Include functions to calculate scores and hours passed to help identify salient documents

* test: Add tests for time weighted retrievers.

- Add new test file for time weighted retrievers
- Implement several tests for TimeWeightedVectorStoreRetriever's getRelevantDocuments method with different data and searchKwargs values

* refactor: Refactor TimeWeightedVectorStoreRetriever for better organization.

- Refactored code in TimeWeightedVectorStoreRetriever for better organization
- Combined memoryDocsAndScores and salientDocsAndScores for easy retrieval
- Changed method names for better descriptive naming consistency

* refactor: Reorganize retrievers exports in langchain codebase

- Reorganize exports in the `index.ts` file in the `retrievers` directory
- Move `MetalRetriever` and `RemoteLangChainRetriever` exports to the top
- Add `TimeWeightedVectorStoreRetriever` export at the bottom for improved organization

* feat: Refactor TimeWeightedVectorStoreRetriever interface and add tests

- Improve time-weighted retriever functionality
- Add JSDoc comments for key retriever functions
- Refactor tests for better isolation and add tests for new functionality
- Expose new interface for retriever in index file

* refactor: Refactor time-weighted retriever constructor and add JSDoc comments

- Simplified the constructor arguments using optional chaining and default values.
- Improved code clarity by adding JSDoc comments for private functions.
- Renamed variable for better understanding of its purpose.
- Removed unnecessary keyword in a method.

* refactor: Refactor test file naming convention.

- Rename `time_weighted3.js` to `time_weighted.js` in the `time_weighted.test.ts` file in `langchain/src/retrievers/tests`.
- No significant changes to other files were made.

* style: Improve code style in retrievers index file

- Add missing comma to SupabaseHybridSearchParams
- Reformat import statements in retrievers/index.ts
- Improve code readability and maintainability in langchain/src/retrievers/

* style: Remove unused eslint-disable comments in test file

- Remove unnecessary eslint-disable comments in the `time_weighted.test.ts` file
- Improve code readability and maintainability
- Enhance overall code quality and consistency

* Lint

* Unod changes to index

* Add entrypoint

* Adds thrown error when using TimeWeightedVectorStoreRetriever on unsupported vector stores, adds docs and test

---------

Co-authored-by: Nuno Campos <nuno@boringbits.io>
Co-authored-by: Jacob Lee <jacob@autocode.com>
2023-05-04 12:43:16 +01:00
Antonio Ulloa 220c47ecd8 Adding contextual compression with an LLMChainExtractor (#975) 2023-05-04 10:46:04 +01:00
Martin Hunt 3a9bb18a2d mark as requiring optional dependency (html-to-text) and mark as node only 2023-05-03 22:37:21 +01:00
Jan Čurn 163e36df43 Better copy for Apify intergration (#2) 2023-05-03 20:24:03 +02:00