Spaces:
Sleeping
Sleeping
Elia Wäfler
commited on
Commit
•
7f10a78
1
Parent(s):
c321b91
templates into app.py
Browse files
app.py
CHANGED
@@ -9,13 +9,56 @@ from langchain.vectorstores import faiss
|
|
9 |
from langchain.chat_models import ChatOpenAI
|
10 |
from langchain.memory import ConversationBufferMemory
|
11 |
from langchain.chains import ConversationalRetrievalChain
|
12 |
-
from html_templates import css, bot_template, user_template
|
13 |
from langchain.llms import HuggingFaceHub
|
14 |
import os
|
15 |
import pickle
|
16 |
from datetime import datetime
|
17 |
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
def get_pdf_text(pdf_docs):
|
20 |
text = ""
|
21 |
for pdf in pdf_docs:
|
|
|
9 |
from langchain.chat_models import ChatOpenAI
|
10 |
from langchain.memory import ConversationBufferMemory
|
11 |
from langchain.chains import ConversationalRetrievalChain
|
|
|
12 |
from langchain.llms import HuggingFaceHub
|
13 |
import os
|
14 |
import pickle
|
15 |
from datetime import datetime
|
16 |
|
17 |
|
18 |
+
css = '''
|
19 |
+
<style>
|
20 |
+
.chat-message {
|
21 |
+
padding: 1.5rem; border-radius: 0.5rem; margin-bottom: 1rem; display: flex
|
22 |
+
}
|
23 |
+
.chat-message.user {
|
24 |
+
background-color: #2b313e
|
25 |
+
}
|
26 |
+
.chat-message.bot {
|
27 |
+
background-color: #475063
|
28 |
+
}
|
29 |
+
.chat-message .avatar {
|
30 |
+
width: 20%;
|
31 |
+
}
|
32 |
+
.chat-message .avatar img {
|
33 |
+
max-width: 78px;
|
34 |
+
max-height: 78px;
|
35 |
+
border-radius: 50%;
|
36 |
+
object-fit: cover;
|
37 |
+
}
|
38 |
+
.chat-message .message {
|
39 |
+
width: 80%;
|
40 |
+
padding: 0 1.5rem;
|
41 |
+
color: #fff;
|
42 |
+
}
|
43 |
+
'''
|
44 |
+
bot_template = '''
|
45 |
+
<div class="chat-message bot">
|
46 |
+
<div class="avatar">
|
47 |
+
<img src="https://i.ibb.co/cN0nmSj/Screenshot-2023-05-28-at-02-37-21.png" style="max-height: 78px; max-width: 78px; border-radius: 50%; object-fit: cover;">
|
48 |
+
</div>
|
49 |
+
<div class="message">{{MSG}}</div>
|
50 |
+
</div>
|
51 |
+
'''
|
52 |
+
user_template = '''
|
53 |
+
<div class="chat-message user">
|
54 |
+
<div class="avatar">
|
55 |
+
<img src="https://i.ibb.co/rdZC7LZ/Photo-logo-1.png">
|
56 |
+
</div>
|
57 |
+
<div class="message">{{MSG}}</div>
|
58 |
+
</div>
|
59 |
+
'''
|
60 |
+
|
61 |
+
|
62 |
def get_pdf_text(pdf_docs):
|
63 |
text = ""
|
64 |
for pdf in pdf_docs:
|