Spaces:
Running
Running
Update README.md
Browse files
README.md
CHANGED
@@ -1,220 +1,9 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
2. **Concept Decomposition and Visualization**
|
12 |
-
- Break down complex problems into basic concepts
|
13 |
-
- Visualize concept relationships through tree diagrams or network graphs
|
14 |
-
- Intuitively display dependencies and connections between concepts
|
15 |
-
|
16 |
-
3. **Interactive Learning Experience**
|
17 |
-
- Click on any sub-concept to get detailed explanations
|
18 |
-
- View targeted examples and exercises
|
19 |
-
- Get recommendations for relevant learning resources
|
20 |
-
|
21 |
-
4. **Progress Saving and Caching**
|
22 |
-
- Cache generated concept explanations to improve response speed
|
23 |
-
- Save learning records for easy review and revision
|
24 |
-
|
25 |
-
## Installation and Running
|
26 |
-
|
27 |
-
### Prerequisites
|
28 |
-
|
29 |
-
- Python 3.7+
|
30 |
-
- pip (Python package manager)
|
31 |
-
|
32 |
-
```angular2html
|
33 |
-
conda create -n ai_new_dream python=3.11
|
34 |
-
pip install -r requirements.txt
|
35 |
-
export OPENAI_API_KEY="your-secret-api-key"
|
36 |
-
```
|
37 |
-
### Automatic Installation and Running
|
38 |
-
|
39 |
-
**Linux/Mac:**
|
40 |
-
```bash
|
41 |
-
# Add execution permission
|
42 |
-
chmod +x run.sh
|
43 |
-
|
44 |
-
# Run startup script
|
45 |
-
./run.sh
|
46 |
-
```
|
47 |
-
|
48 |
-
**Windows:**
|
49 |
-
```
|
50 |
-
# Double-click to run, or run in command prompt
|
51 |
-
run.bat
|
52 |
-
```
|
53 |
-
|
54 |
-
### Manual Installation and Running
|
55 |
-
|
56 |
-
```bash
|
57 |
-
# Create virtual environment
|
58 |
-
python -m venv venv
|
59 |
-
|
60 |
-
# Activate virtual environment
|
61 |
-
# On Windows:
|
62 |
-
venv\Scripts\activate
|
63 |
-
# On Linux/Mac:
|
64 |
-
source venv/bin/activate
|
65 |
-
|
66 |
-
# Install dependencies
|
67 |
-
pip install -r requirements.txt
|
68 |
-
|
69 |
-
# Run application
|
70 |
-
python app.py
|
71 |
-
```
|
72 |
-
|
73 |
-
## Project Structure
|
74 |
-
|
75 |
-
```
|
76 |
-
.
|
77 |
-
├── app.py # Main application file
|
78 |
-
├── prompts.py # LLM prompt templates
|
79 |
-
├── llm_utils.py # LLM utility functions
|
80 |
-
├── visualization.py # Concept graph visualization module
|
81 |
-
├── cache_utils.py # Caching utilities
|
82 |
-
├── concept_handler.js # JavaScript for concept click handling
|
83 |
-
├── requirements.txt # Project dependencies
|
84 |
-
├── run.sh # Linux/Mac startup script
|
85 |
-
└── run.bat # Windows startup script
|
86 |
-
```
|
87 |
-
|
88 |
-
## Integrated LLM
|
89 |
-
|
90 |
-
This application is integrated with the OpenAI API using the `gpt4omini` model. The implementation is in the `call_llm` function in the `llm_utils.py` file:
|
91 |
-
|
92 |
-
```python
|
93 |
-
def call_llm(prompt: str) -> str:
|
94 |
-
"""Call the OpenAI API with gpt4omini model"""
|
95 |
-
try:
|
96 |
-
from openai import OpenAI
|
97 |
-
client = OpenAI(api_key="YOUR_API_KEY")
|
98 |
-
response = client.chat.completions.create(
|
99 |
-
model="gpt4omini",
|
100 |
-
messages=[
|
101 |
-
{"role": "system", "content": "You are a helpful education assistant."},
|
102 |
-
{"role": "user", "content": prompt}
|
103 |
-
]
|
104 |
-
)
|
105 |
-
return response.choices[0].message.content
|
106 |
-
except Exception as e:
|
107 |
-
# Fallback to mock data if API call fails
|
108 |
-
print(f"Error calling OpenAI API: {e}")
|
109 |
-
# ...
|
110 |
-
```
|
111 |
-
|
112 |
-
If the API call fails, the system falls back to mock data to demonstrate functionality.
|
113 |
-
|
114 |
-
## Customization and Extension
|
115 |
-
|
116 |
-
- **Adding New Subjects**: Add new subject options in the `subject_input` options in `app.py`
|
117 |
-
- **Adjusting Prompt Templates**: Modify the prompt templates in `prompts.py` to implement specific teaching styles or methods
|
118 |
-
- **Enhancing Visualization**: Modify the visualization functions in `visualization.py` to implement richer concept graph representations
|
119 |
-
- **Changing LLM Model**: To use a different model, update the `model` parameter in the `call_llm` function in `llm_utils.py`
|
120 |
-
|
121 |
-
## Contributions and Feedback
|
122 |
-
|
123 |
-
Questions, suggestions, or code contributions are welcome to help improve this educational assistant platform!
|
124 |
-
|
125 |
-
## 教育LLM应用
|
126 |
-
|
127 |
-
这是一个基于大语言模型的教育应用,旨在帮助学生分解和理解复杂的学术概念。
|
128 |
-
|
129 |
-
### 功能特点
|
130 |
-
|
131 |
-
- 根据学生的年级和学科自动调整内容难度
|
132 |
-
- 将复杂问题分解为相互关联的子概念
|
133 |
-
- 生成可视化的知识图谱
|
134 |
-
- 为每个概念提供详细解释、示例、学习资源和练习题
|
135 |
-
|
136 |
-
### 如何运行
|
137 |
-
|
138 |
-
#### 使用脚本运行(推荐)
|
139 |
-
|
140 |
-
1. 确保您已安装Python 3.7或更高版本
|
141 |
-
2. 在终端中导航到项目目录
|
142 |
-
|
143 |
-
对于Mac/Linux用户:
|
144 |
-
```bash
|
145 |
-
chmod +x run.sh # 添加执行权限
|
146 |
-
./run.sh # 运行脚本
|
147 |
-
```
|
148 |
-
|
149 |
-
对于Windows用户:
|
150 |
-
```
|
151 |
-
run.bat
|
152 |
-
```
|
153 |
-
|
154 |
-
#### 手动设置
|
155 |
-
|
156 |
-
1. 创建并激活虚拟环境:
|
157 |
-
```bash
|
158 |
-
python -m venv venv
|
159 |
-
source venv/bin/activate # Mac/Linux
|
160 |
-
venv\Scripts\activate # Windows
|
161 |
-
```
|
162 |
-
|
163 |
-
2. 安装依赖:
|
164 |
-
```bash
|
165 |
-
pip install -r requirements.txt
|
166 |
-
```
|
167 |
-
|
168 |
-
3. 启动应用:
|
169 |
-
```bash
|
170 |
-
python app.py
|
171 |
-
```
|
172 |
-
|
173 |
-
### 配置OpenAI API
|
174 |
-
|
175 |
-
应用使用OpenAI API进行概念分解和解释。在`config.py`文件���设置您的API密钥:
|
176 |
-
|
177 |
-
```python
|
178 |
-
OPENAI_API_KEY = "您的API密钥" # 替换为您的实际API密钥
|
179 |
-
```
|
180 |
-
|
181 |
-
您也可以调整其他配置参数:
|
182 |
-
- `OPENAI_MODEL`: 要使用的OpenAI模型名称
|
183 |
-
- `OPENAI_TIMEOUT`: API调用超时时间(秒)
|
184 |
-
- `OPENAI_MAX_RETRIES`: 请求失败时的最大重试次数
|
185 |
-
- `DEBUG_MODE`: 是否启用调试输出
|
186 |
-
- `USE_FALLBACK_DATA`: API失败时是否使用备用数据
|
187 |
-
- `CACHE_ENABLED`: 是否启用响应缓存
|
188 |
-
|
189 |
-
### 系统架构
|
190 |
-
|
191 |
-
应用由以下主要组件组成:
|
192 |
-
|
193 |
-
1. **app.py** - 主应用文件,包含Gradio界面
|
194 |
-
2. **llm_utils.py** - LLM调用和处理函数
|
195 |
-
3. **visualization.py** - 知识图谱可视化
|
196 |
-
4. **prompts.py** - LLM提示模板
|
197 |
-
5. **cache_utils.py** - 响应缓存功能
|
198 |
-
6. **config.py** - 应用配置
|
199 |
-
7. **concept_handler.py** - 备用模拟数据(API失败时使用)
|
200 |
-
|
201 |
-
### 自定义和扩展
|
202 |
-
|
203 |
-
您可以通过以下方式自定义应用:
|
204 |
-
|
205 |
-
1. **添加新学科**: 扩展prompts.py中的领域特定提示
|
206 |
-
2. **调整提示模板**: 修改prompts.py中的系统和用户提示
|
207 |
-
3. **增强可视化**: 在visualization.py中调整知识图谱的生成
|
208 |
-
4. **更改模型**: 在config.py中指定不同的OpenAI模型
|
209 |
-
|
210 |
-
### 故障排除
|
211 |
-
|
212 |
-
如果遇到连接错误:
|
213 |
-
1. 检查您的API密钥是否正确
|
214 |
-
2. 确认您的网络连接正常
|
215 |
-
3. 检查模型名称是否正确(例如:"gpt-4o-mini")
|
216 |
-
4. 查看应用的调试输出(启用DEBUG_MODE)
|
217 |
-
|
218 |
-
### 贡献
|
219 |
-
|
220 |
-
欢迎提交问题报告和拉取请求来改进这个项目。
|
|
|
1 |
+
title: NexusLearnAI
|
2 |
+
emoji: 📊
|
3 |
+
colorFrom: gray
|
4 |
+
colorTo: gray
|
5 |
+
sdk: gradio
|
6 |
+
sdk_version: 5.23.1
|
7 |
+
app_file: app.py
|
8 |
+
pinned: false
|
9 |
+
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|