Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #
🤖 AI-Generated PR Description (Powered by Amazon Bedrock)
Description
This pull request introduces several enhancements and modifications to the language model integration and chat functionality. The primary changes include:
langchain_integration
module, including modifications to thechains
,chat_models
, and the addition of a newmodel_config.py
file.common_utils/constant.py
file.common_entry.py
file, which handles the online entries for the application.ChatBot.tsx
file in the portal's frontend.These changes aim to improve the overall performance, functionality, and integration of the language models with the application's chat and query handling capabilities.
Type of change
File Stats Summary
File number involved in this PR: 10, unfold to see the details:
The file changes summary is as follows:
Claude2ToolCallingChain
class into a genericToolCallingChain
class and dynamically creates subclasses for different models based on configurations.DEFAULT
to theLLMModelType
class, and includes several other model types for the Anthropic Claude language model.ChatChain
class that sets default model kwargs and handles common logic.chain_classes
that dynamically creates chat chain classes for all models defined inMODEL_CONFIGS
.| source/lambda/online/common_logic/langchain_integration/chains/query_rewrite_chain.py | 10 added, 32 removed | The code changes introduce a new
QueryRewriteChain
class that uses the default model specified inMODEL_CONFIGS
. It also dynamically creates chain classes for all models inMODEL_CONFIGS
for theQUERY_REWRITE_TYPE
task, and adds them to the global namespace. || source/lambda/online/common_logic/langchain_integration/chains/init.py | 154 added, 120 removed | This code change introduces a new way to dynamically create LLM chain classes based on the model ID and intent type. It adds methods to convert model IDs to valid Python class names, and a factory method
create_for_model
to create a new chain class dynamically. It also reorganizes the imports of different chain types into separate functions and updates the global namespace accordingly. |🤖 AI-Generated PR Description (Powered by Amazon Bedrock)
Description
This pull request introduces several changes to the codebase, primarily focused on enhancing the integration with LangChain and improving the chat functionality. The modifications span multiple files and directories, including the common utilities, LangChain integration components, and the chatbot user interface.
The key changes include:
constant.py
file to accommodate new constants or modify existing ones.chat_chain.py
,query_rewrite_chain.py
,rag_chain.py
, andtool_calling_chain_api.py
, to improve the chat experience and enhance the functionality of the language model.bedrock_models.py
file, which likely involves changes to the underlying language models used in the application.model_config.py
, which potentially introduces configuration settings for the language models.common_entry.py
file, which may affect the common entry point for the online lambda function.ChatBot.tsx
file in the portal's source code, suggesting updates to the chatbot user interface.Type of change
File Stats Summary
File number involved in this PR: 11, unfold to see the details:
The file changes summary is as follows:
DEFAULT
in theLLMModelType
class, and adds three new model types:CLAUDE_INSTANCE
,CLAUDE_2
, andCLAUDE_21
.BedrockModel
class that replaces the previous model-specific classes likeClaude2
,Claude21
, etc. It dynamically creates model classes based on theMODEL_CONFIGS
and adds them to the module's global namespace. This change likely aims to simplify and centralize model configuration management.ChatChain
that extendsLLMChain
for chat-based language models. It also defines a dictionarychain_classes
that maps model IDs to their correspondingChatChain
subclasses, which are dynamically created usingLLMChain.create_for_model
. The subclasses are then added to the global namespace.create_for_model
method, which takes the model ID and task type as arguments. Additionally, it removes the individual class definitions for specific models like Claude and replaces them with a singleQueryRewriteChain
class that uses theLLMModelType.DEFAULT
model ID.model_id_to_class_name
method to convert the model ID to a valid Python class name, and acreate_for_model
method to create a new chain class dynamically using the model configuration. It also reorganizes the imports of various chain classes and consolidates some of them into separate modules.create_for_model
in theModel
class to create a model instance based on the provided model ID. It also adds a helper methodmodel_id_to_class_name
to convert the model ID to a valid Python class name. Additionally, it refactors the import statements for different model classes and updates the_import_bedrock_models
function to use a more concise approach.🤖 AI-Generated PR Description (Powered by Amazon Bedrock)
Description
This pull request introduces several updates and improvements to the LangChain integration and chat functionality. The main changes include:
model_config.py
file to centralize model configuration settings.These changes aim to enhance the overall performance, scalability, and maintainability of the LangChain integration and chat functionality within the application.
Type of change
File Stats Summary
File number involved in this PR: 12, unfold to see the details:
The file changes summary is as follows:
DEFAULT
to theLLMModelType
class, likely representing a default model ID for language models.BedrockModel
class that serves as a base class for different language models. It imports theMODEL_CONFIGS
from themodel_config
module and dynamically creates model classes based on the configurations. The model classes are added to the module's global namespace for easy access.QueryRewriteChain
class that uses theLLMModelType.DEFAULT
model and achain_classes
dictionary that dynamically creates chain classes for all available models inMODEL_CONFIGS
. The previously defined model-specific chain classes are removed.create_for_model
in theModel
class, which dynamically creates a new class for a given model ID using the configurations fromMODEL_CONFIGS
. It also refactors the import statements for different model classes and updates themodel_id_to_class_name
method to handle model IDs with version numbers and vendor prefixes.RagChain
class that serves as a base class for all RAG (Retrieval-Augmented Generation) chains. It simplifies the codebase by consolidating multiple model-specific chain classes into a single class that dynamically creates chains for different models using theMODEL_CONFIGS
dictionary. Additionally, it adds a dictionarychain_classes
that maps model IDs to their corresponding chain classes, making it easier to access and instantiate chains for different models.create_for_model
in theLLMChain
class, which dynamically creates a new class for a specific model based on the model ID and intent type. It also adds a helper methodmodel_id_to_class_name
to convert the model ID to a valid Python class name. Additionally, it refactors the import statements for various chain modules, using a centralizedchain_classes
dictionary to store the imported classes and updating the global namespace accordingly.🤖 AI-Generated PR Description (Powered by Amazon Bedrock)
Description
This pull request introduces changes to integrate the LangChain library for natural language processing and model management. The main updates include:
model_config.py
to handle the configuration and loading of language models.chat_chain.py
,query_rewrite_chain.py
,rag_chain.py
,tool_calling_chain_api.py
) to incorporate LangChain components.bedrock_models.py
file to support LangChain model integration.common_entry.py
to utilize the new LangChain chains and models.ChatBot.tsx
andconst.ts
files to accommodate the backend changes.The primary motivation behind this change is to leverage the powerful capabilities of LangChain for natural language processing tasks, such as question answering, text generation, and model management. LangChain provides a modular and extensible framework for building applications with language models.
This change does not require any external dependencies beyond the LangChain library itself.
Type of change
File Stats Summary
File number involved in this PR: 12, unfold to see the details:
The file changes summary is as follows:
HISTORY_CHATBOT_ID
to the existing set of constants.DEFAULT
in theLLMModelType
class, likely representing a default model identifier, and adds three constants for different versions of the Claude language model from Anthropic.MODEL_CONFIGS
module. TheBedrockModel
class serves as a base class for all models, and themodel_classes
dictionary maps model IDs to their corresponding instances.QueryRewriteChain
class that uses a default model specified inMODEL_CONFIGS
. It also adds all available query rewrite chain classes to the module's global namespace based on the models defined inMODEL_CONFIGS
.ChatChain
for LLM chat chains, with a default model type and model parameters. It also adds a dictionarychain_classes
that maps model IDs to their correspondingChatChain
subclasses, which are dynamically created using theMODEL_CONFIGS
and added to the global namespace.RagChain
that serves as a base class for all RAG (Retrieval-Augmented Generation) chains, replacing the previousClaude2RagLLMChain
. It also removes several model-specific RAG chain classes and instead dynamically creates chain classes for all available models using a dictionary comprehension. The system prompt addition logic is also refactored into a separate function.model_id_to_class_name
to convert model IDs to valid Python class names, and a factory methodcreate_for_model
to dynamically create model classes based on configurations. It also refactors the import statements for bedrock models.model_id_to_class_name
method to convert model IDs to valid Python class names, and acreate_for_model
factory method to create a new LLMChain subclass for a specific model and intent type. It also reorganizes the imports of different chain types into separate functions.