Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
# ํ์ผ
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
|
| 36 |
# API ํธ์ถ์ ํตํด ๋ถ์, ์ ์ฅ, ๋ฒกํฐ DB ๋ฐ ์ธ๋ฑ์ฑ ์งํ
|
| 37 |
result = client.predict(
|
| 38 |
-
|
| 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
|