cutils-ai 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: cutils-ai
3
+ Version: 0.1.0
4
+ Summary: 通用工具包 - 基于 vutils 重构,新增 AI/LLM 便捷接口
5
+ Author: cutils
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: openai>=1.0
10
+ Requires-Dist: pandas
11
+ Requires-Dist: numpy
12
+ Requires-Dist: matplotlib
13
+ Requires-Dist: tqdm
14
+ Requires-Dist: scikit-learn
15
+ Requires-Dist: torch
16
+ Requires-Dist: gradio
17
+ Requires-Dist: packaging
18
+ Dynamic: author
19
+ Dynamic: requires-python
20
+
21
+ # cutils
22
+
23
+ 通用工具包 — 基于 vutils 重构,新增 AI/LLM 便捷接口。
24
+
25
+ ## 安装
26
+
27
+ ```bash
28
+ # 开发模式安装(推荐)
29
+ cd D:\csy_project\python\cutils
30
+ pip install -e .
31
+
32
+ # 或直接安装
33
+ pip install .
34
+ ```
35
+
36
+ ## 模块概览
37
+
38
+ | 模块 | 功能 |
39
+ |------|------|
40
+ | `cutils.io` | JSON / TXT / CSV 读写 |
41
+ | `cutils.net` | 代理设置 |
42
+ | `cutils.log` | 日志 |
43
+ | `cutils.mail` | 邮件发送 |
44
+ | `cutils.print_color` | 彩色终端输出 |
45
+ | `cutils.timer` | 代码计时器 |
46
+ | `cutils.gpt` | 旧版 OpenAI 兼容接口 |
47
+ | `cutils.tools` | CLI 工具(文件比较、数据浏览) |
48
+ | `cutils.data` | 语言识别 |
49
+ | `cutils.dl` | 深度学习模型(通用分类/回归) |
50
+ | `cutils.ml` | 机器学习(Relief 特征选择) |
51
+ | `cutils.ai` | **新增** — OpenAI API 便捷接口 |
52
+
53
+ ## AI 模块快速上手
54
+
55
+ ```python
56
+ from cutils.ai import configure, chat, chat_stream, embedding, vision
57
+
58
+ # 1. 配置(一次性)
59
+ configure(api_key="sk-xxx", model="gpt-4o")
60
+
61
+ # 2. 单轮对话
62
+ reply = chat("你好,介绍一下自己")
63
+ print(reply)
64
+
65
+ # 3. 带 system prompt
66
+ reply = chat("翻译成英文", system="你是专业翻译")
67
+
68
+ # 4. 流式输出
69
+ for chunk in chat_stream("写一首诗"):
70
+ print(chunk, end="", flush=True)
71
+
72
+ # 5. 获取 embedding
73
+ vec = embedding("hello world")
74
+ print(len(vec)) # 1536
75
+
76
+ # 6. 图片理解
77
+ desc = vision("https://example.com/cat.jpg", "这是什么动物?")
78
+ print(desc)
79
+ ```
80
+
81
+ ## 高级用法
82
+
83
+ ```python
84
+ from cutils.ai import OpenAIClient
85
+
86
+ # 独立客户端(不影响全局默认)
87
+ client = OpenAIClient(api_key="sk-yyy", base_url="https://custom.api.com")
88
+ reply = chat("你好", client=client, model="gpt-4o")
89
+
90
+ # Function Calling
91
+ tools = [{
92
+ "type": "function",
93
+ "function": {
94
+ "name": "get_weather",
95
+ "description": "获取天气",
96
+ "parameters": {
97
+ "type": "object",
98
+ "properties": {"city": {"type": "string"}},
99
+ "required": ["city"]
100
+ }
101
+ }
102
+ }]
103
+ reply = chat("北京今天天气怎么样", tools=tools)
104
+ ```
105
+
106
+ ## CLI
107
+
108
+ ```bash
109
+ ccli ping --name World
110
+ ccli web_data_view --file_path data.json
111
+ ccli compare_two_file --file_path1 a.txt --file_path2 b.txt
112
+ ```
113
+
114
+ ## 从环境变量读取配置
115
+
116
+ ```bash
117
+ export OPENAI_API_KEY="sk-xxx"
118
+ export OPENAI_BASE_URL="https://api.openai.com/v1" # 可选,用于自定义 endpoint
119
+ export CUTILS_MODEL="gpt-4o" # 可选,默认模型
120
+ ```
@@ -0,0 +1,100 @@
1
+ # cutils
2
+
3
+ 通用工具包 — 基于 vutils 重构,新增 AI/LLM 便捷接口。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ # 开发模式安装(推荐)
9
+ cd D:\csy_project\python\cutils
10
+ pip install -e .
11
+
12
+ # 或直接安装
13
+ pip install .
14
+ ```
15
+
16
+ ## 模块概览
17
+
18
+ | 模块 | 功能 |
19
+ |------|------|
20
+ | `cutils.io` | JSON / TXT / CSV 读写 |
21
+ | `cutils.net` | 代理设置 |
22
+ | `cutils.log` | 日志 |
23
+ | `cutils.mail` | 邮件发送 |
24
+ | `cutils.print_color` | 彩色终端输出 |
25
+ | `cutils.timer` | 代码计时器 |
26
+ | `cutils.gpt` | 旧版 OpenAI 兼容接口 |
27
+ | `cutils.tools` | CLI 工具(文件比较、数据浏览) |
28
+ | `cutils.data` | 语言识别 |
29
+ | `cutils.dl` | 深度学习模型(通用分类/回归) |
30
+ | `cutils.ml` | 机器学习(Relief 特征选择) |
31
+ | `cutils.ai` | **新增** — OpenAI API 便捷接口 |
32
+
33
+ ## AI 模块快速上手
34
+
35
+ ```python
36
+ from cutils.ai import configure, chat, chat_stream, embedding, vision
37
+
38
+ # 1. 配置(一次性)
39
+ configure(api_key="sk-xxx", model="gpt-4o")
40
+
41
+ # 2. 单轮对话
42
+ reply = chat("你好,介绍一下自己")
43
+ print(reply)
44
+
45
+ # 3. 带 system prompt
46
+ reply = chat("翻译成英文", system="你是专业翻译")
47
+
48
+ # 4. 流式输出
49
+ for chunk in chat_stream("写一首诗"):
50
+ print(chunk, end="", flush=True)
51
+
52
+ # 5. 获取 embedding
53
+ vec = embedding("hello world")
54
+ print(len(vec)) # 1536
55
+
56
+ # 6. 图片理解
57
+ desc = vision("https://example.com/cat.jpg", "这是什么动物?")
58
+ print(desc)
59
+ ```
60
+
61
+ ## 高级用法
62
+
63
+ ```python
64
+ from cutils.ai import OpenAIClient
65
+
66
+ # 独立客户端(不影响全局默认)
67
+ client = OpenAIClient(api_key="sk-yyy", base_url="https://custom.api.com")
68
+ reply = chat("你好", client=client, model="gpt-4o")
69
+
70
+ # Function Calling
71
+ tools = [{
72
+ "type": "function",
73
+ "function": {
74
+ "name": "get_weather",
75
+ "description": "获取天气",
76
+ "parameters": {
77
+ "type": "object",
78
+ "properties": {"city": {"type": "string"}},
79
+ "required": ["city"]
80
+ }
81
+ }
82
+ }]
83
+ reply = chat("北京今天天气怎么样", tools=tools)
84
+ ```
85
+
86
+ ## CLI
87
+
88
+ ```bash
89
+ ccli ping --name World
90
+ ccli web_data_view --file_path data.json
91
+ ccli compare_two_file --file_path1 a.txt --file_path2 b.txt
92
+ ```
93
+
94
+ ## 从环境变量读取配置
95
+
96
+ ```bash
97
+ export OPENAI_API_KEY="sk-xxx"
98
+ export OPENAI_BASE_URL="https://api.openai.com/v1" # 可选,用于自定义 endpoint
99
+ export CUTILS_MODEL="gpt-4o" # 可选,默认模型
100
+ ```
@@ -0,0 +1,120 @@
1
+ Metadata-Version: 2.4
2
+ Name: cutils-ai
3
+ Version: 0.1.0
4
+ Summary: 通用工具包 - 基于 vutils 重构,新增 AI/LLM 便捷接口
5
+ Author: cutils
6
+ License: MIT
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: openai>=1.0
10
+ Requires-Dist: pandas
11
+ Requires-Dist: numpy
12
+ Requires-Dist: matplotlib
13
+ Requires-Dist: tqdm
14
+ Requires-Dist: scikit-learn
15
+ Requires-Dist: torch
16
+ Requires-Dist: gradio
17
+ Requires-Dist: packaging
18
+ Dynamic: author
19
+ Dynamic: requires-python
20
+
21
+ # cutils
22
+
23
+ 通用工具包 — 基于 vutils 重构,新增 AI/LLM 便捷接口。
24
+
25
+ ## 安装
26
+
27
+ ```bash
28
+ # 开发模式安装(推荐)
29
+ cd D:\csy_project\python\cutils
30
+ pip install -e .
31
+
32
+ # 或直接安装
33
+ pip install .
34
+ ```
35
+
36
+ ## 模块概览
37
+
38
+ | 模块 | 功能 |
39
+ |------|------|
40
+ | `cutils.io` | JSON / TXT / CSV 读写 |
41
+ | `cutils.net` | 代理设置 |
42
+ | `cutils.log` | 日志 |
43
+ | `cutils.mail` | 邮件发送 |
44
+ | `cutils.print_color` | 彩色终端输出 |
45
+ | `cutils.timer` | 代码计时器 |
46
+ | `cutils.gpt` | 旧版 OpenAI 兼容接口 |
47
+ | `cutils.tools` | CLI 工具(文件比较、数据浏览) |
48
+ | `cutils.data` | 语言识别 |
49
+ | `cutils.dl` | 深度学习模型(通用分类/回归) |
50
+ | `cutils.ml` | 机器学习(Relief 特征选择) |
51
+ | `cutils.ai` | **新增** — OpenAI API 便捷接口 |
52
+
53
+ ## AI 模块快速上手
54
+
55
+ ```python
56
+ from cutils.ai import configure, chat, chat_stream, embedding, vision
57
+
58
+ # 1. 配置(一次性)
59
+ configure(api_key="sk-xxx", model="gpt-4o")
60
+
61
+ # 2. 单轮对话
62
+ reply = chat("你好,介绍一下自己")
63
+ print(reply)
64
+
65
+ # 3. 带 system prompt
66
+ reply = chat("翻译成英文", system="你是专业翻译")
67
+
68
+ # 4. 流式输出
69
+ for chunk in chat_stream("写一首诗"):
70
+ print(chunk, end="", flush=True)
71
+
72
+ # 5. 获取 embedding
73
+ vec = embedding("hello world")
74
+ print(len(vec)) # 1536
75
+
76
+ # 6. 图片理解
77
+ desc = vision("https://example.com/cat.jpg", "这是什么动物?")
78
+ print(desc)
79
+ ```
80
+
81
+ ## 高级用法
82
+
83
+ ```python
84
+ from cutils.ai import OpenAIClient
85
+
86
+ # 独立客户端(不影响全局默认)
87
+ client = OpenAIClient(api_key="sk-yyy", base_url="https://custom.api.com")
88
+ reply = chat("你好", client=client, model="gpt-4o")
89
+
90
+ # Function Calling
91
+ tools = [{
92
+ "type": "function",
93
+ "function": {
94
+ "name": "get_weather",
95
+ "description": "获取天气",
96
+ "parameters": {
97
+ "type": "object",
98
+ "properties": {"city": {"type": "string"}},
99
+ "required": ["city"]
100
+ }
101
+ }
102
+ }]
103
+ reply = chat("北京今天天气怎么样", tools=tools)
104
+ ```
105
+
106
+ ## CLI
107
+
108
+ ```bash
109
+ ccli ping --name World
110
+ ccli web_data_view --file_path data.json
111
+ ccli compare_two_file --file_path1 a.txt --file_path2 b.txt
112
+ ```
113
+
114
+ ## 从环境变量读取配置
115
+
116
+ ```bash
117
+ export OPENAI_API_KEY="sk-xxx"
118
+ export OPENAI_BASE_URL="https://api.openai.com/v1" # 可选,用于自定义 endpoint
119
+ export CUTILS_MODEL="gpt-4o" # 可选,默认模型
120
+ ```
@@ -0,0 +1,9 @@
1
+ README.md
2
+ pyproject.toml
3
+ setup.py
4
+ cutils_ai.egg-info/PKG-INFO
5
+ cutils_ai.egg-info/SOURCES.txt
6
+ cutils_ai.egg-info/dependency_links.txt
7
+ cutils_ai.egg-info/entry_points.txt
8
+ cutils_ai.egg-info/requires.txt
9
+ cutils_ai.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ccli = cutils.main:main
@@ -0,0 +1,9 @@
1
+ openai>=1.0
2
+ pandas
3
+ numpy
4
+ matplotlib
5
+ tqdm
6
+ scikit-learn
7
+ torch
8
+ gradio
9
+ packaging
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=45", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "cutils-ai"
7
+ version = "0.1.0"
8
+ description = "通用工具包 - 基于 vutils 重构,新增 AI/LLM 便捷接口"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ license = {text = "MIT"}
12
+
13
+ dependencies = [
14
+ "openai>=1.0",
15
+ "pandas",
16
+ "numpy",
17
+ "matplotlib",
18
+ "tqdm",
19
+ "scikit-learn",
20
+ "torch",
21
+ "gradio",
22
+ "packaging",
23
+ ]
24
+
25
+ [project.scripts]
26
+ ccli = "cutils.main:main"
27
+
28
+ [tool.setuptools.packages.find]
29
+ include = ["cutils*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,31 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ setup(
4
+ name="cutils-ai",
5
+ version="0.1.0",
6
+ author="cutils",
7
+ description="通用工具包 - 基于 vutils 重构,新增 AI/LLM 便捷接口",
8
+ packages=find_packages(),
9
+ python_requires=">=3.8",
10
+ install_requires=[
11
+ "openai>=1.0",
12
+ "pandas",
13
+ "numpy",
14
+ "matplotlib",
15
+ "tqdm",
16
+ "scikit-learn",
17
+ "torch",
18
+ "gradio",
19
+ "packaging",
20
+ ],
21
+ entry_points={
22
+ "console_scripts": [
23
+ "ccli=cutils.main:main",
24
+ ],
25
+ },
26
+ classifiers=[
27
+ "Programming Language :: Python :: 3",
28
+ "License :: OSI Approved :: MIT License",
29
+ "Operating System :: OS Independent",
30
+ ],
31
+ )