File size: 1,456 Bytes
badc6f3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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()