Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -194,13 +194,27 @@ def extract_information(api_key, prompt, examples_json, input_text, template_nam
|
|
| 194 |
"extractions": extractions_list
|
| 195 |
}
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
# 保存文件
|
| 198 |
with tempfile.NamedTemporaryFile(mode='w+', delete=False, suffix='.jsonl', encoding='utf-8') as tmp_file:
|
| 199 |
if isinstance(results, list):
|
| 200 |
-
|
|
|
|
| 201 |
else:
|
| 202 |
-
|
|
|
|
| 203 |
download_path = tmp_file.name
|
|
|
|
|
|
|
|
|
|
| 204 |
|
| 205 |
stats = generate_statistics(output_dict)
|
| 206 |
history = save_to_history(input_text, output_dict, template_name)
|
|
|
|
| 194 |
"extractions": extractions_list
|
| 195 |
}
|
| 196 |
|
| 197 |
+
# 保存文件
|
| 198 |
+
#with tempfile.NamedTemporaryFile(mode='w+', delete=False, suffix='.jsonl', encoding='utf-8') as tmp_file:
|
| 199 |
+
#if isinstance(results, list):
|
| 200 |
+
#lx.io.save_annotated_documents(results, file_path=tmp_file.name)
|
| 201 |
+
#else:
|
| 202 |
+
#lx.io.save_annotated_documents([results], file_path=tmp_file.name)
|
| 203 |
+
#download_path = tmp_file.name
|
| 204 |
+
|
| 205 |
+
|
| 206 |
# 保存文件
|
| 207 |
with tempfile.NamedTemporaryFile(mode='w+', delete=False, suffix='.jsonl', encoding='utf-8') as tmp_file:
|
| 208 |
if isinstance(results, list):
|
| 209 |
+
# 修正:直接传递路径作为第二个参数
|
| 210 |
+
lx.io.save_annotated_documents(results, tmp_file.name)
|
| 211 |
else:
|
| 212 |
+
# 修正:直接传递路径作为第二个参数
|
| 213 |
+
lx.io.save_annotated_documents([results], tmp_file.name)
|
| 214 |
download_path = tmp_file.name
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
|
| 218 |
|
| 219 |
stats = generate_statistics(output_dict)
|
| 220 |
history = save_to_history(input_text, output_dict, template_name)
|