Sifu - Advanced Knowledge and NLP Support System
[](https://opensource.org/licenses/Apache 2.0 )
Sifu is an advanced knowledge and natural language processing system designed to enhance AI assistants with sophisticated context handling, real-time learning, and multi-language support.
🌟 Features
- Advanced NLP: Intent recognition and entity extraction
- Knowledge Management: Store and retrieve information with confidence scoring
- Context Awareness: Maintain conversation context and history
- Multi-language Support: Automatic language detection and translation
- Learning Engine: Improve responses through feedback
- RESTful API: Easy integration with existing systems
- Modular Architecture: Extensible design for custom components
🚀 Quick Start
Prerequisites
- Python 3.8+
- Poetry for dependency management
- (Optional) GPU for better ML performance
Installation
-
Clone the repository:
git clone https://github.com/yourusername/sifu.git cd sifu
-
Install dependencies using Poetry:
poetry installOr install with pip:
pip install -r requirements.txt
-
Install language models (for NLP features):
python -m spacy download en_core_web_sm
Basic Usage
from sifu import Sifu
import asyncio
async def main():
# Initialize Sifu
sifu = Sifu()
# Process a query
response = await sifu.process_query("Hello, what can you do?")
print(f"Response: {response['text']}")
# Add knowledge
await sifu.knowledge_base.add_entry(
content="Sifu is an AI assistant",
tags=["introduction"],
language="en"
)
if __name__ == "__main__":
asyncio.run(main())
📚 Documentation
For detailed documentation, please visit our documentation site.
Key Components
- Knowledge Base: Store and retrieve information
- Context Management: Handle conversation state
- Intent Matcher: Understand user intents
- Learning Engine: Improve through feedback
- API Reference: REST API documentation
🧪 Testing
Run the test suite:
# Install test dependencies
poetry install --with test
# Run tests
pytest tests/ -v
# Run with coverage
pytest --cov=sifu --cov-report=term-missing
🤝 Contributing
Contributions are welcome! Please read our Contributing Guide for details.
📄 License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
📞 Contact
For questions or support, please open an issue or contact your-email@example.com.
Made with ❤️ by Your Name
for ELLMaCore Components
1. Knowledge Management System
- SimpleKnowledgeBase: Core knowledge storage with confidence scoring and continuous learning
- Context Manager: Handles conversation history and context awareness
- Response Generator: Multi-strategy response generation with fallback mechanisms
2. Advanced Features
- Real-time Learning: Learns from interactions and feedback
- Multi-language Support: Built-in support for multiple languages
- User Profiles: Personalized knowledge and preferences
- External API Integration: Access to real-time information
- FastAPI-based API: Easy integration with other systems
Documentation
Architecture
graph TD
A[User Query] --> B[Context Manager]
B --> C{Query Type?}
C -->|Knowledge| D[Knowledge Base]
C -->|External Data| E[API Integrations]
C -->|Conversation| F[Conversation History]
D --> G[Response Generator]
E --> G
F --> G
G --> H[Response + Learning]
H --> I[Update Knowledge]
I --> J[User Feedback]
J --> H
Key Algorithms
-
Context-Aware Response Generation
- Uses conversation history and user context
- Implements attention mechanisms for better context understanding
- Learn more
-
Pattern Matching with NLP
- Advanced NLP techniques for intent recognition
- Support for fuzzy matching and semantic similarity
- Learn more
-
Real-time Learning Loop
- Continuous learning from interactions
- Confidence-based knowledge updates
- Learn more
-
Multi-language Processing
- Language detection and translation
- Culture-aware responses
- Learn more
Getting Started
Prerequisites
- Python 3.8+
- Poetry for dependency management
- Redis (for caching and real-time features)
Installation
# Clone the repository
git clone https://github.com/yourusername/sifu.git
cd sifu
# Install dependencies
poetry install
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# Run the development server
poetry run uvicorn sifu.api:app --reload
API Documentation
Once the server is running, access the interactive API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Usage Examples
Basic Usage
from sifu import Sifu
# Initialize Sifu
sifu = Sifu()
# Process a query
response = sifu.process_query("What's the weather like today?")
print(response)
# Provide feedback
sifu.provide_feedback(
question="What's the weather like today?",
rating=1,
better_response="The current weather is sunny with a temperature of 22°C."
)
Advanced Usage with Custom Knowledge Sources
from sifu import Sifu
from sifu.knowledge import WebSource, APISource
# Initialize with custom knowledge sources
sifu = Sifu(
knowledge_sources=[
WebSource(),
APISource("weather_api", "https://api.weatherapi.com/v1")
]
)
# Process a query with context
response = sifu.process_query(
"What's the weather in Tokyo?",
context={"user_id": "123", "language": "en"}
)
print(response)
Configuration
Configuration is handled through environment variables. Copy .env.example to .env and adjust the settings as needed.
# Database
DATABASE_URL=sqlite:///./sifu.db
REDIS_URL=redis://localhost:6379/0
# API Keys (if using external services)
OPENAI_API_KEY=your_openai_key
WEATHER_API_KEY=your_weather_api_key
# Application Settings
DEBUG=True
LOG_LEVEL=INFO
Contributing
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature/your-feature) - Create a new Pull Request
License
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Acknowledgements
- Built with ❤️ for the ELLMa project
- Uses FastAPI for the web framework
- Integrates with various NLP and ML libraries
Metadata
Release files for sifu 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sifu-0.1.0.tar.gz | 27.5 kB | Without provenance | Details for sifu-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sifu-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for sifu-0.1.0-py3-none-any.whl |
Total release size: 57.8 kB
Release files / sifu-0.1.0.tar.gz
| Download URL | sifu-0.1.0.tar.gz |
|---|---|
| Size | 27.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a8452e606f714a0dc8f76e49ca3b56416940568a0f3652b041a896b551dd6db
|
|
BLAKE2b-256 checksum How to use checksums |
60b7db29b20855475eebd3a088044e39f352793ec0834d63c64f7f841bcfedf6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.4 Linux/6.14.9-300.fc42.x86_64
|
Release files / sifu-0.1.0-py3-none-any.whl
| Download URL | sifu-0.1.0-py3-none-any.whl |
|---|---|
| Size | 30.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b27eeba3dd752fcaf5c605f5815da6a028cfcc728f3dce50ed5d63f6d9ece67c
|
|
BLAKE2b-256 checksum How to use checksums |
f5dc980c87167d85811f0d0ac60a074ae74330423fadc452b972cd0656312a5b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.3 CPython/3.12.4 Linux/6.14.9-300.fc42.x86_64
|
Security for sifu 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.