Skip to main content

LLM-based agent for general purpose tasks

Project description

Pywen

Python 3.9+ License: MIT Alpha

ไธญๆ–‡็‰ˆ | English

Pywen Logo

Pywen is a Python CLI tool based on Qwen3-Coder, designed specifically for intelligent software engineering tasks. It provides a conversational interface that can understand natural language instructions and execute complex development workflows through an advanced agent system.

๐ŸŽฏ Project Background

Pywen is built on the Qwen3-Coder large language model, aiming to provide developers with an efficient and intelligent code assistant. The project is primarily adapted from Qwen-Code, with deep optimizations for Python developers and the Qwen3-Coder model.

Why Choose Qwen3-Coder?

  • ๐Ÿš€ Code Specialization: Qwen3-Coder excels in code generation, understanding, and debugging
  • โšก Efficient Inference: Optimized model architecture providing fast responses
  • ๐Ÿ”ง Engineering Practicality: Specifically trained for real-world software development scenarios

Project Status: The project is still under active development. We welcome your help in improving Pywen.

Differences from Other Code Agent CLIs

Pywen is a Python-based CLI tool with excellent Python ecosystem compatibility and developer-friendliness. It provides a transparent, modular architecture that allows researchers and developers to easily modify, extend, and analyze, making it an ideal platform for researching AI Agent architectures, conducting ablation studies, and developing new Agent capabilities. This research-friendly design enables academia and the open-source community to more easily contribute to foundational Agent frameworks and build innovative applications, facilitating continuous breakthroughs in the rapidly evolving AI Agent field.

โœจ Features

  • ๐Ÿค– Qwen3-Coder-Plus Powered: Based on Alibaba Cloud's latest code-specialized large model
  • ๐Ÿ“ฆ Modular: Built on modular architecture, extensible and customizable (future support for multi-agent frameworks)
  • ๐Ÿ› ๏ธ Rich Tool Ecosystem: File editing, bash execution, sequential thinking, and more
  • ๐Ÿ“Š Trajectory Recording: Detailed logging of all Agent operations for debugging and analysis
  • โš™๏ธ Smart Configuration: Automatic guided configuration on first run, supports environment variables
  • ๐Ÿ“ˆ Session Statistics: Real-time tracking of API calls, tool usage, and token consumption

๐Ÿš€ Quick Start

Installation

pip install pywen-agent
Build from source with uv (recommended)
git clone https://github.com/PAMPAS-Lab/Pywen.git
cd Pywen
uv venv
uv sync --all-extras

# linux/macos
source .venv/bin/activate

# windows
.venv\Scripts\activate

First Use

Simply run the pywen command to start:

pywen

If it's your first run and there's no configuration file, Pywen will automatically start the configuration wizard:

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•—    โ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ–ˆโ•—   โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•”โ•โ•โ–ˆโ–ˆโ•—โ•šโ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ•‘    โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•โ•โ•โ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•”โ• โ–ˆโ–ˆโ•‘ โ–ˆโ•— โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—  โ–ˆโ–ˆโ•”โ–ˆโ–ˆโ•— โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•”โ•โ•โ•โ•   โ•šโ–ˆโ–ˆโ•”โ•  โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘โ–ˆโ–ˆโ•”โ•โ•โ•  โ–ˆโ–ˆโ•‘โ•šโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘
โ–ˆโ–ˆโ•‘        โ–ˆโ–ˆโ•‘   โ•šโ–ˆโ–ˆโ–ˆโ•”โ–ˆโ–ˆโ–ˆโ•”โ•โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ•—โ–ˆโ–ˆโ•‘ โ•šโ–ˆโ–ˆโ–ˆโ–ˆโ•‘
โ•šโ•โ•        โ•šโ•โ•    โ•šโ•โ•โ•โ•šโ•โ•โ• โ•šโ•โ•โ•โ•โ•โ•โ•โ•šโ•โ•  โ•šโ•โ•โ•โ•

Configuration file not found, starting setup wizard...

API Key: [Enter your Qwen API key]
Base URL: https://dashscope.aliyuncs.com/compatible-mode/v1
Model: qwen3-coder-plus
...

โœ… Configuration saved to pywen_config.json

After configuration is complete, you can start using Pywen!

Basic Usage

Once you enter the Pywen command-line interface, you can:

# File operations
> Create a Python script to calculate Fibonacci sequence
> Refactor functions in main.py to make them more efficient

# Code analysis and debugging
> Fix bugs in this project and add unit tests
> Analyze performance bottlenecks in my code

# Project management
> Create a new Flask web application with proper structure
> Add comprehensive documentation to this codebase

๐Ÿ“– User Guide

Command Line Interface

Available Commands

# System commands
/help, /?     - Show help information
/clear        - Clear screen and conversation history
/status       - Show agent status
/config       - Show current configuration
/stats        - Check session statistics (API calls, tokens, etc.)
/quit, /exit  - Exit Pywen

# Special commands
@<file>       - Include file content in prompt
!<command>    - Execute shell command

# Keyboard shortcuts
Ctrl+Y        - Toggle YOLO mode (auto-approve all operations - use with caution!)

# Direct input of task descriptions to execute agent

YOLO Mode

Use with caution:

  • Press Ctrl+Y to toggle YOLO mode
  • Default behavior: All tool calls require user confirmation for safety
  • In YOLO mode, all tool calls are automatically approved without user confirmation
  • This speeds up execution but removes safety checks
  • Mode status is displayed in the interface
  • You can also type 'a' (always) when prompted for tool confirmation to enable YOLO mode

Configuration Management

Pywen uses the pywen_config.json file for configuration:

{
  "default_provider": "qwen",
  "max_steps": 20,
  "enable_lakeview": false,
  "model_providers": {
    "qwen": {
      "api_key": "your-qwen-api-key",
      "base_url": "https://dashscope.aliyuncs.com/compatible-mode/v1",
      "model": "qwen3-coder-plus",
      "max_tokens": 4096,
      "temperature": 0.5
    }
  }
}

Configuration Priority:

  1. Command line arguments (highest)
  2. Configuration file values
  3. Environment variables
  4. Default values (lowest)

Environment Variables

You can set API keys through environment variables:

# Qwen (required)
export QWEN_API_KEY="your-qwen-api-key"

# Tool API Keys (optional but recommended)
export SERPER_API_KEY="your-serper-api-key"  # For web search
export JINA_API_KEY="your-jina-api-key"      # For content reading

# Other supported providers
export OPENAI_API_KEY="your-openai-api-key"
export ANTHROPIC_API_KEY="your-anthropic-api-key"

Getting API Keys

Serper API (Web Search):

  1. Visit serper.dev
  2. Sign up for a free account
  3. Get your API key from the dashboard

Jina API (Content Reading):

  1. Visit jina.ai
  2. Sign up for a free account
  3. Get your API key from the dashboard

๐Ÿ› ๏ธ Available Tools

Pywen provides a comprehensive toolkit for software development:

  • File Operations: Create, edit, read, and manage files
  • Bash Execution: Run shell commands and scripts
  • Sequential Thinking: Structured problem-solving approach
  • Task Completion: Mark tasks as complete with summaries
  • JSON Operations: Parse and manipulate JSON data

For detailed information about all available tools and their capabilities, see docs/tools.md.

๐Ÿ“Š Trajectory Recording

Pywen automatically records detailed execution trajectories for debugging and analysis:

# Trajectory files are automatically saved to trajectories/ directory
trajectories/trajectory_xxxxxx.json

Trajectory files contain:

  • LLM Interactions: All messages, responses, and tool calls
  • Agent Steps: State transitions and decision points
  • Tool Usage: Which tools were called and their results
  • Metadata: Timestamps, token usage, and execution metrics

๐Ÿ“ˆ Session Statistics

Monitor your usage with real-time statistics:

> /stats

Tracks:

  • API calls and token consumption
  • Tool usage patterns
  • Session duration
  • Model performance metrics

๐Ÿค Contributing

We welcome contributions to Pywen! Here's how to get started:

  1. Fork the repository
  2. Set up the development environment:
    git clone https://github.com/your-username/Pywen.git
    cd Pywen
    uv venv
    uv sync --all-extras
    
    # linux/macos
    source .venv/bin/activate
    
    # windows
    .venv\Scripts\activate
    
  3. Create a feature branch
  4. Make your changes and add tests
  5. Submit a pull request

Development Guidelines

  • Follow PEP 8 style guidelines
  • Add tests for new features
  • Update documentation as needed
  • Use type hints appropriately
  • Ensure all tests pass before submitting

๐Ÿ“‹ Requirements

  • Python 3.9+
  • Qwen API key (recommended) or other supported LLM provider API keys
  • Internet connection for API access

๐Ÿ”ง Troubleshooting

Common Issues

Configuration Issues:

# Re-run configuration wizard
rm pywen_config.json
pywen

API Key Issues:

# Verify your API key is set
echo $QWEN_API_KEY

# Check configuration in Pywen
> /config

๐Ÿ™ Acknowledgments

We thank:

  • Google for the Gemini CLI project, which provided agent execution logic and rich tool ecosystem libraries for this project
  • Alibaba Cloud Qwen Team for providing the powerful Qwen3-Coder model and Qwen-Code reference implementation
  • ByteDance for the trae-agent project, which provided valuable foundational architecture for this project

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Pywen - Making the power of Qwen3-Coder accessible for intelligent software development! ๐Ÿš€

PAMPAS-Lab - Dedicated to breakthroughs in large model agent frameworks, bridging AI research and applications! ๐Ÿš€

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywen-1.0.0.tar.gz (257.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywen-1.0.0-py3-none-any.whl (296.6 kB view details)

Uploaded Python 3

File details

Details for the file pywen-1.0.0.tar.gz.

File metadata

  • Download URL: pywen-1.0.0.tar.gz
  • Upload date:
  • Size: 257.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for pywen-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c6b96b02f792739061bc1353a0682022df67abb37e5de56fbdd8732e7ebfe2c0
MD5 4665cbded57564c70ed666986300b5e8
BLAKE2b-256 9af9afff5212749313f47cb1bd1abf9bd4700626052967555345ed25e346423c

See more details on using hashes here.

File details

Details for the file pywen-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pywen-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 296.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for pywen-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c400ce1013d10ce3bb9467990af4ee513de7388515a42ed5c013272a57e2eecb
MD5 e5deeaedb27a137e62b9ecc526e843e9
BLAKE2b-256 aae9985c64dcdfdb64f5c3134c46c1cb7f10451b7b852b0ae2fde991934e778d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page