https://github.com/openmined/syft-nsai
Network-source AI
https://github.com/openmined/syft-nsai
Last synced: 2 months ago
JSON representation
Network-source AI
- Host: GitHub
- URL: https://github.com/openmined/syft-nsai
- Owner: OpenMined
- License: apache-2.0
- Created: 2025-06-29T02:31:50.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2025-06-29T02:31:51.000Z (12 months ago)
- Last Synced: 2025-11-28T01:52:25.466Z (7 months ago)
- Language: Python
- Size: 23.4 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# syft-nsai
**Bridge Data and AI. Privately.**
An OpenAI-compatible interface for using SyftBox datasets with AI models in secure enclaves.
## π What is syft-nsai?
`syft-nsai` transforms how you work with federated datasets by providing a familiar OpenAI-style chat completions API that operates within secure enclaves. No more complex setup or unfamiliar APIs - just select your datasets and chat with your data.
```python
import syft_datasets as syd
import syft_nsai as nsai
# Discover datasets with beautiful interactive UI
syd.datasets
# Use them with familiar OpenAI-style API
selected_datasets = [syd.datasets[i] for i in [0, 1, 5]]
response = nsai.client.chat.completions.create(
model=selected_datasets, # Your datasets become the "model"
messages=[{"role": "user", "content": "What trends do you see in this data?"}]
)
# Access results
print(response.choices[0].message.content)
```
## β¨ Key Features
- **π Privacy-First**: All processing happens in secure enclaves
- **π€ OpenAI Compatible**: Drop-in replacement for familiar chat completions API
- **π Real Data Integration**: Datasets are loaded and summarized before AI analysis
- **β‘ Lazy Loading**: Results are fetched asynchronously for better UX
- **π Seamless Integration**: Works perfectly with `syft-datasets` for dataset discovery
## ποΈ Architecture
```
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β syft-datasets β β syft-nsai β β Secure Enclave β
β β β β β β
β Dataset DiscoveryβββββΆβOpenAI-style API βββββΆβ AI Processing β
β Interactive UI β βChat Completions β β with Real Data β
β Search & Select β βAsync Results β β β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
```
## π¦ Installation
```bash
pip install syft-nsai
```
For development:
```bash
pip install syft-nsai[dev]
```
## π Quick Start
### 1. Discover Datasets
First, use `syft-datasets` to explore available datasets:
```python
import syft_datasets as syd
# Show interactive dataset browser
syd.datasets
```
### 2. Select and Analyze
Use the selected datasets with the OpenAI-compatible API:
```python
import syft_nsai as nsai
# Select datasets (from the interactive UI or programmatically)
my_datasets = [syd.datasets[0], syd.datasets[3]]
# Create chat completion
response = nsai.client.chat.completions.create(
model=my_datasets,
messages=[
{"role": "system", "content": "You are a data analyst."},
{"role": "user", "content": "Summarize the key insights from this data."}
]
)
# Results are loaded lazily when accessed
insights = response.choices[0].message.content
print(insights)
```
### 3. Advanced Usage
```python
# Multiple datasets for cross-analysis
crop_data = syd.datasets.search("crop")[0]
weather_data = syd.datasets.search("weather")[0]
response = nsai.client.chat.completions.create(
model=[crop_data, weather_data],
messages=[{
"role": "user",
"content": "Analyze the correlation between weather patterns and crop yields."
}]
)
```
## π§ How It Works
1. **Dataset Integration**: Selected datasets are loaded and analyzed within the enclave
2. **Context Enhancement**: Your prompts are enhanced with actual dataset summaries and sample data
3. **Secure Processing**: AI analysis happens in a privacy-preserving enclave using Tinfoil API
4. **Familiar Interface**: Results are returned through OpenAI-compatible response objects
## π Integration with SyftBox Ecosystem
`syft-nsai` is part of the broader SyftBox ecosystem:
- **syft-datasets**: Dataset discovery and management
- **syft-core**: Core SyftBox functionality
- **syftbox-enclave**: Secure enclave execution
- **syft-rds**: Remote data science capabilities
## π API Reference
### Client
```python
import syft_nsai as nsai
# Global client instance
client = nsai.client
```
### Chat Completions
```python
response = nsai.client.chat.completions.create(
model=datasets_list, # List of Dataset objects
messages=messages_list, # OpenAI-style messages
**kwargs # Additional parameters
)
```
### Response Objects
```python
# ChatCompletion
response.choices # List of Choice objects
# Choice
choice = response.choices[0]
choice.message # Message object
# Message
message = choice.message
message.content # Actual AI response (lazy loaded)
```
## π§ͺ Development
### Setup
```bash
git clone https://github.com/OpenMined/syft-nsai
cd syft-nsai
uv sync
```
### Testing
```bash
uv run pytest
```
### Linting
```bash
uv run ruff check .
uv run ruff format .
```
## π€ Contributing
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
## π License
Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.
## π Acknowledgments
Built with β€οΈ by the OpenMined community. Special thanks to:
- The Tinfoil team for secure AI infrastructure
- SyftBox contributors for the federated data ecosystem
- The broader privacy-preserving ML community
---
**Transform your data science workflow. Privately and securely.**
[Get Started β](https://github.com/OpenMined/syft-nsai#quick-start) | [Documentation β](https://github.com/OpenMined/syft-nsai#api-reference) | [Examples β](./examples/)