关于 cc25a-openai-api-agent-project123123123
这是一个用于学习 OpenAI API Agent 开发的课程项目,提供 Agent 应用、MCP 服务及微调数据处理示例。适合学习相关开发流程的使用者。
主要功能
- 01运行 Agent 应用
- 02通过 Function Calling 定义函数
- 03将函数用作 MCP 工具
- 04准备并上传 SFT、DPO、RFT 数据
适用场景
- 01运行基于 OpenAI API 的 Agent 应用
- 02将项目函数提供给 MCP 客户端
- 03转换并上传微调数据
MCP 相关
项目中的 tools.py 函数可作为 MCP 工具,由 MCP 服务提供给客户端。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
服务地址
https://server.smithery.ai/@cc25a/openai-api-agent-project123123123/mcp一键复制安装命令
Claude CodeTerminal
claude mcp add --transport http ai-smithery-cc25a-openai-api-agent-project123123123 https://server.smithery.ai/@cc25a/openai-api-agent-project123123123/mcpCursor.cursor/mcp.json
{"mcpServers":{"ai-smithery-cc25a-openai-api-agent-project123123123":{"type":"http","url":"https://server.smithery.ai/@cc25a/openai-api-agent-project123123123/mcp"}}}在 Cursor 中打开VS Code.vscode/mcp.json
{"servers":{"ai-smithery-cc25a-openai-api-agent-project123123123":{"type":"http","url":"https://server.smithery.ai/@cc25a/openai-api-agent-project123123123/mcp"}}}在 VS Code 中打开Claude Desktopclaude_desktop_config.json
{"mcpServers":{"ai-smithery-cc25a-openai-api-agent-project123123123":{"type":"http","url":"https://server.smithery.ai/@cc25a/openai-api-agent-project123123123/mcp"}}}Windsurf~/.codeium/windsurf/mcp_config.json
{"mcpServers":{"ai-smithery-cc25a-openai-api-agent-project123123123":{"serverUrl":"https://server.smithery.ai/@cc25a/openai-api-agent-project123123123/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
全部服务地址
Streamable HTTP
https://server.smithery.ai/@cc25a/openai-api-agent-project123123123/mcp需要授权工具
详细介绍
OpenAI API Agent School - 项目
本资料是由 (주)에이아이캐슬制作的使用 OpenAI API 学习 Agent 开发入门 (OpenAI API Agent School)课程项目资料。
[0] 安装与构建(uv)
# uv Install
curl -LsSf https://astral.sh/uv/install.sh | sh
# uv Build
uv sync --frozen && uv cache prune --ci
[1] 项目配置
1.1. 环境变量(.env)
- 通过 .env 文件进行配置,或在部署环境中指定
OPENAI_API_KEY:Agent 应用或上传要进行微调的数据时使用的 OpenAI API 密钥PROMPT_ID:Agent 应用中使用的 OpenAI 提示词 IDTITLE:Agent 应用顶部的标题PASSWORD:设置密码(留空时,任何人都可以访问)- 在 Agent 应用中,必须登录才能访问
- 在 MCP 服务中,必须通过查询字符串传递,例如
?password=<your-password>
1.2. config.overrides.jsonc
- 在 Agent 应用中发送 OpenAI API 请求时,用于覆盖 responses create 中配置的值
- 通过 config.overrides.jsonc 文件进行配置,或在部署环境中指定
- 文件位置
- 项目文件夹(优先级较高)
- /etc/secrets/
1.3. tools.py
- 在 Agent 应用中通过 Function Calling 使用的函数。
- 或在 MCP 服务中作为工具使用的函数。
- 文件位置:tools.py
[2] 运行应用
运行
uv run main.py
-
端口:如果指定了环境变量
PORT的值,则使用该值;否则使用8000。 -
Agent 应用地址:https://localhost:8000/agent
-
MCP 服务地址:https://localhost:8000/mcp
KEEPALIVE_URL
- 如果运行中的应用在一段时间内没有访问而进入空闲状态,可以将
KEEPALIVE_URL设为 GitHub Actions 的环境变量(secrets),以执行定期访问的 cron 任务。 - 如果是 Fork 的仓库,请访问 Fork 的仓库,在顶部的 Actions 选项卡中启用 Actions,并启用 .github/workflows/keepalive-url.yml。
- 前往 Repository > settings > Secrets and Variables > Actions > New repository secret,并按如下方式输入(Secret 中填写你部署的 URL)
- 示例
- Name:
KEEPALIVE_URL - Secret:
https://<your-project-name>.onrender.com
- Name:
[3] 微调数据
必须在 .env文件中注册 OPENAI_API_KEY,才能正常上传
3.1. SFT(监督式微调)
- 文件夹位置:
fine_tuning_data/supervised/ - 生成并上传数据
uv run fine_tuning_data/supervised/convert_and_upload.py
3.2. DPO(直接偏好优化)
- 文件夹位置:
fine_tuning_data/preference/ - 生成并上传数据
uv run fine_tuning_data/preference/convert_and_upload.py
3.3. RFT(强化微调)
- 文件夹位置:
fine_tuning_data/reinforcement/ - 生成并上传数据
uv run fine_tuning_data/reinforcement/convert_and_upload.py
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。