tugaa's picture
Create app.py
badc6f3 verified
# app.py
import gradio as gr
import asyncio
from modules.input_processor import InputProcessor
from modules.task_decomposer import TaskDecomposer
from modules.parallel_executor import ParallelTaskExecutor
from modules.result_synthesizer import ResultSynthesizer
input_processor = InputProcessor()
decomposer = TaskDecomposer()
executor = ParallelTaskExecutor()
synthesizer = ResultSynthesizer()
async def process_all(text, image, video, output_lang):
context = await input_processor.process(text, image, video)
subtasks = await decomposer.decompose(context)
results = await executor.execute(subtasks)
summary = await synthesizer.synthesize(results, output_lang)
return summary
def main(text, image, video, output_lang):
return asyncio.run(process_all(text, image, video, output_lang))
iface = gr.Interface(
fn=main,
inputs=[
gr.Textbox(label="指示テキスト"),
gr.Image(label="画像ファイル (任意)", type="filepath", optional=True),
gr.Video(label="動画ファイル (任意)", optional=True),
gr.Dropdown(choices=["ja", "en", "es", "zh", "fr"], label="出力言語", value="ja")
],
outputs=gr.Textbox(label="出力結果"),
title="多言語・多モーダルWeb参照AIエージェント",
description="テキスト・画像・動画をもとにWeb情報を収集・統合し、指定言語で出力するAI"
)
if __name__ == "__main__":
iface.launch()