看到这个介绍:两天时间,AI协助我把OpenAI开源的Codex CLI重构成Python 版本——Codexy! - 知乎
官网:GitHub - AndersonBY/codexy: Lightweight coding agent that runs in your terminal
重要提示: Python 版本 (codexy
) 目前缺少原始 TypeScript 版本中的平台特定沙盒机制(如 macOS Seatbelt 或 Docker/iptables)。在 full-auto
模式下,命令会在您的系统上直接执行,工具本身不会施加网络或文件系统限制。dangerous-auto
模式明确地在非沙盒环境中运行所有操作。请极其谨慎地使用自动批准模式,尤其是在不受信任的环境或未受版本控制的仓库中。
我感觉这个安全问题确实要特别注意!
windows下安装
pip安装
pip install -U codexy
设置
E:\work\codexy>set OPENAI_API_KEY="你的硅基流动密钥"
E:\work\codexy>set OPENAI_BASE_URL="http:/192.168.1.5:1337/v1"
codexy启动
codexy "帮我分析一下这个 Python 项目的核心逻辑" -m deepseek-v3
$Env:OPENAI_API_KEY="你的硅基流动密钥"
$Env:OPENAI_BASE_URL="https://api.siliconflow.cn/v1"
# 或者在项目根目录创建 .env 文件写入:
OPENAI_API_KEY=你的硅基流动密钥
OPENAI_BASE_URL=https://api.siliconflow.cn/v1
set OPENAI_API_KEY="你的硅基流动密钥"
set OPENAI_BASE_URL="http:/192.168.1.5:1337/v1"
FreeBSD下安装
在192.168.0.109机器的普通用户下,直接:
$ python3.11 -m pip install codexy
bash切换到bash shell
配置环境变量
export OPENAI_API_KEY="你的key"
export OPENAI_BASE_URL="http://192.168.1.5:1337/v1"
这里使用了自建的AI 模型。
执行
python3.11 -m codexy "帮我写一个hello word" -m deepseek-v3
运行成功
哇塞,太不容易了,这几天一直调试codex和codexy,这是第一次看到输出结果:
调试
退出是Ctrl+q ,确认输入是Ctrl+回车
报错:Failed after unexpected error: 'ascii' codec
Agent Error: Error: Failed after unexpected error: 'ascii' codec can't encode characters in ▊
▎ position 8-15: ordinal not in range(128)
明白了,原来是key里面带了中文,改掉:
export OPENAI_API_KEY="test"
报错: Agent Error: Error: Failed after unexpected error:
大约是模型的问题,毕竟自建的服务器,有时候不太稳定。
换成gpt-4o模型