# Python 代码库 **Repository Path**: ye-jing1/python-code-library ## Basic Information - **Project Name**: Python 代码库 - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-09-15 - **Last Updated**: 2026-09-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 01-deepseek-api-demo 基于 OpenAI 兼容接口的 LLM API 对话演示项目(智谱 GLM)。 ## 功能 - 通过 `openai` SDK 调用智谱 GLM API(OpenAI 兼容协议) - 终端流式对话:输入问题,流式输出回答 - 使用 `python-dotenv` 从本地 `.env` 读取密钥配置,密钥不入库 ## 环境准备 1. 安装依赖: ```bash pip install -r requirements.txt ``` 2. 配置密钥:复制 `.env.example` 为 `.env`,填入你自己的 API Key: ``` ZHIPU_API_KEY="你的智谱APIKey" ZHIPU_BASE_URL="https://open.bigmodel.cn/api/paas/v4" ZHIPU_MODEL="glm-4-flash" ``` ## 运行 ```bash python 01_Zcode_api_demo.py ``` 输入问题后回车即可看到流式回答。 ## 文件说明 | 文件 | 说明 | | --- | --- | | `01_Zcode_api_demo.py` | 主程序:流式对话演示 | | `main.py` | 简单测试入口 | | `requirements.txt` | 依赖清单 | | `.env.example` | 环境变量模板(不含密钥) | | `.gitignore` | 忽略规则(`.env`、`.venv`、`.idea` 等不入库) |