AI-powered autonomous agent for data science tasks
5.9K
An AI-powered autonomous agent for data science with persistent Jupyter kernel execution, session management, and conversational interface.
____ _____ ___ __
/ __ \/ ___/ / | ____ ____ ____ / /_
/ / / /\__ \ / /| |/ __ `/ _ \/ __ \/ __/
/ /_/ /___/ // ___ / /_/ / __/ / / / /_
/_____//____//_/ |_\__, /\___/_/ /_/\__/
/____/
pip install datascience-agent
With optional features:
pip install "datascience-agent[api]" # FastAPI server support
pip install "datascience-agent[mcp]" # MCP tools support
For development:
git clone https://github.com/nmlemus/dsagent
cd dsagent
uv sync --all-extras
Configuration uses the same environment variables as the CLI and server (see Configuration). The container listens on PORT (default 8000).
# Run API server (default: port 8000)
docker run -d -p 8080:8080 \
-e PORT=8080 \
-e DSAGENT_DEFAULT_MODEL=gpt-4o \
-e OPENAI_API_KEY=sk-your-key \
nmlemus/dsagent:latest
# Run interactive CLI
docker run -it \
-e OPENAI_API_KEY=sk-your-key \
-v "$(pwd)/workspace:/workspace" \
nmlemus/dsagent:latest \
dsagent chat
# One-shot task
docker run --rm \
-e OPENAI_API_KEY=sk-your-key \
-v "$(pwd)/workspace:/workspace" \
nmlemus/dsagent:latest \
dsagent run "Analyze data/sales.csv" --data ./data/sales.csv
For Docker deployment details, see docs/DOCKER.md and docs/guide/docker.md.
Run the setup wizard to configure your LLM provider:
dsagent init
This will:
~/.dsagent/.envgpt-4oclaude-sonnet-4-5gemini/gemini-2.5-flashollama/llama3To use a different model, set DSAGENT_DEFAULT_MODEL or LLM_MODEL in ~/.dsagent/.env, or use the --model flag:
dsagent --model gpt-4o-mini
dsagent
This starts an interactive session where you can:
For batch processing or scripts:
dsagent run "Analyze sales trends" --data ./sales.csv
| Command | Description |
|---|---|
dsagent | Start interactive chat (default) |
dsagent chat | Same as above, with explicit options |
dsagent run "task" | Execute a one-shot task |
dsagent serve | Run REST + WebSocket API server |
dsagent init | Setup wizard for configuration |
dsagent skills list | List installed skills |
dsagent skills install <source> | Install a skill from GitHub or path |
dsagent skills remove <name> | Remove a skill |
dsagent skills info <name> | Show skill details |
dsagent mcp list | List configured MCP servers |
dsagent mcp add <template> | Add an MCP server from template |
dsagent mcp remove <name> | Remove an MCP server |
# Interactive chat with specific model
dsagent --model claude-sonnet-4-5
# One-shot analysis
dsagent run "Find patterns in this data" --data ./dataset.csv
# Resume a previous session
dsagent --session abc123
# With MCP tools (web search)
dsagent --mcp-config ~/.dsagent/mcp.yaml
# Human-in-the-loop mode
dsagent --hitl plan
For complete CLI documentation, see docs/CLI.md.
DSAgent provides two agents for different use cases:
For building chat interfaces and interactive applications:
from dsagent import ConversationalAgent, ConversationalAgentConfig
config = ConversationalAgentConfig(model="gpt-4o")
agent = ConversationalAgent(config)
agent.start()
# Chat with persistent context
response = agent.chat("Load the iris dataset")
print(response.content)
response = agent.chat("Train a classifier on it")
print(response.content) # Has access to previous variables
agent.shutdown()
For one-shot tasks and automated pipelines:
from dsagent import PlannerAgent
with PlannerAgent(model="gpt-4o", data="./data.csv") as agent:
result = agent.run("Analyze this dataset and create visualizations")
print(result.answer)
print(f"Notebook: {result.notebook_path}")
For complete API documentation, see docs/PYTHON_API.md.
DSAgent uses LiteLLM to support 100+ LLM providers:
| Provider | Models | API Key |
|---|---|---|
| OpenAI | gpt-4o, o1, o3-mini | OPENAI_API_KEY |
| Anthropic | claude-sonnet-4-5, claude-opus-4 | ANTHROPIC_API_KEY |
gemini-2.5-pro, gemini-2.5-flash | GOOGLE_API_KEY | |
| DeepSeek | deepseek/deepseek-r1 | DEEPSEEK_API_KEY |
| Ollama | ollama/llama3.2 | None (local) |
For detailed model setup, see docs/MODELS.md.
Connect to external tools via the Model Context Protocol:
# Add web search capability
dsagent mcp add brave-search
# Use it in chat
dsagent --mcp-config ~/.dsagent/mcp.yaml
Available templates: brave-search, filesystem, github, memory, fetch, bigquery
For MCP configuration details, see docs/MCP.md.
Sessions persist your conversation history and kernel state:
# List sessions
dsagent chat
> /sessions
# Resume a session
dsagent --session <session-id>
# Export session to notebook
> /export myanalysis.ipynb
Each run creates organized output:
workspace/
└── runs/{run_id}/
├── data/ # Input data (copied)
├── notebooks/ # Generated Jupyter notebooks
├── artifacts/ # Charts, models, exports
└── logs/ # Execution logs
DSAgent comes with essential data science libraries pre-installed:
| Category | Libraries |
|---|---|
| Core | numpy, pandas, scipy |
| DataFrames | polars, pyarrow |
| Visualization | matplotlib, seaborn, plotly |
| Machine Learning | scikit-learn, xgboost, lightgbm, pycaret |
| Feature Selection | boruta |
| Statistics | statsmodels |
.envMIT
Content type
Image
Digest
sha256:f37024aa9…
Size
1.2 GB
Last updated
8 months ago
docker pull nmlemus/dsagent