Update app.py
Browse files
app.py
CHANGED
@@ -1,20 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
|
10 |
|
11 |
-
|
12 |
|
13 |
-
def
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
gr.ChatInterface(
|
17 |
-
fn=
|
18 |
textbox=gr.Textbox(placeholder="๋ง๊ฑธ์ด์ฃผ์ธ์..", container=False, scale=7),
|
19 |
title="์ด๋ค ์ฑ๋ด์ ์ํ์ฌ๋ฏธ๊น?",
|
20 |
description="๋ฌผ์ด๋ณด๋ฉด ๋ตํ๋ ์ฑ๋ด์๋ฏธ๋ค.",
|
|
|
1 |
import gradio as gr
|
2 |
+
import pandas as pd
|
3 |
+
from sentence_transformers import SentenceTransformer
|
4 |
+
from sklearn.metrics.pairwise import cosine_similarity
|
5 |
|
6 |
+
title = "๐๊ณ ๋ฏผ ํด๊ฒฐ ๋์ ์ถ์ฒ ์ฑ๋ด๐"
|
7 |
+
description = "๊ณ ๋ฏผ์ด ๋ฌด์์ธ๊ฐ์? ๊ณ ๋ฏผ ํด๊ฒฐ์ ๋์์ค ์ฑ
์ ์ถ์ฒํด๋๋ฆฝ๋๋ค"
|
8 |
+
examples = [["์์ฆ ์ ์ด ์ ์จ๋ค"]]
|
9 |
|
10 |
|
11 |
+
model = SentenceTransformer('jhgan/ko-sroberta-multitask')
|
12 |
|
13 |
+
def recommend(message):
|
14 |
+
embedding = model.encode(message)
|
15 |
+
df_emb['๊ฑฐ๋ฆฌ'] = df_emb['์ํ์๋ฒ ๋ฉ'].map(lambda x: cosine_similarity([embedding], [x]).squeeze())
|
16 |
+
answer = df.loc[df_emb['๊ฑฐ๋ฆฌ'].idxmax()]
|
17 |
+
Book_title = answer['์ ๋ชฉ']
|
18 |
+
Book_author = answer['์๊ฐ']
|
19 |
+
Book_publisher = answer['์ถํ์ฌ']
|
20 |
+
Book_comment = answer['์ํ']
|
21 |
+
return Book_title
|
22 |
|
23 |
gr.ChatInterface(
|
24 |
+
fn=recommend,
|
25 |
textbox=gr.Textbox(placeholder="๋ง๊ฑธ์ด์ฃผ์ธ์..", container=False, scale=7),
|
26 |
title="์ด๋ค ์ฑ๋ด์ ์ํ์ฌ๋ฏธ๊น?",
|
27 |
description="๋ฌผ์ด๋ณด๋ฉด ๋ตํ๋ ์ฑ๋ด์๋ฏธ๋ค.",
|