这个项目是对 Google 研究团队的论文 DS-STAR: A State-of-the-Art Versatile Data Science Agent 的实现。
这个项目是对 Google 研究团队的论文 DS-STAR: A State-of-the-Art Versatile Data Science Agent 的实现。
DS-STAR (Data Science - Structured Thought and Action) is a Python-based agentic framework for automating data science tasks. It leverages a multi-agent system powered by Google's Gemini models to analyze data, devise a plan, write and execute code, and iteratively refine the solution to answer a user's query.
This project is an implementation of the paper from Google Research: DS-STAR: A State-of-the-Art Versatile Data Science Agent. Paper
config.yaml file.The DS-STAR pipeline is composed of several phases and agents:
Analyzer agent inspects the initial data files and generates summaries.Planner creates an initial plan to address the user's query.Coder generates Python code to execute the current step of the plan.Debugger agent attempts to fix any code that fails.Verifier checks if the result sufficiently answers the query.Router decides what to do next: either finalize the plan or add a new step for refinement.Finalyzer agent takes the final code and results and formats them into a clean, specified output format (e.g., JSON).All artifacts for each run are stored in the runs/ directory, organized by run_id.
/
├─── dsstar.py # Main script containing the agent logic and CLI
├─── config.yaml # Main configuration file
├─── prompt.yaml # Prompts for the different AI agents
├─── pyproject.toml # Project metadata and dependencies (uv format)
├─── uv.lock # Locked dependency versions for reproducibility
├─── .python-version # Python version specification for uv
├─── data/ # Directory for your data files
└─── runs/ # Directory where all experiment runs and artifacts are storedClone the repository:
git clone
cd DS-StarInstall uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | shInstall dependencies with uv:
uv syncSet your API Key: The application requires a Gemini API key. You can set it as an environment variable:
export GEMINI_API_KEY='your-api-key'Alternatively, you can add it to the config.yaml file.
Customize config.yaml:
Create a config.yaml file in the root of the project and customize the settings. See the "Configuration" section below for details.
# config.yaml
model_name: 'gemini-1.5-flash'
max_refinement_rounds: 5
interactive: false
# api_key: 'your-api-key' # Alternatively, place it here
# Optional: Configure specific models for different agents
agent_models:
PLANNER: 'gpt-4'
CODER: 'gemini-1.5-pro'
VERIFIER: 'gemini-1.5-flash'Place your data files (e.g., .xlsx, .csv) in the data/ directory.
To start a new analysis, you need to provide the data files and a query.
Using uv:
uv run python dsstar.py --data-files file1.xlsx file2.xlsx --query "What is the total sales for each department?"If a run was interrupted, you can resume it using its run_id.
uv run python dsstar.py --resume You can manually edit the last generated piece of code and re-run it. This is useful for manual debugging or tweaking the agent's logic.
uv run python dsstar.py --edit-last --resume This will open the last code file in your default text editor (nano, vim, etc.). After you save and close the editor, the script will re-execute the modified code.
To review each step before proceeding, use the interactive flag.
uv run python dsstar.py --interactive --data-files ... --query "..."This project uses uv for fast and reliable dependency management. Here are some useful commands:
uv syncuv add package-nameuv remove package-nameuv sync --upgradeuv run python script.pyuv pip listuv run to execute commands directlyThe following options are available in config.yaml and can be overridden by CLI arguments:
run_id (string): The ID of a run to resume.max_refinement_rounds (int): The maximum number of times the agent will try to refine its plan.api_key (string): Your Gemini API key.model_name (string): The Gemini model to use (e.g., gemini-1.5-flash).interactive (bool): If true, waits for user input before executing each step.auto_debug (bool): If true, the Debugger agent will automatically try to fix failing code.execution_timeout (int): Timeout in seconds for code execution.execution_timeout (int): Timeout in seconds for code execution.preserve_artifacts (bool): If true, all step artifacts are saved to the runs directory.agent_models (dict): A dictionary mapping agent names (e.g., PLANNER, CODER) to specific model names. If not specified, model_name is used.DS-STAR supports multiple AI model providers. Each provider requires specific environment variables to be configured:
Provider Identifier: Default provider (no prefix required)
Environment Variable:
export GEMINI_API_KEY='your-gemini-api-key'Model Examples:gemini-2.5-pro, gemini-2.0-flash
Provider Identifier: Models prefixed with gpt or o1
Environment Variable:
export OPENAI_API_KEY='your-openai-api-key'Model Examples: gpt-4, gpt-4-turbo, o1
Provider Identifier: Models prefixed with ollama/
Environment Variables:
export OLLAMA_API_KEY='your-ollama-api-key' # Optional
export OLLAMA_HOST='http://localhost:11434' # Optional, defaults to http://localhost:11434Model Examples: ollama/llama3, ollama/qwen3-coder
Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or feature requests.
暂无开放 Issues,或尚未同步最近议题。