CoolFace
Apppublic

alpha-79-xf/digital-twin-assistant

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

Jack's Digital Twin Assistant ๐Ÿค–

An AI-powered digital twin assistant that acts as a personal representative, capable of answering questions about Jack Ma's background, skills, experience, and more. Built with Streamlit and powered by advanced AI agents with built-in guardrails and contact management.

๐ŸŒŸ Features

  • โ€”Intelligent Q&A System: Answers questions about personal information based on YAML data
  • โ€”Multi-layered Guardrails: Built-in response review system to ensure appropriate and accurate responses
  • โ€”Contact Management: Collects user contact information for follow-up when questions can't be answered
  • โ€”Email Notifications: Automatic email alerts for unanswered questions and contact requests
  • โ€”Conversation History: Maintains chat history with approval status tracking
  • โ€”Tracing & Debugging: Comprehensive tracing system for monitoring and debugging
  • โ€”Responsive UI: Clean, modern interface with real-time status updates

๐Ÿ—๏ธ Architecture

The application uses a multi-agent architecture:

  1. 1.Digital Twin Agent: Primary agent that responds as Jack Ma
  2. 2.Guardrail Agent: Secondary agent that reviews responses for appropriateness
  3. 3.Contact Collection System: Manages user contact information and notifications
  4. 4.Tracing System: Monitors performance and helps with debugging

๐Ÿ“‹ Prerequisites

  • โ€”Python 3.8+
  • โ€”Google API Key (for Gemini AI)
  • โ€”Gmail account for email notifications
  • โ€”Personal information in YAML format

๐Ÿš€ Installation

  1. 1.Clone the repository
bash
   git clone <repository-url>
   cd Jack-digital-twin
  1. 1.Install dependencies
bash
   pip install -r requirements.txt
  1. 1.Set up environment variables Create a .env file in the project root:
env
   GOOGLE_API_KEY=your_google_api_key_here
   EMAIL_SENDER=your_gmail_address@gmail.com
   EMAIL_PASSWORD=your_gmail_app_password
   EMAIL_RECEIVER=recipient_email@gmail.com
  1. 1.Create personal information file Create a personal_info.yaml file with your information:
yaml
   personal_info:
     name: "Your Name"
     birth_year: Age
     education:
       - degree: "Data Engineering"
         institution: "School"
         status: "Currently studying"
     experience:
       - role: "Rple"
         company: "Current workplace"
         type: "Part-time"
       - role: "Data Engineering Intern"
         company: "Various companies"
         type: "Internship"
     skills:
       programming_languages:
         - "Python"
         - "SQL"
         - "Bash"
       technologies:
         - "Streamlit"
         - "AI/ML"
         - "Data Engineering"
       certifications:
         - "Microsoft Certified"

๐Ÿ”ง Configuration

Environment Variables

VariableDescriptionRequired
GOOGLE_API_KEYGoogle Gemini API keyYes
EMAIL_SENDERGmail address for sending notificationsYes
EMAIL_PASSWORDGmail app passwordYes
EMAIL_RECEIVEREmail address to receive notificationsYes

Gmail Setup

  1. 1.Enable 2-factor authentication on your Gmail account
  2. 2.Generate an app password:
  3. 3.Go to Google Account settings
  4. 4.Security โ†’ 2-Step Verification โ†’ App passwords
  5. 5.Generate a password for "Mail"
  6. 6.Use this password in the EMAIL_PASSWORD variable

๐Ÿ“– Usage

Running the Application

  1. 1.Start the Streamlit app
bash
   streamlit run main.py
  1. 1.Access the application
  2. 2.Open your browser and go to http://localhost:8501
  3. 3.The interface will load with the digital twin assistant

Using the Interface

  1. 1.Ask Questions
  2. 2.Type your question in the text area
  3. 3.Click "Send Question" to get a response
  4. 4.The system will provide answers based on the YAML data
  1. 1.Question Types
  2. 2.Personal Information: Age, skills, education, experience
  3. 3.General Questions: Brief answers with redirection to personal topics
  4. 4.Unanswerable Questions: Triggers contact collection process
  1. 1.Contact Collection
  2. 2.If a question can't be answered, the system will offer to collect contact information
  3. 3.Provide your name, email, and/or phone number
  4. 4.The question will be forwarded to Jack for follow-up
  1. 1.Conversation Management
  2. 2.View conversation history with approval status
  3. 3.Clear conversation history when needed
  4. 4.Monitor response review status

๐Ÿ” System Behavior

Response Categories

  1. 1.Approved Responses: โœ…
  2. 2.Based on YAML data
  3. 3.Appropriate redirection
  4. 4.Proper contact collection handling
  1. 1.Rejected Responses: โŒ
  2. 2.Violates instructions
  3. 3.Provides incorrect information
  4. 4.Requires manual review
  1. 1.Error Responses: โš ๏ธ
  2. 2.Technical issues
  3. 3.Processing errors
  4. 4.System failures

Contact Collection Triggers

  • โ€”Questions related to Jack but not in YAML data
  • โ€”Requests for detailed information not available
  • โ€”Follow-up inquiries requiring personal response

๐Ÿ“ File Structure

Jack-digital-twin/
โ”œโ”€โ”€ mainV4.py                 # Main application file
โ”œโ”€โ”€ personal_info.yaml        # Personal information data
โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”œโ”€โ”€ .env                      # Environment variables
โ”œโ”€โ”€ unanswered_questions.log  # Log file for unanswered questions
โ””โ”€โ”€ README.md                 # This file

๐Ÿ”ง Dependencies

txt
streamlit>=1.28.0
python-dotenv>=1.0.0
google-generativeai>=0.3.0
openai>=1.0.0
pydantic>=2.0.0
agents>=1.0.0
PyYAML>=6.0

๐Ÿ› Troubleshooting

Common Issues

  1. 1.API Key Errors
  2. 2.Verify your Google API key is valid
  3. 3.Check if the API key has proper permissions
  4. 4.Ensure the key is correctly set in the .env file
  1. 1.Email Sending Failures
  2. 2.Verify Gmail app password is correct
  3. 3.Check if 2-factor authentication is enabled
  4. 4.Ensure the sender email is valid
  1. 1.YAML Loading Errors
  2. 2.Verify the personal_info.yaml file exists
  3. 3.Check YAML syntax is correct
  4. 4.Ensure file encoding is UTF-8
  1. 1.Model Loading Issues
  2. 2.Check internet connection
  3. 3.Verify API quotas and limits
  4. 4.Ensure the agents library is properly installed

Debug Mode

The application includes comprehensive tracing. To view traces:

  1. 1.Check the console output for trace information
  2. 2.Monitor the unanswered_questions.log file
  3. 3.Review email notifications for system status

๐Ÿ”’ Security Considerations

  • โ€”API Keys: Never commit API keys to version control
  • โ€”Email Credentials: Use app passwords, not account passwords
  • โ€”Data Privacy: Personal information is stored locally in YAML format
  • โ€”Input Validation: Built-in guardrails prevent inappropriate responses

๐Ÿค Contributing

  1. 1.Fork the repository
  2. 2.Create a feature branch
  3. 3.Make your changes
  4. 4.Add tests if applicable
  5. 5.Submit a pull request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ“ž Support

For technical support or questions:

  • โ€”Create an issue in the repository
  • โ€”Contact Jack Ma directly
  • โ€”Review the troubleshooting section above

๐Ÿš€ Future Enhancements

  • โ€”[ ] Multi-language support
  • โ€”[ ] Voice input/output capabilities
  • โ€”[ ] Integration with calendar systems
  • โ€”[ ] Advanced analytics and reporting
  • โ€”[ ] Custom theme support
  • โ€”[ ] Mobile app version
  • โ€”[ ] Integration with social media platforms

๐Ÿ“Š Monitoring

The application logs:

  • โ€”All unanswered questions
  • โ€”Contact collection requests
  • โ€”System errors and performance metrics
  • โ€”Response approval/rejection status

Monitor the unanswered_questions.log file and email notifications to stay informed about system activity.


Built with โค๏ธ by Jack Ma using Streamlit and AI Agents