| import gradio as gr |
| import pandas as pd |
| import tempfile |
| import os |
| from chatgpt_api import get_chatgpt_response2 |
| from voice_create import text_to_speech |
| from select_question import create_choice_question |
| from manuscript_conversion import manuscript_conversion |
|
|
|
|
| def check(csv_file, input_text): |
| prompt_text = input_text + "該当しない場合は「該当なし」、該当する場合は「該当あり」としてください\n" |
| |
| df = pd.read_csv(csv_file) |
| |
| df['id'] = df['id'].astype(str) |
|
|
| df["prompt"] = prompt_text + df["原稿"] |
|
|
| df["分類結果"] = df["prompt"].apply(get_chatgpt_response2) |
| |
| |
| |
| with tempfile.NamedTemporaryFile(delete=False, suffix='.csv') as tmp: |
| df.to_csv(tmp.name, index=False, encoding='cp932', errors='ignore') |
| output_path = tmp.name |
| |
| |
| new_path = os.path.join(os.path.dirname(output_path), "output.csv") |
| os.rename(output_path, new_path) |
| return new_path |