File size: 1,021 Bytes
a0b2f3c
4991a9b
a0b2f3c
33c1a1e
a0b2f3c
2036883
33c1a1e
a0b2f3c
c1a05e4
4991a9b
 
 
 
 
 
8bfc25a
4991a9b
 
 
 
 
930de57
4991a9b
 
 
 
 
 
 
aec0035
4991a9b
 
b3e85e9
 
4e98579
4991a9b
b3e85e9
33c1a1e
 
 
de2dd13
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
41
42
import gradio as gr
from spiralfilm import FilmCore, FilmConfig


def greet(name):
    return "こんにちは " + name + "さん!! \n僕はパスカルくんだよ。よろしくね"


async def summarize(text: str, textbox: str):    
    _prompt = f"""
    以下の文章を要約してください。
    {text}
    """

    config = FilmConfig(
        "gpt-3.5-turbo",
        api_type="azure",
        azure_deployment_id="gpt-35-turbo",
        azure_api_version="2023-05-15",
        timeout=60.0,  # これを入れないとtimeoutが頻繁に発生する
    )
    config.get_apikey()

    film = FilmCore(
        prompt=_prompt,
        system_prompt="あなたは優秀なライターです。",
        config=config
    )

    return await film.run_async()


async def chat(text, textbox):
    return await summarize(text, textbox)
        

iface = gr.Interface(fn=chat, inputs=["text", "textbox"], outputs="text")


if __name__ == "__main__":
    iface.launch(auth=("spiralai", "spiralai"), share=True)