AI Personal Learning
and practical guidance
CyberKnife Drawing Mirror

AiPy: automating the task of running Python code for data analysis

General Introduction

AiPy is an open source Python command-line tool developed by the Knownsec team. It combines the Large Language Model (LLM) and the Python runtime environment , allowing users to describe the task through natural language , automatically generate and run Python code.AiPy is suitable for data engineers , programmers and users who need to quickly process data . It supports CSV, Excel, JSON and other formats, covering data cleaning, analysis, visualization and other functions. AiPy is designed for data engineers and programmers who need to process data quickly. it supports CSV, Excel, JSON and other formats, covering data cleansing, analysis, visualization, etc. Users can input requirements in natural language or run Python code directly, sharing data in both modes, with simple operation.

AiPy: Automating the Running of Python Code to Accomplish Targeted Tasks-1


 

Function List

  • Natural language code generation: the user describes the task and AiPy automatically generates and runs the Python code.
  • Data format support: Handles CSV, Excel, JSON, SQLite, Parquet and other formats.
  • Data processing: supports cleaning, conversion, calculation, aggregation, sorting, grouping and filtering.
  • Data Visualization: Generate charts such as bar charts, pie charts, etc.
  • Python command-line mode: Type and run Python code directly.
  • Third-party library management: automatic prompts to install required libraries, such as pandas maybe psutilThe
  • Code Error Correction: Detect and fix code errors with Abstract Syntax Trees (AST).
  • API calls: Support for Internet APIs (e.g. weather, maps) and local private APIs.
  • Mode switching: Freely switch between task mode (natural language) and Python mode (code input).
  • Local Deployment: Supports local data processing to protect privacy and security.

 

Using Help

Installation process

AiPy supports Windows, macOS and Linux, and Python 3.9 or above is recommended. Here are the installation steps:

  1. Checking the Python Version
    Make sure Python 3.9+ is installed. Run the following command to confirm:

    python3 --version
    

    If the version is not sufficient, you can download and install it from the Python website.

  2. Installation via pip
    Install AiPy using pip:

    pip install aipyapp
    

    This will automatically install dependent libraries. If you have problems, upgrade pip:

    pip install --upgrade pip
    
  3. Cloning of source code (optional)
    To experience the latest features, clone your GitHub repository:

    git clone https://github.com/knownsec/aipyapp.git
    cd aipyapp
    

    Create a virtual environment and install dependencies:

    python3 -m venv venv
    source venv/bin/activate  # Linux/macOS
    venv\Scripts\activate     # Windows
    pip install -r requirements.txt
    
  4. Windows Free Edition
    Windows users can download the one-click runtime package, unzip it and run it update.bat Start AiPy without configuring your environment. Download link:AiPy Free Installation PackageThe
  5. Configuring the Big Model
    AiPy requires large model support, DeepSeek API is recommended (cost effective). Create a configuration file in the installation directory or user directory (e.g. .aipyconfig), fill in the API information:

    [llm]
    api_key = your_deepseek_api_key
    model = deepseek
    

    Support for local models (e.g. Ollama, LMStudio) requires configuration of the API address.

  6. Launch AiPy
    Run the following command:

    aipython
    

    By default, you enter task mode with the prompt AiPy (Quit with 'exit()') >>>The

Basic use

AiPy provides task mode and Python mode, both modes are interoperable.

  • mission mode
    Ideal for fast task processing. The user inputs natural language and AiPy generates and runs the code. Example:

    ai("读取 orders.csv,计算每种产品的总收入")
    

    AiPy Generate code:

    import pandas as pd
    df = pd.read_csv('orders.csv')
    df['收入'] = df['价格'] * df['数量']
    result = df.groupby('产品')['收入'].sum()
    print(result)
    

    If a third-party library is required, it will be prompted:

    📦 LLM requests to install third-party packages: ['pandas']
    If you agree, enter 'y [y/n] (n):
    

    importation y Acknowledgment.

  • Python mode
    Startup command for users familiar with Python:

    aipython --python
    

    Enter the code directly, for example:

    import pandas as pd
    df = pd.read_csv('orders.csv')
    print(df.head())
    

    The data generated in task mode can be continued in Python mode.

Featured Function Operation

  1. natural language programming
    The user describes the requirements and AiPy automatically generates the code. Example:

    ai("从 data.csv 筛选薪资高于 5000 的记录,按年龄排序")
    

    Generate code:

    import pandas as pd
    df = pd.read_csv('data.csv')
    result = df[df['薪资'] > 5000][['姓名', '年龄', '薪资']].sort_values(by='年龄')
    print(result)
    
  2. data visualization
    Support for generating charts. Example:

    ai("绘制 orders.csv 中产品收入的饼图")
    

    Generate code:

    import pandas as pd
    import matplotlib.pyplot as plt
    df = pd.read_csv('orders.csv')
    df['收入'] = df['价格'] * df['数量']
    result = df.groupby('产品')['收入'].sum()
    plt.pie(result, labels=result.index, autopct='%1.1f%%')
    plt.show()
    
  3. API Calls
    Internet and local APIs are supported. for example:

    ai("查询上海明天天气")
    

    AiPy calls the weather API and returns results. API Key needs to be configured.

  4. Code Correction
    AiPy uses AST to detect and fix code errors, such as indentation or syntax problems, to ensure smooth operation.
  5. local deployment
    Supports local operation, data processing is completed in the user's device, suitable for sensitive data scenarios. No need to network after configuring the local model.

Example of operation flow

see also paragraph (e.g. of the commentary) sales.csv(Columns: Product, Price, Volume) as an example:

  1. Start AiPy:
    aipython
    
  2. Enter the task:
    ai("读取 sales.csv,计算每种产品总销量")
    

    Output:

    产品    总销量
    手机    100
    电脑     50
    
  3. Generate charts:
    ai("绘制总销量的柱状图")
    

    Displays a bar graph.

  4. Switch to Python mode:
    aipython --python
    

    Input:

    plt.title('产品销量')
    plt.show()
    

caveat

  • Make sure the file path is correct, otherwise an error is prompted.
  • Check network or local model status when configuring the API.
  • Local models require hardware support (e.g. GPU).
  • Exit AiPy Input exit()The

application scenario

  1. data analysis
    Data engineers quickly process Excel or CSV to complete cleansing, statistics and visualization, eliminating manual coding.
  2. Programming Learning
    Beginners try tasks in natural language, see generated code, and learn Python library usage.
  3. automation script
    Developers generate scripts to process files, monitor resources, or call APIs.
  4. Life Helper
    Check the weather, plan a trip, or filter your food, and AiPy automatically organizes the results.

 

QA

  1. What models does AiPy support?
    Support DeepSeek, Ollama, LMStudio, etc., you can set the API in the configuration file. DeepSeek is recommended.
  2. How do I call the local API?
    Add the API address and description to the configuration file and AiPy automatically generates the calling code.
  3. What about code errors?
    AiPy fixes common errors via AST. If it fails, use Python mode to adjust it manually.
  4. Do I need to network?
    Local deployment requires no network, suitable for private scenarios. Internet API calls require a network.
May not be reproduced without permission:Chief AI Sharing Circle " AiPy: automating the task of running Python code for data analysis
en_USEnglish