aws-samples / aws-genai-llm-chatbot

A modular and comprehensive solution to deploy a Multi-LLM and Multi-RAG powered chatbot (Amazon Bedrock, Anthropic, HuggingFace, OpenAI, Meta, AI21, Cohere, Mistral) using AWS CDK on AWS
https://aws-samples.github.io/aws-genai-llm-chatbot/
MIT No Attribution
1.1k stars 332 forks source link

Add multi-language system prompts and BedrockChatAdapter implementation #576

Closed michel-heon closed 3 weeks ago

michel-heon commented 1 month ago

Pull Request: Centralize and Internationalize System Prompts

This pull request addresses the issue of scattered system prompts across the codebase and the lack of support for internationalization, as described in the corresponding Git issue https://github.com/aws-samples/aws-genai-llm-chatbot/issues/571.


Changes:


Key Improvements:


Testing Instructions:

  1. Deploy the Application: Follow the deployment instructions provided in the project documentation to deploy the application.
  2. Target Language: The language used by the system prompts is now managed by the mechanism in system_prompts.py.
  3. Modify Language: You can modify the target language at runtime by editing the language selection in the GenAIChatBotStack-LangchainInterfaceReques Lambda function.
  4. Prompt Tracing: The system prompts are logged and can be traced in CloudWatch. Additionally, they are available in the prompt field of the metadata variable in the AWS GenAI Chatbot console for further analysis.

Expected Outcome:


charles-marion commented 1 month ago

@michel-heon please tag me or click the re-request review button if you'd like me to have a look. (Note I noticed the file base.py_new which is probably not relevant?)

michel-heon commented 1 month ago

@charles-marion In fact, the base.py_new file is an error that I've deleted. And indeed, the code is ready for revision.

michel-heon commented 1 month ago

I've just finished making the corrections and pushed the updated changes. No worries about the time involved—it's genuinely a pleasure to contribute to this effort.

michel-heon commented 3 weeks ago

The i18n mechanism works for Bedrock, but not for azureopenai. This fix could be part of a future PR?

charles-marion commented 3 weeks ago

The i18n mechanism works for Bedrock, but not for azureopenai. This fix could be part of a future PR?

Do you mean it breaks the azureopenai flow or just always use english prompts? Yes it could be a future PR if it does not break capabilities.

Happy to merge today/tomorrow if that's not the case.

michel-heon commented 3 weeks ago

In fact, the use of azureopenai refers to the default system-prompt in langchain, which must be overloaded. The same applies to Mistral. I agree with deferring this development to another PR and merging the current work.

charles-marion commented 3 weeks ago

Build is blocked until the following is merged. #598 I will merge this PR when the above is merged.