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

Add multi-language system prompts and BedrockChatAdapter implementation #576

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

michel-heon
Copy link

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 #571.


Changes:

  • Commit: 256279db811d17f6c558ccf469bfbec0e0d93583
  • Objective: Centralize system prompt management and enable internationalization (i18n).
  • Affected Files:
    • system_prompts.py: A new module created to centralize all system prompts and support multiple languages (English and Canadian French).
    • base.py: Refactored methods (get_prompt, get_condense_question_prompt, get_qa_prompt) to retrieve prompts from system_prompts.py.
    • __init__.py: Updated to import system prompts for simplified access.

Key Improvements:

  • Centralization: All system prompts are now stored in one place (system_prompts.py), improving manageability and scalability.
  • Internationalization: The system can now support multiple languages, with English and Canadian French prompts available as an initial setup. This framework allows for future expansion into other languages.
  • Adapter Compatibility: Adapters such as azure-openai, mistral, claude, titan, and llama are updated to use the new prompt management system, ensuring consistency and reducing code duplication.

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:

  • Simplified prompt management across adapters.
  • Enhanced scalability and flexibility in adding new languages.

- Implement system prompts in English and Canadian French for AI
interactions in `system_prompts.py`.
- Enhance `BedrockChatAdapter` with prompt templates for QA,
conversation, and follow-up questions in `base.py`.
- Update `__init__.py` to include system prompt imports for easy access.
- Configure logger in `base.py` to trace key operations for QA prompts
and conversational prompts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants