ai_service/README.md
Wang Xiuqiang a8a2c0c48d 初步实现 LLM调用生成排版 react 代码
1. 创建scripts,outputs文件夹,生成 layout 代码位于 scripts 下的generate_layout.py当中,生成结果保存在 outputs 下的 generated_code.jsx 当中
    2. 实现了根据 Prompt 生成指定的 react 代码
    3. 需要根据前端传递给后端的相关prompt来完善功能,故暂时未暴露给后端接口
2025-05-19 23:28:21 +08:00

23 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# ai_service
## LLM 调用部分
### 功能组件
使用 DeepSeek API 提供的 LLM大型语言模型功能用于生成 React 组件代码,主要服务于端午节活动海报的排版设计。当前实现的功能包括:
- **代码生成**根据提示prompt生成 React 组件代码,专注于排版位置(不包含样式描述)。
- **分层排版**:生成包含背景图层、主体图层、活动亮点和页脚的 React 组件
- **文件保存**:将生成的 React 代码保存到指定路径。
### 如何调用
1. **环境准备**
- 确保已安装 Python 环境和必要依赖(`openai`、`python-dotenv`等)。
- 在项目根目录的 `.env` 文件中配置 `DEEPSEEK_API_KEY`
2. **运行脚本**
- 直接运行 `generate_layout.py` 脚本:
```bash
python generate_layout.py
```
- 该脚本会自动调用 DeepSeek API 生成 React 组件代码,并将其保存到指定路径。
默认为``output/generated_code.jsx``,可以根据需要修改。