ssboost commited on
Commit
94d047f
ยท
verified ยท
1 Parent(s): 17c0a4f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -2,6 +2,7 @@ import pandas as pd
2
  from io import BytesIO
3
  import gradio as gr
4
  from gradio_client import Client
 
5
 
6
  # API ํด๋ผ์ด์–ธํŠธ ์ดˆ๊ธฐํ™”
7
  client = Client("https://ssboost-excel-ra-vector-db-test1.hf.space/--replicas/q77r3/")
@@ -28,19 +29,22 @@ def long_text_result(file):
28
  df = read_excel_data(file)
29
  longest_reviews = extract_longest_reviews(df)
30
 
31
- # ํŒŒ์ผ ๋‚ด์šฉ์„ BytesIO ๊ฐ์ฒด๋กœ ๋ณ€ํ™˜
32
- file_bytes = BytesIO()
33
- df.to_excel(file_bytes, index=False)
34
- file_bytes.seek(0)
35
 
36
  # API ํ˜ธ์ถœ์„ ํ†ตํ•ด ๋ถ„์„, ์ €์žฅ, ๋ฒกํ„ฐ DB ๋ฐ ์ธ๋ฑ์‹ฑ ์ง„ํ–‰
37
  result = client.predict(
38
- file_bytes,
39
  100,
40
  10,
41
  api_name="/analyze_and_initialize_db"
42
  )
43
 
 
 
 
44
  # ๋ถ„์„ ๊ฒฐ๊ณผ ์ฒ˜๋ฆฌ
45
  analysis = "์ƒํ’ˆ์˜ ์žฅ๋‹จ์  10๊ฐ€์ง€ ๋ถ„์„ ๊ฒฐ๊ณผ:\n" + str(result)
46
  return analysis
 
2
  from io import BytesIO
3
  import gradio as gr
4
  from gradio_client import Client
5
+ import tempfile
6
 
7
  # API ํด๋ผ์ด์–ธํŠธ ์ดˆ๊ธฐํ™”
8
  client = Client("https://ssboost-excel-ra-vector-db-test1.hf.space/--replicas/q77r3/")
 
29
  df = read_excel_data(file)
30
  longest_reviews = extract_longest_reviews(df)
31
 
32
+ # ์ž„์‹œ ํŒŒ์ผ ์ƒ์„ฑ ๋ฐ ์ €์žฅ
33
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".xlsx") as tmp_file:
34
+ df.to_excel(tmp_file.name, index=False)
35
+ tmp_file_path = tmp_file.name
36
 
37
  # API ํ˜ธ์ถœ์„ ํ†ตํ•ด ๋ถ„์„, ์ €์žฅ, ๋ฒกํ„ฐ DB ๋ฐ ์ธ๋ฑ์‹ฑ ์ง„ํ–‰
38
  result = client.predict(
39
+ tmp_file_path,
40
  100,
41
  10,
42
  api_name="/analyze_and_initialize_db"
43
  )
44
 
45
+ # ์ž„์‹œ ํŒŒ์ผ ์‚ญ์ œ
46
+ os.remove(tmp_file_path)
47
+
48
  # ๋ถ„์„ ๊ฒฐ๊ณผ ์ฒ˜๋ฆฌ
49
  analysis = "์ƒํ’ˆ์˜ ์žฅ๋‹จ์  10๊ฐ€์ง€ ๋ถ„์„ ๊ฒฐ๊ณผ:\n" + str(result)
50
  return analysis