Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import gradio as gr
|
3 |
+
import asyncio
|
4 |
+
|
5 |
+
from modules.input_processor import InputProcessor
|
6 |
+
from modules.task_decomposer import TaskDecomposer
|
7 |
+
from modules.parallel_executor import ParallelTaskExecutor
|
8 |
+
from modules.result_synthesizer import ResultSynthesizer
|
9 |
+
|
10 |
+
input_processor = InputProcessor()
|
11 |
+
decomposer = TaskDecomposer()
|
12 |
+
executor = ParallelTaskExecutor()
|
13 |
+
synthesizer = ResultSynthesizer()
|
14 |
+
|
15 |
+
async def process_all(text, image, video, output_lang):
|
16 |
+
context = await input_processor.process(text, image, video)
|
17 |
+
subtasks = await decomposer.decompose(context)
|
18 |
+
results = await executor.execute(subtasks)
|
19 |
+
summary = await synthesizer.synthesize(results, output_lang)
|
20 |
+
return summary
|
21 |
+
|
22 |
+
def main(text, image, video, output_lang):
|
23 |
+
return asyncio.run(process_all(text, image, video, output_lang))
|
24 |
+
|
25 |
+
iface = gr.Interface(
|
26 |
+
fn=main,
|
27 |
+
inputs=[
|
28 |
+
gr.Textbox(label="指示テキスト"),
|
29 |
+
gr.Image(label="画像ファイル (任意)", type="filepath", optional=True),
|
30 |
+
gr.Video(label="動画ファイル (任意)", optional=True),
|
31 |
+
gr.Dropdown(choices=["ja", "en", "es", "zh", "fr"], label="出力言語", value="ja")
|
32 |
+
],
|
33 |
+
outputs=gr.Textbox(label="出力結果"),
|
34 |
+
title="多言語・多モーダルWeb参照AIエージェント",
|
35 |
+
description="テキスト・画像・動画をもとにWeb情報を収集・統合し、指定言語で出力するAI"
|
36 |
+
)
|
37 |
+
|
38 |
+
if __name__ == "__main__":
|
39 |
+
iface.launch()
|