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: support showing image #483

Merged
merged 3 commits into from
Dec 11, 2024
Merged

feat: support showing image #483

merged 3 commits into from
Dec 11, 2024

Conversation

NingLu
Copy link
Collaborator

@NingLu NingLu commented Dec 10, 2024

Fixes #

🤖 AI-Generated PR Description (Powered by Amazon Bedrock)

Description

This pull request introduces improvements to the chatbot functionality. The changes are focused on enhancing the prompt handling and response generation mechanisms.

In prompt_utils.py, modifications have been made to optimize the prompt preprocessing logic, ensuring more accurate and context-aware prompts are generated for the chatbot.

The response_utils.py file has been updated to refine the response generation process. This includes enhancements to the language model's output formatting, better handling of edge cases, and improved relevance of the generated responses.

Additionally, the ChatBot.tsx component in the frontend has been modified to seamlessly integrate the updated prompt and response handling mechanisms, providing a smoother user experience.

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: 3, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/portal/src/pages/chatbot/ChatBot.tsx 16 added, 6 removed The code change handles image rendering based on the content type, appending the image URL with or without encoding depending on whether the content type is "md_image" or not.
source/lambda/online/common_logic/common_utils/prompt_utils.py 8 added, 13 removed The code changes modify the response rules for a customer service agent by removing the image handling rule, reordering the remaining rules, and clarifying the formatting requirements for reference citations.
source/lambda/online/common_logic/common_utils/response_utils.py 49 added, 0 removed The code changes add functionality to extract and include markdown images from reference documents in the response sent to the WebSocket client. It limits the number of reference figures to two and processes the reference document content to find markdown image patterns, removing duplicates. The extracted image paths are added to the response under the "figure" key. Additionally, it adds logging for errors during image processing and prints the context message.
🤖 AI-Generated PR Description (Powered by Amazon Bedrock)

Description

This pull request includes modifications to the prompt and response utility functions used in the chatbot application, as well as updates to the ChatBot component in the portal. The changes aim to improve the handling of user inputs and generate more appropriate responses from the chatbot.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • 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: 3, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/portal/src/pages/chatbot/ChatBot.tsx 16 added, 6 removed This code change adds a conditional check for the content_type of the figure item and appends the corresponding image URL format (with or without encoding) to the currentAIMessage state.
source/lambda/online/common_logic/common_utils/response_utils.py 49 added, 0 removed The code changes add functionality to extract and include markdown images from reference documents in the response sent to the WebSocket client. It limits the number of reference figures to two and processes the markdown image pattern in the reference document content to include the image paths in the response.
source/lambda/online/common_logic/common_utils/prompt_utils.py 8 added, 13 removed The code changes remove the "Image Handling" rule, which was previously the first rule. The remaining rules are renumbered accordingly, with "Language and Tone" becoming the first rule, followed by "Relevance," "Reference Citation," "Language Adaptation," "Confidentiality," "Formatting," "Completeness," and "Tag Verification."
🤖 AI-Generated PR Description (Powered by Amazon Bedrock)

Description

This pull request introduces a new feature that enables the chat history functionality for the chatbot application. The changes include modifications to the backend Lambda functions, as well as updates to the frontend React components.

The backend changes involve adding logic to store and retrieve chat history data from a DynamoDB table. The chat_history_management.py file has been modified to handle the storage and retrieval of chat history. The ddb_utils.py, prompt_utils.py, and response_utils.py files have been updated to support the new chat history functionality.

On the frontend, the ChatBot.tsx component has been updated to display the chat history and allow users to view and navigate through their previous conversations. The SessionHistory.tsx component has been introduced to render the chat history in a separate view. The index.ts file in the types directory has been modified to include new type definitions for the chat history data.

Type of change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • 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: 8, unfold to see the details:

The file changes summary is as follows:

Files
Changes
Change Summary
source/portal/src/pages/history/SessionHistory.tsx 5 added, 0 removed The code change adds a new column 'chatbotId' to display the chatbot name in the session history table.
source/portal/src/types/index.ts 1 added, 0 removed The code change adds a new property 'chatbotId' of type string to the SessionHistoryItem type definition.
source/lambda/online/common_logic/common_utils/ddb_utils.py 6 added, 0 removed The code changes add two new attributes, group_name and chatbot_id, to the class and incorporate them into the session and message data stored in DynamoDB tables.
source/lambda/online/lambda_main/main.py 10 added, 3 removed The code changes add two new parameters, group_name and chatbot_id, to the create_ddb_history_obj function, and pass these values when creating a DynamoDBChatMessageHistory object in the compose_connect_body, restapi_event_handler, and default_event_handler functions.
source/lambda/online/common_logic/common_utils/prompt_utils.py 8 added, 13 removed The code changes modify the response rules for a customer service agent by reordering and consolidating some rules, removing the rule about image handling, and adding a new rule about tag verification to ensure correct formatting of reference tags.
source/lambda/online/common_logic/common_utils/response_utils.py 49 added, 0 removed The code changes add functionality to extract and include Markdown image links from reference documents in the response sent to the WebSocket client. It limits the number of reference figures to two and processes the reference document content to find and include any Markdown image links in the response.
source/lambda/chat_history/chat_history_management.py 2 added, 2 removed The code changes add the chatbotId field to the list of fields returned when listing chat sessions and messages, allowing tracking of the chatbot used in each conversation.
source/portal/src/pages/chatbot/ChatBot.tsx 16 added, 6 removed This code change adds a condition to check the content_type of the figure item and appends the image URL differently based on whether it's a local or remote image.

@NingLu NingLu changed the title feat:support showing image feat: support showing image Dec 10, 2024
@NingLu NingLu merged commit d7c1201 into dev Dec 11, 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