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.🤖 AI-Generated PR Description (Powered by Amazon Bedrock)
Description
This pull request introduces changes to the LangChain integration and the chatbot frontend. The main modifications are:
model_config.py
file to centralize the configuration of LangChain models.These changes aim to enhance the overall performance, scalability, and maintainability of the chatbot 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, representing a default model identifier.ToolCallingBaseChain
for tool calling chains, replacing the previous model-specific classes likeClaude2ToolCallingChain
. It dynamically creates chain classes for all available models using theMODEL_CONFIGS
instead of hardcoding them.QueryRewriteBaseChain
for query rewriting task chains, and dynamically creates chain classes for all available models defined inMODEL_CONFIGS
. It removes the hard-coded subclasses for specific models like Claude variants, and instead generates the subclasses programmatically based on the model configurations.BedrockBaseModel
that extends theModel
class, and defines a dictionarymodel_classes
that maps model IDs to their corresponding model classes. The model classes are dynamically created using theBedrockBaseModel.create_for_model
method and theMODEL_CONFIGS
imported frommodel_config
.create_for_model
to dynamically create a model class 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 simplifies the import of bedrock models by using a singlemodel_classes
import instead of individual imports.RagBaseChain
for RAG (Retrieval-Augmented Generation) LLM chains, which dynamically creates chain classes for different LLM models based on the configurations inMODEL_CONFIGS
. It replaces the previous approach of defining individual chain classes for each model.ChatBaseChain
for handling chat-based language model interactions. It defines a default model ID, task type, and model parameters. Several existing chat chain classes are modified to inherit fromChatBaseChain
instead ofClaude2ChatChain
. Additionally, a dictionarychain_classes
is created to dynamically generate chat chain classes for each model configuration defined inMODEL_CONFIGS
.🤖 AI-Generated PR Description (Powered by Amazon Bedrock)
Description
This pull request introduces several enhancements and modifications to the codebase, primarily focused on improving the integration with LangChain, a framework for building applications with large language models. The changes include updates to various utility functions, chain implementations, and chat model configurations.
Some notable changes are:
constant.py
andprompt_utils.py
files in thecommon_utils
module, likely related to handling constants and prompt generation.chat_chain.py
,conversation_summary_chain.py
,query_rewrite_chain.py
,rag_chain.py
, andtool_calling_chain_api.py
, which may involve improvements or bug fixes related to these specific chains.model_config.py
in thelangchain_integration
module, which is likely responsible for managing configurations related to language models.bedrock_models.py
file in thechat_models
module, potentially introducing changes to the handling of Bedrock language models.common_entry.py
file in theonline_entries
module, which may affect the common entry point for online functionality.ChatBot.tsx
file in theportal/src/pages/chatbot
directory, suggesting updates to the chatbot user interface.const.ts
file in theportal/src/utils
directory, which may involve modifications to constant values used throughout the application.Type of change
File Stats Summary
File number involved in this PR: 14, unfold to see the details:
The file changes summary is as follows:
all_knowledge_rag_tool
variable, using double quotes for the dictionary key instead of single quotes.HISTORY_CHATBOT_ID
, use it to store and retrieve the chatbot ID from localStorage, and remove the stored chatbot ID when manually changing the chatbot option.ChatBaseChain
that inherits fromLLMChain
and defines common properties and methods for chat-based LLM chains. It also importsMODEL_CONFIGS
andLLMModelType
andLLMTaskType
from other modules. Additionally, it creates a dictionarychain_classes
that maps model IDs to their corresponding chat chain classes, which are dynamically created using thecreate_for_model
method ofChatBaseChain
.BedrockBaseModel
that extends theModel
class and uses theLLMModelType.DEFAULT
model ID. It also imports theMODEL_CONFIGS
frommodel_config
. Instead of defining individual model classes likeClaude2
,ClaudeInstance
, etc., it creates a dictionarymodel_classes
that maps model IDs fromMODEL_CONFIGS
to their respective model classes dynamically created usingBedrockBaseModel.create_for_model()
.RagBaseChain
for RAG (Retrieval-Augmented Generation) LLM chains, which uses a default model type. It also removes specific classes for different model types (e.g., Claude2RagLLMChain, Claude21RagLLMChain) and instead dynamically creates chain classes for all available model configurations using a dictionary comprehension.QueryRewriteBaseChain
is created with a default model type.chain_classes
is created to dynamically generate query rewrite chain classes for all available models. || source/lambda/online/common_logic/langchain_integration/chains/init.py | 143 added, 121 removed | This code change introduces a dynamic class creation mechanism for LLMChains based on model configurations. It adds a new method
create_for_model
that generates a new class for a specific model ID and intent type. The class name is derived from the model ID using a naming convention. The new class inherits from the base LLMChain class and has pre-defined attributes likeintent_type
,model_id
, anddefault_model_kwargs
based on the model configuration. Additionally, it refactors the import statements for different chain types into separate functions and adds a newchain_classes
module for each chain type. || source/lambda/online/common_logic/langchain_integration/chat_models/init.py | 97 added, 43 removed | The code changes introduce a new factory method
create_for_model
in theModel
class to dynamically create a model class based on the provided model ID. It also adds support for several new models, including variations of Claude and LLaMa models for different regions (US, EU, APAC). Themodel_classes
module is imported instead of importing individual model classes directly. Additionally, themodel_id_to_class_name
method is added to convert model IDs to valid Python class names. || source/lambda/online/common_logic/langchain_integration/chains/tool_calling_chain_api.py | 7 added, 44 removed | The code changes introduce a new base class
ToolCallingBaseChain
that replaces the previousClaude2ToolCallingChain
class, and dynamically creates subclasses for different model configurations using a dictionary comprehension. |