This commit is contained in:
2026-06-05 21:11:32 +08:00
parent d8cec42fa9
commit 9ba8306b8d
6 changed files with 550 additions and 144 deletions
+149
View File
@@ -0,0 +1,149 @@
# Local AI Coding Setup — Windows 11 (Aider + Ollama)
## Hardware
- GPU: RTX 5070 Ti, 12GB VRAM
- RAM: 32GB
- OS: Windows 11
---
## Prerequisites
### 1. Install Ollama
Download from https://ollama.com and install.
### 2. Pull a model
```powershell
ollama pull qwen3-coder:30b # 18GB, strong coding model (MoE, VRAM+RAM split)
ollama pull gemma4:12b # 12GB, responds in English more reliably
```
Confirm models are available:
```powershell
ollama list
```
Confirm Ollama is serving:
```powershell
curl http://localhost:11434/api/tags
```
---
## Install Aider
```powershell
pip install aider-chat
aider --version # should print version number
```
---
## Project Config
Create `.aider.conf.yml` in your project root:
```yaml
model: ollama/gemma4:12b
openai-api-base: http://localhost:11434/v1
openai-api-key: ollama
edit-format: whole
map-tokens: 2048
no-auto-commits: true
system-prompt: "Always respond in English only. Never use Chinese or any other language."
```
**Config notes:**
- `edit-format: whole` — more reliable file writes for local models (avoids code showing in chat only)
- `map-tokens: 2048` — limits repo map size, important for smaller context windows
- `no-auto-commits: true` — review changes before they hit git
- `system-prompt` — forces English responses (important for Qwen3 which defaults to Chinese)
Switch models without editing the file:
```
/model ollama/qwen3-coder:30b
```
---
## Optional: Performance Tuning (if inference is slow)
Create a `Modelfile` in the project root:
```
FROM qwen3-coder:30b
PARAMETER num_ctx 8192
PARAMETER num_gpu 99
```
Register it:
```powershell
ollama create qwen3-coder-tuned -f Modelfile
```
Update `.aider.conf.yml`:
```yaml
model: ollama/qwen3-coder-tuned
```
**Why:** `num_gpu 99` maximizes VRAM usage. `num_ctx 8192` prevents the KV cache from
spilling too much into RAM. Recommended context range: 409616384.
---
## Daily Aider Workflow
Start Aider (reads config automatically):
```powershell
aider
```
| Command | What it does |
|---------|-------------|
| `/add src/foo.py` | Add file to context |
| `/drop src/foo.py` | Remove file from context |
| `/diff` | See pending changes |
| `/undo` | Revert last change |
| `/run pytest` | Run command, share output with model |
| `/run git rm --cached file.py` | Run git commands from inside Aider |
| `/clear` | Clear chat history (keep files) |
| `/settings` | Show loaded config (verify auto_commits, system_prompt) |
| `/model ollama/gemma4:12b` | Switch model on the fly |
| `/exit` | Quit |
---
## Known Issues & Fixes
### Model responds in Chinese
Cause: Qwen3 is a Chinese model and defaults to Chinese.
Fix: `system-prompt` in `.aider.conf.yml` (already included above). Restart Aider after config change.
### Aider shows code in chat but doesn't write files
Cause: Model didn't follow Aider's edit format.
Fix 1: `/add target_file.py` before asking — hints the target file to the model.
Fix 2: `edit-format: whole` in config (already included above).
### "File not found" / repo-map warnings for deleted files
Cause: File deleted from disk but still tracked in git index.
Fix:
```powershell
git rm --cached filename.py
```
Or from inside Aider:
```
/run git rm --cached filename.py
```
### Config changes not taking effect
Fix: Exit Aider (`/exit`) and restart. Config is only read at startup.
---
## Verify Everything Works
1. `ollama list` — model appears
2. `aider --version` — prints version
3. Start Aider, run `/settings` — confirm `auto_commits: False` and `system_prompt` present
4. Ask Aider to create a simple file — it should write to disk, not just chat
5. Response is in English
+342
View File
@@ -0,0 +1,342 @@
# Local AI Coding Environment Implementation Plan
## Objective
Build a local-first AI coding environment on a Windows 11 workstation with the following requirements:
### Hardware
* NVIDIA RTX 5070 Ti 12GB VRAM
* 64GB+ system RAM (if available)
* Windows 11
* WSL2 Ubuntu
* VS Code
### Existing Software
* Ollama installed and operational
* Qwen3-Coder 30B installed in Ollama
* Claude Code CLI installed
* Git installed
### Constraints
* Source code is confidential.
* All code must remain local by default.
* Cloud models may be used only as an optional fallback.
* Minimize API costs.
* Support large codebases.
---
# Target Architecture
```text
VS Code
|
+---- Continue Extension
|
+---- Claude Code CLI
|
+---- Aider
|
v
Ollama
|
v
Qwen3-Coder 30B
```
---
# Project Goals
Implement and validate the following workflows.
## Workflow 1: Local Chat
Developer can:
* Ask coding questions
* Explain code
* Generate code
* Review code
using:
```text
VS Code
+
Continue
+
Ollama
+
Qwen3-Coder 30B
```
---
## Workflow 2: Local Agent
Developer can:
* Refactor code
* Create files
* Modify files
* Run git-aware edits
using:
```text
Aider
+
Ollama
+
Qwen3-Coder 30B
```
---
## Workflow 3: Claude Code Optional
Developer can:
* Use Claude Code against local Ollama models
* Compare behavior against Aider
* Determine whether Claude Code provides additional value
using:
```text
Claude Code
+
Ollama
+
Qwen3-Coder 30B
```
---
# Deliverables
Produce the following:
## Deliverable 1
Environment verification script.
Verify:
* Ollama installed
* NVIDIA GPU visible
* CUDA available
* WSL functioning
* Qwen3-Coder model available
Expected output:
```text
PASS: Ollama
PASS: GPU
PASS: CUDA
PASS: Qwen3-Coder
```
---
## Deliverable 2
Aider installation guide.
Include:
### Linux / WSL installation
Commands:
```bash
pipx install aider-chat
```
or preferred installation method.
### Ollama integration
Configuration examples.
### Verification steps
Simple repository test.
---
## Deliverable 3
Continue configuration.
Create:
### VS Code setup instructions
Install Continue extension.
### Model configuration
Configure Continue to use:
```text
Ollama
Qwen3-Coder 30B
```
### Example config files
Include complete examples.
---
## Deliverable 4
Claude Code local model integration.
Research and implement the best available approach for:
```text
Claude Code
->
OpenAI-compatible endpoint
->
Ollama
```
Requirements:
* Use officially supported methods where possible.
* Avoid unsupported hacks.
* Document limitations.
* Provide rollback procedure.
---
## Deliverable 5
Performance optimization.
Analyze:
### VRAM usage
Qwen3-Coder 30B on RTX 5070 Ti 12GB.
### Recommended quantization
Evaluate:
* Q4
* Q5
* IQ3
Recommend the best balance between:
* Quality
* Speed
* Memory usage
---
## Deliverable 6
Benchmark suite.
Create repeatable tests:
### Test 1
Generate a REST API.
### Test 2
Refactor a medium-sized module.
### Test 3
Write unit tests.
### Test 4
Debug a failing application.
Measure:
* Completion time
* Accuracy
* Token throughput
* User effort
Compare:
```text
Aider + Qwen3-Coder 30B
Claude Code + Qwen3-Coder 30B
Continue + Qwen3-Coder 30B
```
---
# Preferred Outcome
Primary development workflow:
```text
VS Code
+
Continue
+
Qwen3-Coder 30B
```
Agent workflow:
```text
Aider
+
Qwen3-Coder 30B
```
Optional advanced workflow:
```text
Claude Code
+
Qwen3-Coder 30B
```
---
# Success Criteria
The project is successful if:
1. All code remains local.
2. No cloud services are required.
3. Developer can perform daily coding tasks locally.
4. Aider successfully edits repositories.
5. Continue provides a productive IDE experience.
6. Claude Code local integration is evaluated and documented.
7. Setup can be reproduced on a fresh machine.
---
# Final Report
Produce a final report containing:
* Architecture diagram
* Installation steps
* Configuration files
* Benchmark results
* Known limitations
* Recommended workflow
* Future upgrade path
The report should be suitable for long-term maintenance and onboarding of additional developers.
-74
View File
@@ -1,74 +0,0 @@
import os
import sys
import pandas as pd
from pathlib import Path
def merge_excel_files(input_dir):
"""
合并指定目录下所有包含"交易流水"工作表的Excel文件
"""
# 创建输出文件路径
output_file = os.path.join(input_dir, "txn_summary.xlsx")
# 存储所有数据的列表
all_data = []
# 遍历输入目录中的所有文件
for filename in os.listdir(input_dir):
if filename.endswith(('.xlsx', '.xls')):
file_path = os.path.join(input_dir, filename)
try:
# 读取Excel文件的所有工作表
excel_file = pd.ExcelFile(file_path)
# 检查是否包含"交易流水"工作表
if "交易流水" in excel_file.sheet_names:
# 读取"交易流水"工作表
df = pd.read_excel(file_path, sheet_name="交易流水")
# 检查数据是否为空
if not df.empty:
# 添加源文件名列
df['来源文件'] = filename
# 将数据添加到列表中
all_data.append(df)
else:
print(f"警告: 文件 {filename} 中的'交易流水'工作表为空")
except Exception as e:
print(f"处理文件 {filename} 时出错: {e}")
# 如果没有找到任何匹配的文件,退出
if not all_data:
print("未找到包含'交易流水'工作表的Excel文件或所有文件都为空")
return
# 合并所有数据
merged_df = pd.concat(all_data, ignore_index=True)
# 保存合并后的数据到输出文件
merged_df.to_excel(output_file, index=False)
print(f"成功合并 {len(all_data)} 个文件,结果已保存到: {output_file}")
def main():
# 从命令行参数获取输入目录路径
if len(sys.argv) != 2:
print("请提供输入目录路径作为命令行参数")
print("使用方法: python merge_excel.py <input_directory>")
return
input_dir = sys.argv[1]
# 检查输入目录是否存在
if not os.path.isdir(input_dir):
print(f"错误: 目录 '{input_dir}' 不存在")
return
# 合并Excel文件
merge_excel_files(input_dir)
if __name__ == "__main__":
main()
-63
View File
@@ -1,63 +0,0 @@
import os
import pandas as pd
from pathlib import Path
import sys
def merge_transaction_data():
# 获取用户输入的路径
input_path_str = input("请输入包含 Excel 文件的文件夹路径: ").strip()
input_dir = Path(input_path_str)
# 检查路径是否有效
if not input_dir.is_dir():
print(f"错误:提供的路径 '{input_path_str}' 不是一个有效的目录。")
return
all_data = []
target_sheet = "交易流水"
# 获取目录下所有的 excel 文件 (支持 .xlsx 和 .xls)
files = list(input_dir.glob("*.xlsx")) + list(input_dir.glob("*.xls"))
if not files:
print("在该目录下未找到任何 Excel 文件。")
return
for file_path in files:
try:
# 读取指定的 sheet
# 使用 pandas 的 read_excel,如果 sheet 不存在会抛出 ValueError
df = pd.read_excel(file_path, sheet_name=target_sheet)
if df.empty:
print(f"跳过 {file_path.name}:工作表 '{target_sheet}' 为空。")
continue
all_data.append(df)
print(f"成功读取: {file_path.name}")
except ValueError:
# 如果找不到指定的 sheet 名称,则跳过该文件
print(f"跳过 {file_path.name}:未找到名为 '{target_sheet}' 的工作表。")
except Exception as e:
print(f"处理文件 {file_path.name} 时发生错误: {e}")
if all_data:
# 合并所有 DataFrame
merged_df = pd.concat(all_data, ignore_index=True)
# 定义输出路径
output_file = input_dir / "txn_summary.xlsx"
# 保存结果
# 使用 openpyxl 作为引擎以确保兼容性
merged_df.to_excel(output_file, index=False, engine='openpyxl')
print("-" * 30)
print(f"合并成功!")
print(f"总计处理文件数: {len(all_data)}")
print(f"结果已保存至: {output_file}")
else:
print("未找到包含 '" + target_sheet + "' 工作表的有效数据,未生成输出文件。")
if __name__ == "__main__":
# 确保安装了必要的库:pip install pandas openpyxl
merge_transaction_data()
+60 -8
View File
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"id": "259a585b",
"metadata": {},
"outputs": [],
@@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 3,
"id": "fe7bf6eb",
"metadata": {},
"outputs": [
@@ -58,7 +58,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 4,
"id": "4bddedb8",
"metadata": {},
"outputs": [
@@ -95,18 +95,70 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "b33dcb00",
"metadata": {},
"outputs": [],
"source": [
"set(text)"
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"65\n",
"\n",
" !$&',-.3:;?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\n"
]
}
],
"source": [
"chars = sorted(list(set(text)))\n",
"vocab_size = len(chars)\n",
"print(vocab_size\n",
")\n",
"print(\"\".join(chars\n",
"))\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7c84058a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'!'"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"stoi = {char:i for i, char in enumerate(chars)}\n",
"itos = {i:char for i, char in enumerate(chars)}\n",
"# print (itos)\n",
"\n",
"stoi['a'] # 0\n",
"itos[2]\n",
"\n",
"encode = lambda s: \n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4f43742c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"display_name": ".venv (3.12.10)",
"language": "python",
"name": "python3"
},