alpha-79-xf/digital-twin-assistant
0
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:
- Digital Twin Agent: Primary agent that responds as Jack Ma
- Guardrail Agent: Secondary agent that reviews responses for appropriateness
- Contact Collection System: Manages user contact information and notifications
- 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
- Clone the repository
git clone <repository-url>
cd Jack-digital-twin- Install dependencies
pip install -r requirements.txt- Set up environment variables Create a
.envfile in the project root:
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- Create personal information file Create a
personal_info.yamlfile with your information:
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
Gmail Setup
- Enable 2-factor authentication on your Gmail account
- Generate an app password:
- Go to Google Account settings
- Security โ 2-Step Verification โ App passwords
- Generate a password for "Mail"
- Use this password in the
EMAIL_PASSWORDvariable
๐ Usage
Running the Application
- Start the Streamlit app
streamlit run main.py- Access the application
- Open your browser and go to
http://localhost:8501 - The interface will load with the digital twin assistant
Using the Interface
- Ask Questions
- Type your question in the text area
- Click "Send Question" to get a response
- The system will provide answers based on the YAML data
- Question Types
- Personal Information: Age, skills, education, experience
- General Questions: Brief answers with redirection to personal topics
- Unanswerable Questions: Triggers contact collection process
- Contact Collection
- If a question can't be answered, the system will offer to collect contact information
- Provide your name, email, and/or phone number
- The question will be forwarded to Jack for follow-up
- Conversation Management
- View conversation history with approval status
- Clear conversation history when needed
- Monitor response review status
๐ System Behavior
Response Categories
- Approved Responses: โ
- Based on YAML data
- Appropriate redirection
- Proper contact collection handling
- Rejected Responses: โ
- Violates instructions
- Provides incorrect information
- Requires manual review
- Error Responses: โ ๏ธ
- Technical issues
- Processing errors
- 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
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
- API Key Errors
- Verify your Google API key is valid
- Check if the API key has proper permissions
- Ensure the key is correctly set in the
.envfile
- Email Sending Failures
- Verify Gmail app password is correct
- Check if 2-factor authentication is enabled
- Ensure the sender email is valid
- YAML Loading Errors
- Verify the
personal_info.yamlfile exists - Check YAML syntax is correct
- Ensure file encoding is UTF-8
- Model Loading Issues
- Check internet connection
- Verify API quotas and limits
- Ensure the agents library is properly installed
Debug Mode
The application includes comprehensive tracing. To view traces:
- Check the console output for trace information
- Monitor the
unanswered_questions.logfile - 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
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- 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
