Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,32 +5,33 @@ 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 |
df = pd.read_pickle('BookData_emb.pkl')
|
14 |
df_emb = df[['์ํ์๋ฒ ๋ฉ']].copy()
|
15 |
|
16 |
|
17 |
def recommend(message):
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
|
|
26 |
|
27 |
gr.ChatInterface(
|
28 |
fn=recommend,
|
29 |
textbox=gr.Textbox(placeholder="๋ง๊ฑธ์ด์ฃผ์ธ์..", container=False, scale=7),
|
30 |
-
title=
|
31 |
-
description=
|
32 |
theme="soft",
|
33 |
-
examples=
|
34 |
retry_btn="๋ค์๋ณด๋ด๊ธฐ โฉ",
|
35 |
undo_btn="์ด์ ์ฑ ์ญ์ โ",
|
36 |
clear_btn="์ ์ฑ ์ญ์ ๐ซ").launch()
|
|
|
5 |
|
6 |
title = "๐๊ณ ๋ฏผ ํด๊ฒฐ ๋์ ์ถ์ฒ ์ฑ๋ด๐"
|
7 |
description = "๊ณ ๋ฏผ์ด ๋ฌด์์ธ๊ฐ์? ๊ณ ๋ฏผ ํด๊ฒฐ์ ๋์์ค ์ฑ
์ ์ถ์ฒํด๋๋ฆฝ๋๋ค"
|
8 |
+
examples = [["์์ฆ ์ ์ด ์ ์จ๋ค"], ["ํ๋ถ์ด ์ ์๋ผ์ง ์์"]]
|
9 |
|
10 |
|
11 |
+
# model = SentenceTransformer('jhgan/ko-sroberta-multitask')
|
12 |
|
13 |
df = pd.read_pickle('BookData_emb.pkl')
|
14 |
df_emb = df[['์ํ์๋ฒ ๋ฉ']].copy()
|
15 |
|
16 |
|
17 |
def recommend(message):
|
18 |
+
text = df_emb['์ํ์๋ฒ ๋ฉ'][0]
|
19 |
+
# embedding = model.encode(message)
|
20 |
+
# df_emb['๊ฑฐ๋ฆฌ'] = df_emb['์ํ์๋ฒ ๋ฉ'].map(lambda x: cosine_similarity([embedding], [x]).squeeze())
|
21 |
+
# answer = df.loc[df_emb['๊ฑฐ๋ฆฌ'].idxmax()]
|
22 |
+
# Book_title = answer['์ ๋ชฉ']
|
23 |
+
# Book_author = answer['์๊ฐ']
|
24 |
+
# Book_publisher = answer['์ถํ์ฌ']
|
25 |
+
# Book_comment = answer['์ํ']
|
26 |
+
return message + text
|
27 |
|
28 |
gr.ChatInterface(
|
29 |
fn=recommend,
|
30 |
textbox=gr.Textbox(placeholder="๋ง๊ฑธ์ด์ฃผ์ธ์..", container=False, scale=7),
|
31 |
+
title=title,
|
32 |
+
description=description,
|
33 |
theme="soft",
|
34 |
+
examples=examples,
|
35 |
retry_btn="๋ค์๋ณด๋ด๊ธฐ โฉ",
|
36 |
undo_btn="์ด์ ์ฑ ์ญ์ โ",
|
37 |
clear_btn="์ ์ฑ ์ญ์ ๐ซ").launch()
|