|
13 | 13 | delete_chat, get_chat_chart_data, get_chat_predict_data, get_chat_with_records_with_data, get_chat_record_by_id |
14 | 14 | from apps.chat.models.chat_model import CreateChat, ChatRecord, RenameChat, ChatQuestion, ExcelData |
15 | 15 | from apps.chat.task.llm import LLMService |
16 | | -from common.core.deps import CurrentAssistant, SessionDep, CurrentUser |
| 16 | +from common.core.deps import CurrentAssistant, SessionDep, CurrentUser, Trans |
17 | 17 |
|
18 | 18 | router = APIRouter(tags=["Data Q&A"], prefix="/chat") |
19 | 19 |
|
@@ -106,7 +106,7 @@ async def start_chat(session: SessionDep, current_user: CurrentUser): |
106 | 106 | async def recommend_questions(session: SessionDep, current_user: CurrentUser, chat_record_id: int, |
107 | 107 | current_assistant: CurrentAssistant): |
108 | 108 | def _return_empty(): |
109 | | - yield 'data:' + orjson.dumps( {'content': '[]', 'type': 'recommended_question'}).decode() + '\n\n' |
| 109 | + yield 'data:' + orjson.dumps({'content': '[]', 'type': 'recommended_question'}).decode() + '\n\n' |
110 | 110 |
|
111 | 111 | try: |
112 | 112 | record = get_chat_record_by_id(session, chat_record_id) |
@@ -201,10 +201,16 @@ def _err(_e: Exception): |
201 | 201 |
|
202 | 202 |
|
203 | 203 | @router.post("/excel/export") |
204 | | -async def export_excel(excel_data: ExcelData): |
| 204 | +async def export_excel(excel_data: ExcelData, trans: Trans): |
205 | 205 | def inner(): |
206 | 206 | _fields_list = [] |
207 | 207 | data = [] |
| 208 | + if not excel_data.data: |
| 209 | + raise HTTPException( |
| 210 | + status_code=500, |
| 211 | + detail=trans("i18n_excel_export.data_is_empty") |
| 212 | + ) |
| 213 | + |
208 | 214 | for _data in excel_data.data: |
209 | 215 | _row = [] |
210 | 216 | for field in excel_data.axis: |
|
0 commit comments