Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add model config #487

Merged
merged 7 commits into from
Dec 19, 2024
Merged

feat: add model config #487

merged 7 commits into from
Dec 19, 2024

Conversation

NingLu
Copy link
Collaborator

@NingLu NingLu commented Dec 18, 2024

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:

  1. Updates to the langchain_integration module, including modifications to the chains, chat_models, and the addition of a new model_config.py file.
  2. Changes to the common_utils/constant.py file.
  3. Modifications to the common_entry.py file, which handles the online entries for the application.
  4. Updates to the 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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 10, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/portal/src/pages/chatbot/ChatBot.tsx 5 added, 0 removed The code changes add functionality to store the current chatbot option in the browser's local storage, allowing it to persist across page reloads.
source/lambda/online/common_logic/langchain_integration/chains/tool_calling_chain_api.py 9 added, 42 removed This code change refactors the Claude2ToolCallingChain class into a generic ToolCallingChain class and dynamically creates subclasses for different models based on configurations.
source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py 1 added, 1 removed The code change involves modifying the string quotation marks around the "all_knowledge_rag_tool" key from single quotes to double quotes.
source/lambda/online/common_logic/langchain_integration/chat_models/init.py 0 added, 5 removed The code change removes the import logic for the LLMModelType.NOVA_PRO case from the _load_module function's model_loader dictionary.
source/lambda/online/common_logic/langchain_integration/model_config.py 67 added, 0 removed This code defines a ModelConfig dataclass and a dictionary of model configurations for various LLM models with their respective model IDs and default keyword arguments.
source/lambda/online/common_logic/langchain_integration/chains/rag_chain.py 9 added, 52 removed This code change refactors the existing LLMChain subclasses for different model types into a single RagChain class that dynamically creates chains for different models based on configurations defined in MODEL_CONFIGS.
source/lambda/online/common_logic/common_utils/constant.py 1 added, 0 removed The code adds a new constant DEFAULT to the LLMModelType class, and includes several other model types for the Anthropic Claude language model.
source/lambda/online/common_logic/langchain_integration/chains/chat_chain.py 17 added, 63 removed This code change seems to be refactoring the different LLM chat chain classes. The main changes are:
  1. Introduced a base ChatChain class that sets default model kwargs and handles common logic.
  2. Removed individual chat chain classes for specific models like Claude variants.
  3. Introduced a dictionary chain_classes that dynamically creates chat chain classes for all models defined in MODEL_CONFIGS.
  4. Added these dynamically created classes to the global namespace. |
    | 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 in MODEL_CONFIGS. It also dynamically creates chain classes for all models in MODEL_CONFIGS for the QUERY_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:

  1. Updates to the constant.py file to accommodate new constants or modify existing ones.
  2. Modifications to the LangChain integration chains, such as chat_chain.py, query_rewrite_chain.py, rag_chain.py, and tool_calling_chain_api.py, to improve the chat experience and enhance the functionality of the language model.
  3. Updates to the bedrock_models.py file, which likely involves changes to the underlying language models used in the application.
  4. Addition of a new file, model_config.py, which potentially introduces configuration settings for the language models.
  5. Changes to the common_entry.py file, which may affect the common entry point for the online lambda function.
  6. Modifications to the ChatBot.tsx file in the portal's source code, suggesting updates to the chatbot user interface.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 11, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py 1 added, 1 removed The code change modifies the assignment of the 'all_knowledge_rag_tool' variable, replacing single quotes with double quotes for string consistency.
source/lambda/online/common_logic/common_utils/constant.py 1 added, 0 removed This code change introduces a new constant DEFAULT in the LLMModelType class, and adds three new model types: CLAUDE_INSTANCE, CLAUDE_2, and CLAUDE_21.
source/portal/src/pages/chatbot/ChatBot.tsx 5 added, 0 removed The code adds functionality to store the current chatbot option in the browser's localStorage, allowing it to persist across page reloads or sessions.
source/lambda/online/common_logic/langchain_integration/model_config.py 78 added, 0 removed The code defines a ModelConfig dataclass and a dictionary MODEL_CONFIGS containing configurations for various language models, including settings like model ID, default keyword arguments, and whether to enable auto tool choice and prefill.
source/lambda/online/common_logic/langchain_integration/chains/rag_chain.py 9 added, 52 removed The code changes involve refactoring the various LLMChain subclasses for different models into a single RagChain class that dynamically creates chains based on the model ID. It imports MODEL_CONFIGS from model_config and uses it to generate chain classes for each model ID at runtime.
source/lambda/online/common_logic/langchain_integration/chat_models/bedrock_models.py 9 added, 57 removed The code changes introduce a new BedrockModel class that replaces the previous model-specific classes like Claude2, Claude21, etc. It dynamically creates model classes based on the MODEL_CONFIGS and adds them to the module's global namespace. This change likely aims to simplify and centralize model configuration management.
source/lambda/online/common_logic/langchain_integration/chains/tool_calling_chain_api.py 9 added, 42 removed This code change refactors the model-specific tool calling chain classes into a single ToolCallingChain class that dynamically creates chain instances for different models based on configurations.
source/lambda/online/common_logic/langchain_integration/chains/chat_chain.py 17 added, 63 removed The code changes introduce a new base class ChatChain that extends LLMChain for chat-based language models. It also defines a dictionary chain_classes that maps model IDs to their corresponding ChatChain subclasses, which are dynamically created using LLMChain.create_for_model. The subclasses are then added to the global namespace.
source/lambda/online/common_logic/langchain_integration/chains/query_rewrite_chain.py 10 added, 32 removed This code change introduces a more generic and extensible approach for creating query rewrite chains for different language models. Instead of defining separate classes for each model, it uses a dictionary to map model IDs to their corresponding chain classes. The chain classes are dynamically created using the 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 single QueryRewriteChain class that uses the LLMModelType.DEFAULT model ID.
source/lambda/online/common_logic/langchain_integration/chains/init.py 150 added, 120 removed This code change introduces a new way to create chains dynamically based on the model ID and intent type. It adds a model_id_to_class_name method to convert the model ID to a valid Python class name, and a create_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.
source/lambda/online/common_logic/langchain_integration/chat_models/init.py 83 added, 42 removed The code changes introduce a new factory method create_for_model in the Model class to create a model instance based on the provided model ID. It also adds a helper method model_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:

  • Refactoring and optimization of the LangChain chains, including the chat chain, query rewrite chain, and retrieval-augmented generation (RAG) chain.
  • Updates to the Bedrock language models for improved performance and compatibility.
  • Addition of a new model_config.py file to centralize model configuration settings.
  • Modifications to the common entry point for online lambda functions to accommodate the updated LangChain integration.
  • Updates to the chatbot component in the portal to support the new features and changes.

These changes aim to enhance the overall performance, scalability, and maintainability of the LangChain integration and chat functionality within the application.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 12, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/portal/src/utils/const.ts 2 added, 1 removed The provided code change adds a new constant export named "HISTORY_CHATBOT_ID" to the existing list of exported constants.
source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py 1 added, 1 removed The code change modifies the assignment of the 'all_knowledge_rag_tool' variable, replacing single quotes with double quotes for string literals.
source/lambda/online/common_logic/common_utils/constant.py 1 added, 0 removed The code adds a new constant DEFAULT to the LLMModelType class, likely representing a default model ID for language models.
source/lambda/online/common_logic/langchain_integration/chat_models/bedrock_models.py 9 added, 57 removed This code change introduces a new BedrockModel class that serves as a base class for different language models. It imports the MODEL_CONFIGS from the model_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.
source/lambda/online/common_logic/langchain_integration/chains/tool_calling_chain_api.py 9 added, 42 removed The code changes introduce a generic ToolCallingChain class that dynamically creates chain classes for different models based on the MODEL_CONFIGS, replacing the previous approach of defining separate classes for each model.
source/lambda/online/common_logic/langchain_integration/model_config.py 78 added, 0 removed This code defines a ModelConfig dataclass and a dictionary of model configurations for various LLM models, including Claude, Nova, Llama, Mistral, and Cohere models, with settings for model ID, default model parameters, auto tool choice, and prefill options.
source/portal/src/pages/chatbot/ChatBot.tsx 6 added, 2 removed The code changes involve importing a new constant HISTORY_CHATBOT_ID, using it to store and retrieve the chatbot ID from localStorage, and removing the history chatbot ID from localStorage when manually changing the chatbot.
source/lambda/online/common_logic/langchain_integration/chains/chat_chain.py 17 added, 63 removed This code change refactors the ChatChain classes to use a more generic approach based on model configurations, adds support for different language models, and updates default model parameters.
source/lambda/online/common_logic/langchain_integration/chains/query_rewrite_chain.py 10 added, 32 removed This code change introduces a more generic and extensible approach for creating query rewrite chains for different language models. It defines a single QueryRewriteChain class that uses the LLMModelType.DEFAULT model and a chain_classes dictionary that dynamically creates chain classes for all available models in MODEL_CONFIGS. The previously defined model-specific chain classes are removed.
source/lambda/online/common_logic/langchain_integration/chat_models/init.py 83 added, 42 removed The code changes introduce a new factory method create_for_model in the Model class, which dynamically creates a new class for a given model ID using the configurations from MODEL_CONFIGS. It also refactors the import statements for different model classes and updates the model_id_to_class_name method to handle model IDs with version numbers and vendor prefixes.
source/lambda/online/common_logic/langchain_integration/chains/rag_chain.py 9 added, 52 removed The code changes introduce a new 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 the MODEL_CONFIGS dictionary. Additionally, it adds a dictionary chain_classes that maps model IDs to their corresponding chain classes, making it easier to access and instantiate chains for different models.
source/lambda/online/common_logic/langchain_integration/chains/init.py 150 added, 120 removed The code changes introduce a new method create_for_model in the LLMChain class, which dynamically creates a new class for a specific model based on the model ID and intent type. It also adds a helper method model_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 centralized chain_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:

  • Added a new module model_config.py to handle the configuration and loading of language models.
  • Modified various chain files (chat_chain.py, query_rewrite_chain.py, rag_chain.py, tool_calling_chain_api.py) to incorporate LangChain components.
  • Updated the bedrock_models.py file to support LangChain model integration.
  • Modified common_entry.py to utilize the new LangChain chains and models.
  • Updated the frontend ChatBot.tsx and const.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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 12, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/portal/src/utils/const.ts 2 added, 1 removed This code change adds a new exported constant called HISTORY_CHATBOT_ID to the existing set of constants.
source/lambda/online/common_logic/common_utils/constant.py 1 added, 0 removed This code change introduces a new constant DEFAULT in the LLMModelType class, likely representing a default model identifier, and adds three constants for different versions of the Claude language model from Anthropic.
source/lambda/online/common_logic/langchain_integration/chains/tool_calling_chain_api.py 9 added, 42 removed The code changes refactor the ToolCallingChain class to dynamically create chain classes for different models based on the MODEL_CONFIGS, instead of having separate classes for each model.
source/lambda/online/common_logic/langchain_integration/chat_models/bedrock_models.py 9 added, 57 removed This code change introduces a more flexible and extensible way of creating and managing different AI models. It removes the individual model classes (e.g., Claude2, Claude21, etc.) and instead creates model instances dynamically based on configurations defined in the MODEL_CONFIGS module. The BedrockModel class serves as a base class for all models, and the model_classes dictionary maps model IDs to their corresponding instances.
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 a default model specified in MODEL_CONFIGS. It also adds all available query rewrite chain classes to the module's global namespace based on the models defined in MODEL_CONFIGS.
source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py 1 added, 1 removed This code change updates a string quote style from single quotes to double quotes for the 'all_knowledge_rag_tool' key in a dictionary.
source/lambda/online/common_logic/langchain_integration/chains/chat_chain.py 17 added, 63 removed The code changes introduce a new base class ChatChain for LLM chat chains, with a default model type and model parameters. It also adds a dictionary chain_classes that maps model IDs to their corresponding ChatChain subclasses, which are dynamically created using the MODEL_CONFIGS and added to the global namespace.
source/lambda/online/common_logic/langchain_integration/chains/rag_chain.py 9 added, 52 removed The code changes introduce a new class RagChain that serves as a base class for all RAG (Retrieval-Augmented Generation) chains, replacing the previous Claude2RagLLMChain. 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.
source/portal/src/pages/chatbot/ChatBot.tsx 6 added, 2 removed The code changes include: importing a new constant HISTORY_CHATBOT_ID, using the constant for localStorage key instead of hardcoded string, removing the HISTORY_CHATBOT_ID from localStorage when manually changing chatbot option.
source/lambda/online/common_logic/langchain_integration/model_config.py 78 added, 0 removed This code change introduces a dataclass called ModelConfig to store configuration details for different language models, including model ID, default model parameters, and flags for enabling auto tool choice and prefilling. It also defines a base configuration and a dictionary of configurations for various models like Claude, Nova, Llama, Mistral, and Cohere.
source/lambda/online/common_logic/langchain_integration/chat_models/init.py 83 added, 42 removed The code changes introduce a new method model_id_to_class_name to convert model IDs to valid Python class names, and a factory method create_for_model to dynamically create model classes based on configurations. It also refactors the import statements for bedrock models.
source/lambda/online/common_logic/langchain_integration/chains/init.py 150 added, 120 removed This code change introduces a new way to dynamically create LLMChain classes for different models and intent types. It adds a model_id_to_class_name method to convert model IDs to valid Python class names, and a create_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:

  • Updated the LangChain integration to support the latest version of the LangChain library.
  • Refactored the chat chain, query rewrite chain, and RAG chain to improve code organization and maintainability.
  • Added a new model_config.py file to centralize the configuration of LangChain models.
  • Modified the chatbot frontend to accommodate the changes in the backend API.

These changes aim to enhance the overall performance, scalability, and maintainability of the chatbot application.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 12, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/lambda/online/common_logic/common_utils/constant.py 1 added, 0 removed The code change introduces a new constant DEFAULT to the LLMModelType class, representing a default model identifier.
source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py 1 added, 1 removed The code change modifies the assignment of the 'all_knowledge_rag_tool' value from state by using double quotes instead of single quotes for the dictionary key.
source/portal/src/pages/chatbot/ChatBot.tsx 6 added, 2 removed The code changes involve storing and managing the selected chatbot ID in the browser's localStorage, using a constant HISTORY_CHATBOT_ID. It also removes the stored chatbot ID when manually changing the chatbot option.
source/portal/src/utils/const.ts 2 added, 1 removed This change exports a new constant named "HISTORY_CHATBOT_ID" which likely represents an identifier for storing or retrieving chat history with a chatbot.
source/lambda/online/common_logic/langchain_integration/chains/tool_calling_chain_api.py 7 added, 44 removed The code changes introduce a base class ToolCallingBaseChain for tool calling chains, replacing the previous model-specific classes like Claude2ToolCallingChain. It dynamically creates chain classes for all available models using the MODEL_CONFIGS instead of hardcoding them.
source/lambda/online/common_logic/langchain_integration/model_config.py 78 added, 0 removed The code defines a ModelConfig dataclass and a dictionary of model configurations for different language models, including Claude, Nova Pro, Llama, Mistral, and Cohere models, with default parameters like max_tokens, temperature, and enabling/disabling certain features like auto tool choice and prefilling.
source/lambda/online/common_logic/langchain_integration/chains/query_rewrite_chain.py 8 added, 33 removed This code change introduces a base class QueryRewriteBaseChain for query rewriting task chains, and dynamically creates chain classes for all available models defined in MODEL_CONFIGS. It removes the hard-coded subclasses for specific models like Claude variants, and instead generates the subclasses programmatically based on the model configurations.
source/lambda/online/common_logic/langchain_integration/chat_models/bedrock_models.py 7 added, 58 removed This code change introduces a new base class BedrockBaseModel that extends the Model class, and defines a dictionary model_classes that maps model IDs to their corresponding model classes. The model classes are dynamically created using the BedrockBaseModel.create_for_model method and the MODEL_CONFIGS imported from model_config.
source/lambda/online/common_logic/langchain_integration/chat_models/init.py 83 added, 43 removed The code changes introduce a factory method create_for_model to dynamically create a model class based on the provided model ID. It also adds a helper method model_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 single model_classes import instead of individual imports.
source/lambda/online/common_logic/langchain_integration/chains/rag_chain.py 7 added, 53 removed The code changes introduce a new base class RagBaseChain for RAG (Retrieval-Augmented Generation) LLM chains, which dynamically creates chain classes for different LLM models based on the configurations in MODEL_CONFIGS. It replaces the previous approach of defining individual chain classes for each model.
source/lambda/online/common_logic/langchain_integration/chains/chat_chain.py 14 added, 63 removed The provided code changes introduce a new base class called 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 from ChatBaseChain instead of Claude2ChatChain. Additionally, a dictionary chain_classes is created to dynamically generate chat chain classes for each model configuration defined in MODEL_CONFIGS.
source/lambda/online/common_logic/langchain_integration/chains/init.py 147 added, 121 removed This code change introduces dynamic class creation for LLM chains based on the model ID and intent type. It adds a method to convert model IDs to valid Python class names, and a factory method to create new chain classes dynamically. It also reorganizes the imports of different chain types into separate functions, and adds a new chain_classes import for chat and query rewrite chains.
🤖 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:

  • Updates to the constant.py and prompt_utils.py files in the common_utils module, likely related to handling constants and prompt generation.
  • Modifications to several chain implementations, such as chat_chain.py, conversation_summary_chain.py, query_rewrite_chain.py, rag_chain.py, and tool_calling_chain_api.py, which may involve improvements or bug fixes related to these specific chains.
  • Addition of a new file model_config.py in the langchain_integration module, which is likely responsible for managing configurations related to language models.
  • Updates to the bedrock_models.py file in the chat_models module, potentially introducing changes to the handling of Bedrock language models.
  • Modifications to the common_entry.py file in the online_entries module, which may affect the common entry point for online functionality.
  • Changes to the ChatBot.tsx file in the portal/src/pages/chatbot directory, suggesting updates to the chatbot user interface.
  • Updates to the const.ts file in the portal/src/utils directory, which may involve modifications to constant values used throughout the application.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

File Stats Summary

File number involved in this PR: 14, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/lambda/online/lambda_main/main_utils/online_entries/common_entry.py 1 added, 1 removed The code change modifies the value assignment for the all_knowledge_rag_tool variable, using double quotes for the dictionary key instead of single quotes.
source/lambda/online/common_logic/langchain_integration/model_config.py 141 added, 0 removed This code defines a ModelConfig dataclass and a dictionary of model configurations (MODEL_CONFIGS) for different language models, specifying their model IDs, default parameters, and settings like enabling auto-tool choice and prefilling.
source/lambda/online/common_logic/langchain_integration/chains/conversation_summary_chain.py 45 added, 92 removed This code change imports the MODEL_CONFIGS from the model_config module and dynamically creates conversation summary chain classes for each model in MODEL_CONFIGS using a dictionary comprehension. It replaces the previous hard-coded conversation summary chain classes for specific models.
source/portal/src/utils/const.ts 18 added, 1 removed The code changes added several new AI models from Anthropic, Amazon, and Meta to the LLM_BOT_COMMON_MODEL_LIST, while also updating the LLM_BOT_RETAIL_MODEL_LIST and adding a new constant HISTORY_CHATBOT_ID.
source/lambda/online/common_logic/common_utils/constant.py 17 added, 1 removed The code changes introduce new constants for various LLM model types, including default model ID, Amazon Nova models (Nova Lite, Nova Micro), Anthropic Claude models (Claude 3 Sonnet, Opus, Haiku for different regions), Claude 3.5 models, and a LLaMA 3.1 70B instruct model for the US region.
source/lambda/online/common_logic/common_utils/prompt_utils.py 100 added, 1 removed This code change adds support for several new LLM model types, including Nova Lite, Nova Micro, various Claude models for different regions (US, EU, APAC), and LLaMa3.1 70B Instruct model for the US region.
source/portal/src/pages/chatbot/ChatBot.tsx 6 added, 2 removed The code changes introduce a new constant 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.
source/lambda/online/common_logic/langchain_integration/chains/chat_chain.py 14 added, 63 removed This code change introduces a new base class ChatBaseChain that inherits from LLMChain and defines common properties and methods for chat-based LLM chains. It also imports MODEL_CONFIGS and LLMModelType and LLMTaskType from other modules. Additionally, it creates a dictionary chain_classes that maps model IDs to their corresponding chat chain classes, which are dynamically created using the create_for_model method of ChatBaseChain.
source/lambda/online/common_logic/langchain_integration/chat_models/bedrock_models.py 7 added, 58 removed The code changes introduce a new base class BedrockBaseModel that extends the Model class and uses the LLMModelType.DEFAULT model ID. It also imports the MODEL_CONFIGS from model_config. Instead of defining individual model classes like Claude2, ClaudeInstance, etc., it creates a dictionary model_classes that maps model IDs from MODEL_CONFIGS to their respective model classes dynamically created using BedrockBaseModel.create_for_model().
source/lambda/online/common_logic/langchain_integration/chains/rag_chain.py 7 added, 53 removed The code changes introduce a base class 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.
source/lambda/online/common_logic/langchain_integration/chains/query_rewrite_chain.py 8 added, 33 removed This code change introduces a more generic and flexible approach for creating query rewrite chains for different language models. The main changes are:
  1. A new base class QueryRewriteBaseChain is created with a default model type.
  2. Separate classes for specific models (like Claude2, Claude21, etc.) are removed.
  3. A dictionary 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 like intent_type, model_id, and default_model_kwargs based on the model configuration. Additionally, it refactors the import statements for different chain types into separate functions and adds a new chain_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 the Model 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). The model_classes module is imported instead of importing individual model classes directly. Additionally, the model_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 previous Claude2ToolCallingChain class, and dynamically creates subclasses for different model configurations using a dictionary comprehension. |

@NingLu NingLu merged commit 8131a5c into dev Dec 19, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants