Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,33 @@ def kousei(csv_file, input_text):
|
|
| 43 |
# 各プロンプトをAPIに送信(この部分は実装に応じて修正が必要です)
|
| 44 |
prompts['response'] = prompts['prompt_after'].apply(get_chatgpt_response)
|
| 45 |
print(prompts['response'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
|
| 48 |
|
|
@@ -121,7 +148,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 121 |
with gr.Row():
|
| 122 |
inputs=gr.File(label="CSVファイルをアップロード")
|
| 123 |
outputs=gr.File(label="ダウンロード", file_count="singular")
|
| 124 |
-
gr.Button("
|
| 125 |
kousei,
|
| 126 |
inputs=[inputs,input_text_kousei],
|
| 127 |
outputs=[outputs]
|
|
@@ -133,5 +160,16 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 133 |
submit_button = gr.Button("音声ファイルを生成")
|
| 134 |
file_output = gr.File(label="ダウンロード")
|
| 135 |
submit_button.click(fn=text_to_speech, inputs=[file_input], outputs=[file_output])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
demo.launch(share=True)
|
| 137 |
|
|
|
|
| 43 |
# 各プロンプトをAPIに送信(この部分は実装に応じて修正が必要です)
|
| 44 |
prompts['response'] = prompts['prompt_after'].apply(get_chatgpt_response)
|
| 45 |
print(prompts['response'])
|
| 46 |
+
|
| 47 |
+
def check(csv_file, input_text):
|
| 48 |
+
prompt_text = input_text + "振り分けは全ての問題において、該当しない場合も含めて、必ず全問題、[id]に続けて結果を各フォーマットで返してください。[id]の後は改行しないで。[id]はリクエストと完全一致の形式で。(必ず[問題ID]が5つ表示されるはずです)指摘方法は、該当しない場合は「該当なし」、該当する場合は「該当あり」\n#リスト"
|
| 49 |
+
|
| 50 |
+
# CSVファイルを読み込む
|
| 51 |
+
df = pd.read_csv(csv_file)
|
| 52 |
+
# 'id'列のデータ型を文字列に変換
|
| 53 |
+
df['id'] = df['id'].astype(str)
|
| 54 |
+
# DataFrameを5行ごとに処理するためのグループ化
|
| 55 |
+
df['group_id'] = df.index // 5
|
| 56 |
+
grouped = df.groupby('group_id')
|
| 57 |
+
|
| 58 |
+
# 各グループに対してフォーマットされたプロンプトを作成
|
| 59 |
+
def create_prompt(group, base_prompt):
|
| 60 |
+
prompt = base_prompt
|
| 61 |
+
for _, row in group.iterrows():
|
| 62 |
+
prompt += f"\n[{row['id']}]\n{row['原稿']}"
|
| 63 |
+
print(prompt)
|
| 64 |
+
return prompt
|
| 65 |
+
|
| 66 |
+
# 各グループごとのプロンプトを生成
|
| 67 |
+
prompts = grouped.apply(lambda g: create_prompt(g, prompt_text))
|
| 68 |
+
prompts = prompts.reset_index(name='prompt_after')
|
| 69 |
+
|
| 70 |
+
# 各プロンプトをAPIに送信(この部分は実装に応じて修正が必要です)
|
| 71 |
+
prompts['response'] = prompts['prompt_after'].apply(get_chatgpt_response)
|
| 72 |
+
print(prompts['response'])
|
| 73 |
|
| 74 |
|
| 75 |
|
|
|
|
| 148 |
with gr.Row():
|
| 149 |
inputs=gr.File(label="CSVファイルをアップロード")
|
| 150 |
outputs=gr.File(label="ダウンロード", file_count="singular")
|
| 151 |
+
gr.Button("校正スタート").click(
|
| 152 |
kousei,
|
| 153 |
inputs=[inputs,input_text_kousei],
|
| 154 |
outputs=[outputs]
|
|
|
|
| 160 |
submit_button = gr.Button("音声ファイルを生成")
|
| 161 |
file_output = gr.File(label="ダウンロード")
|
| 162 |
submit_button.click(fn=text_to_speech, inputs=[file_input], outputs=[file_output])
|
| 163 |
+
with gr.Tab("カテゴリ分類分類"):
|
| 164 |
+
with gr.Column():
|
| 165 |
+
input_text_kousei = gr.Textbox(label="分類観点を入力してください。",value="xxxxxxxに関する内容の場合は「該当あり」と書いてください。")
|
| 166 |
+
with gr.Row():
|
| 167 |
+
inputs=gr.File(label="CSVファイルをアップロード")
|
| 168 |
+
outputs=gr.File(label="ダウンロード", file_count="singular")
|
| 169 |
+
gr.Button("分類スタート").click(
|
| 170 |
+
kousei,
|
| 171 |
+
inputs=[inputs,input_text_kousei],
|
| 172 |
+
outputs=[outputs]
|
| 173 |
+
)
|
| 174 |
demo.launch(share=True)
|
| 175 |
|