Metadata-Version: 2.4
Name: cutils-ai
Version: 0.1.0
Summary: 通用工具包 - 基于 vutils 重构，新增 AI/LLM 便捷接口
Author: cutils
License: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: openai>=1.0
Requires-Dist: pandas
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: tqdm
Requires-Dist: scikit-learn
Requires-Dist: torch
Requires-Dist: gradio
Requires-Dist: packaging
Dynamic: author
Dynamic: requires-python

# cutils

通用工具包 — 基于 vutils 重构，新增 AI/LLM 便捷接口。

## 安装

```bash
# 开发模式安装（推荐）
cd D:\csy_project\python\cutils
pip install -e .

# 或直接安装
pip install .
```

## 模块概览

| 模块 | 功能 |
|------|------|
| `cutils.io` | JSON / TXT / CSV 读写 |
| `cutils.net` | 代理设置 |
| `cutils.log` | 日志 |
| `cutils.mail` | 邮件发送 |
| `cutils.print_color` | 彩色终端输出 |
| `cutils.timer` | 代码计时器 |
| `cutils.gpt` | 旧版 OpenAI 兼容接口 |
| `cutils.tools` | CLI 工具（文件比较、数据浏览） |
| `cutils.data` | 语言识别 |
| `cutils.dl` | 深度学习模型（通用分类/回归） |
| `cutils.ml` | 机器学习（Relief 特征选择） |
| `cutils.ai` | **新增** — OpenAI API 便捷接口 |

## AI 模块快速上手

```python
from cutils.ai import configure, chat, chat_stream, embedding, vision

# 1. 配置（一次性）
configure(api_key="sk-xxx", model="gpt-4o")

# 2. 单轮对话
reply = chat("你好，介绍一下自己")
print(reply)

# 3. 带 system prompt
reply = chat("翻译成英文", system="你是专业翻译")

# 4. 流式输出
for chunk in chat_stream("写一首诗"):
    print(chunk, end="", flush=True)

# 5. 获取 embedding
vec = embedding("hello world")
print(len(vec))  # 1536

# 6. 图片理解
desc = vision("https://example.com/cat.jpg", "这是什么动物？")
print(desc)
```

## 高级用法

```python
from cutils.ai import OpenAIClient

# 独立客户端（不影响全局默认）
client = OpenAIClient(api_key="sk-yyy", base_url="https://custom.api.com")
reply = chat("你好", client=client, model="gpt-4o")

# Function Calling
tools = [{
    "type": "function",
    "function": {
        "name": "get_weather",
        "description": "获取天气",
        "parameters": {
            "type": "object",
            "properties": {"city": {"type": "string"}},
            "required": ["city"]
        }
    }
}]
reply = chat("北京今天天气怎么样", tools=tools)
```

## CLI

```bash
ccli ping --name World
ccli web_data_view --file_path data.json
ccli compare_two_file --file_path1 a.txt --file_path2 b.txt
```

## 从环境变量读取配置

```bash
export OPENAI_API_KEY="sk-xxx"
export OPENAI_BASE_URL="https://api.openai.com/v1"  # 可选，用于自定义 endpoint
export CUTILS_MODEL="gpt-4o"  # 可选，默认模型
```
