Spaces:
Sleeping
Sleeping
add tab
Browse files- pages/recommendations.py +19 -20
pages/recommendations.py
CHANGED
@@ -84,7 +84,7 @@ with col1:
|
|
84 |
query = st.text_area('Введите запрос, чтобы получить рекомендации', f'{text}', height=95)
|
85 |
with col2:
|
86 |
number = st.number_input(
|
87 |
-
"Сколько книг найти?", value=
|
88 |
)
|
89 |
find_button = st.button('Найти', key='find_button', use_container_width=True)
|
90 |
|
@@ -99,25 +99,24 @@ if find_button and query:
|
|
99 |
with col2:
|
100 |
st.subheader(f"{row['title']}")
|
101 |
st.write(f"**Автор:** {row['author']}")
|
102 |
-
st.
|
103 |
-
|
104 |
-
|
105 |
-
with col1:
|
106 |
st.metric(label="Схожесть", value=f"{row['similarity_score']:.3f}")
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
st.write("---")
|
123 |
|
|
|
84 |
query = st.text_area('Введите запрос, чтобы получить рекомендации', f'{text}', height=95)
|
85 |
with col2:
|
86 |
number = st.number_input(
|
87 |
+
"Сколько книг найти?", value=3
|
88 |
)
|
89 |
find_button = st.button('Найти', key='find_button', use_container_width=True)
|
90 |
|
|
|
99 |
with col2:
|
100 |
st.subheader(f"{row['title']}")
|
101 |
st.write(f"**Автор:** {row['author']}")
|
102 |
+
tab1, tab2 = st.tabs(['Аннотация', 'Краткое содержание'])
|
103 |
+
with tab1:
|
104 |
+
st.write(row['annotation'])
|
|
|
105 |
st.metric(label="Схожесть", value=f"{row['similarity_score']:.3f}")
|
106 |
+
st.write(f"**Ссылка:** {row['page_url']}")
|
107 |
+
with tab2:
|
108 |
+
template = "ты умеешь кратко в несколько предложений описывать содержание книги по ее названию"
|
109 |
+
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
|
110 |
+
human_template = "Кратко опиши содержание книги под названием: {book_title}"
|
111 |
+
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
|
112 |
+
chat_prompt = ChatPromptTemplate.from_messages(
|
113 |
+
[system_message_prompt, human_message_prompt]
|
114 |
+
)
|
115 |
+
formatted_prompt = chat_prompt.format_prompt(
|
116 |
+
book_title=row['title']
|
117 |
+
)
|
118 |
+
response = chat(formatted_prompt.to_messages())
|
119 |
+
st.write(response.content)
|
120 |
+
st.write("---")
|
121 |
st.write("---")
|
122 |
|