YKajima commited on
Commit
38d8108
1 Parent(s): 5601afb
Files changed (1) hide show
  1. app.py +26 -19
app.py CHANGED
@@ -18,12 +18,26 @@ def extract_texts(input_str):
18
 
19
 
20
  async def summarize(input_text: str, input_url: str):
 
 
 
 
 
 
 
 
 
21
  if input_text:
22
  _prompt = f"""
23
- 以下の文章を要約してください。
24
- {input_text}
25
  """
26
- elif input_url:
 
 
 
 
 
27
  res = requests.get(input_url)
28
  soup = BeautifulSoup(res.text)
29
  url_content = soup.find('title').text + '\n' + soup.find('body').text
@@ -31,25 +45,18 @@ async def summarize(input_text: str, input_url: str):
31
  以下の文章を要約してください。
32
  {url_content}
33
  """
34
- else:
35
- return "テキストかURLを入力してください。"
36
 
37
- config = FilmConfig(
38
- "gpt-4-32k",
39
- api_type="azure",
40
- azure_deployment_id="gpt-4-32k",
41
- azure_api_version="2023-05-15",
42
- timeout=60.0, # これを入れないとtimeoutが頻繁に発生する
43
- )
44
- config.get_apikey()
45
 
46
- film = FilmCore(
47
- prompt=_prompt,
48
- system_prompt="あなたは優秀なライターです。",
49
- config=config
50
- )
51
 
52
- return await film.run_async()
53
 
54
 
55
  async def chat(input_text, input_url):
 
18
 
19
 
20
  async def summarize(input_text: str, input_url: str):
21
+ config = FilmConfig(
22
+ "gpt-4-32k",
23
+ api_type="azure",
24
+ azure_deployment_id="gpt-4-32k",
25
+ azure_api_version="2023-05-15",
26
+ timeout=60.0, # これを入れないとtimeoutが頻繁に発生する
27
+ )
28
+ config.get_apikey()
29
+
30
  if input_text:
31
  _prompt = f"""
32
+ 以下の文章を要約してください。
33
+ {input_text}
34
  """
35
+ return await FilmCore(
36
+ prompt=_prompt,
37
+ system_prompt="あなたは優秀なライターです。",
38
+ config=config
39
+ ).run_async()
40
+ if input_url:
41
  res = requests.get(input_url)
42
  soup = BeautifulSoup(res.text)
43
  url_content = soup.find('title').text + '\n' + soup.find('body').text
 
45
  以下の文章を要約してください。
46
  {url_content}
47
  """
 
 
48
 
49
+ res = await FilmCore(
50
+ prompt=_prompt,
51
+ system_prompt="あなたは優秀なライターです。",
52
+ config=config
53
+ ).run_async()
 
 
 
54
 
55
+ return res + '\n' + input_url
56
+
57
+ else:
58
+ return "テキストかURLを入力してください。"
 
59
 
 
60
 
61
 
62
  async def chat(input_text, input_url):