langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
92.4k stars 14.78k forks source link

Feature Request: Add decorator function to register custom components (agents, tools, etc) #1360

Closed ajndkr closed 1 year ago

ajndkr commented 1 year ago

Description

Motivation

Using configuration files are great for fast prototyping but given the current state of the framework, it is limited to pre-defined agents, tools and other components. Currently the load_tools() function is implemented to load pre-defined tools via tool name.

https://github.com/hwchase17/langchain/blob/fe7dbecfe6f5c4f9ad3237148fb25c91cf5be9f6/langchain/agents/load_tools.py#L179

For custom implementations, I don't suppose we can use the above function to load them.

Proposed solution

I suggest we create a decorator function for all components which can be initialised via config file. We can take inspiration from the ClassyVision project:

https://github.com/facebookresearch/ClassyVision/blob/74e83dd97afbc9371b336304af09548f5080fa9c/classy_vision/models/__init__.py#L27

Even Pytorch Lightning Flash has a similar concept: https://lightning-flash.readthedocs.io/en/latest/general/registry.html?highlight=registry

Benefits

Enabling fast prototyping for users in a deep learning research/experimentation fashion can greatly speed up development of applications using LangChain.

dosubot[bot] commented 1 year ago

Hi, @ajndkr! I'm here to help the LangChain team manage their backlog and I wanted to let you know that we are marking this issue as stale.

From what I understand, you made a feature request to add a decorator function for registering custom components in the LangChain framework. The goal is to enhance flexibility in initializing components through a configuration file, taking inspiration from projects like ClassyVision and Pytorch Lightning Flash.

However, there hasn't been any activity on this issue yet, and it remains unresolved.

Could you please let us know if this issue is still relevant to the latest version of the LangChain repository? If it is, please comment on the issue to inform the LangChain team. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the LangChain project!