Update main.py
Browse files
main.py
CHANGED
@@ -19,22 +19,22 @@ from langchain.schema.runnable import Runnable, RunnablePassthrough, RunnableLam
|
|
19 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
20 |
from langchain_core.prompts import PromptTemplate
|
21 |
|
22 |
-
|
23 |
-
def auth_callback(username: str, password: str):
|
24 |
-
auth = json.loads(os.environ['CHAINLIT_AUTH_LOGIN'])
|
25 |
-
ident = next(d['ident'] for d in auth if d['ident'] == username)
|
26 |
-
pwd = next(d['pwd'] for d in auth if d['ident'] == username)
|
27 |
-
resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(ident.encode('utf-8'), bcrypt.gensalt()))
|
28 |
-
resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(pwd.encode('utf-8'), bcrypt.gensalt()))
|
29 |
-
resultRole = next(d['role'] for d in auth if d['ident'] == username)
|
30 |
-
if resultLogAdmin and resultPwdAdmin and resultRole == "admindatapcc":
|
31 |
-
return cl.User(
|
32 |
-
identifier=ident + " : 🧑💼 Admin Datapcc", metadata={"role": "admin", "provider": "credentials"}
|
33 |
-
)
|
34 |
-
elif resultLogAdmin and resultPwdAdmin and resultRole == "userdatapcc":
|
35 |
-
return cl.User(
|
36 |
-
identifier=ident + " : 🧑🎓 User Datapcc", metadata={"role": "user", "provider": "credentials"}
|
37 |
-
)
|
38 |
|
39 |
@cl.author_rename
|
40 |
def rename(orig_author: str):
|
@@ -52,16 +52,16 @@ async def chat_profile():
|
|
52 |
async def start():
|
53 |
await cl.Message(f"> REVIEWSTREAM").send()
|
54 |
await cl.Message(f"Nous avons le plaisir de vous accueillir dans l'application de recherche et d'analyse des publications.").send()
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
settings = await cl.ChatSettings(
|
66 |
[
|
67 |
Select(
|
|
|
19 |
from langchain.prompts import ChatPromptTemplate, MessagesPlaceholder
|
20 |
from langchain_core.prompts import PromptTemplate
|
21 |
|
22 |
+
#@cl.password_auth_callback
|
23 |
+
#def auth_callback(username: str, password: str):
|
24 |
+
# auth = json.loads(os.environ['CHAINLIT_AUTH_LOGIN'])
|
25 |
+
# ident = next(d['ident'] for d in auth if d['ident'] == username)
|
26 |
+
# pwd = next(d['pwd'] for d in auth if d['ident'] == username)
|
27 |
+
# resultLogAdmin = bcrypt.checkpw(username.encode('utf-8'), bcrypt.hashpw(ident.encode('utf-8'), bcrypt.gensalt()))
|
28 |
+
# resultPwdAdmin = bcrypt.checkpw(password.encode('utf-8'), bcrypt.hashpw(pwd.encode('utf-8'), bcrypt.gensalt()))
|
29 |
+
# resultRole = next(d['role'] for d in auth if d['ident'] == username)
|
30 |
+
# if resultLogAdmin and resultPwdAdmin and resultRole == "admindatapcc":
|
31 |
+
# return cl.User(
|
32 |
+
# identifier=ident + " : 🧑💼 Admin Datapcc", metadata={"role": "admin", "provider": "credentials"}
|
33 |
+
# )
|
34 |
+
# elif resultLogAdmin and resultPwdAdmin and resultRole == "userdatapcc":
|
35 |
+
# return cl.User(
|
36 |
+
# identifier=ident + " : 🧑🎓 User Datapcc", metadata={"role": "user", "provider": "credentials"}
|
37 |
+
# )
|
38 |
|
39 |
@cl.author_rename
|
40 |
def rename(orig_author: str):
|
|
|
52 |
async def start():
|
53 |
await cl.Message(f"> REVIEWSTREAM").send()
|
54 |
await cl.Message(f"Nous avons le plaisir de vous accueillir dans l'application de recherche et d'analyse des publications.").send()
|
55 |
+
listPrompts_name = f"Liste des revues de recherche"
|
56 |
+
contentPrompts = """<p><img src='/public/hal-logo-header.png' width='32' align='absmiddle' /> <strong> Hal Archives Ouvertes</strong> : Une archive ouverte est un réservoir numérique contenant des documents issus de la recherche scientifique, généralement déposés par leurs auteurs, et permettant au grand public d'y accéder gratuitement et sans contraintes.
|
57 |
+
</p>
|
58 |
+
<p><img src='/public/logo-persee.png' width='32' align='absmiddle' /> <strong>Persée</strong> : offre un accès libre et gratuit à des collections complètes de publications scientifiques (revues, livres, actes de colloques, publications en série, sources primaires, etc.) associé à une gamme d'outils de recherche et d'exploitation.</p>
|
59 |
+
"""
|
60 |
+
prompt_elements = []
|
61 |
+
prompt_elements.append(
|
62 |
+
cl.Text(content=contentPrompts, name=listPrompts_name, display="side")
|
63 |
+
)
|
64 |
+
await cl.Message(content="📚 " + listPrompts_name, elements=prompt_elements).send()
|
65 |
settings = await cl.ChatSettings(
|
66 |
[
|
67 |
Select(
|