Merge branch 'main' into feature/graph_recommandation
Browse files- app.py +37 -4
- climateqa/engine/chains/query_transformation.py +1 -1
- front/utils.py +0 -1
- style.css +29 -15
app.py
CHANGED
|
@@ -94,6 +94,21 @@ share_client = service.get_share_client(file_share_name)
|
|
| 94 |
user_id = create_user_id()
|
| 95 |
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
# Create vectorstore and retriever
|
| 99 |
vectorstore = get_pinecone_vectorstore(embeddings_function, index_name = os.getenv("PINECONE_API_INDEX"))
|
|
@@ -129,7 +144,7 @@ async def chat(query,history,audience,sources,reports,current_graphs):
|
|
| 129 |
if reports is None or len(reports) == 0:
|
| 130 |
reports = []
|
| 131 |
|
| 132 |
-
inputs = {"user_input": query,"audience": audience_prompt,"
|
| 133 |
result = agent.astream_events(inputs,version = "v1")
|
| 134 |
|
| 135 |
|
|
@@ -638,9 +653,27 @@ with gr.Blocks(title="Climate Q&A", css_paths=os.getcwd()+ "/style.css", theme=t
|
|
| 638 |
with gr.Tab("About",elem_classes = "max-height other-tabs"):
|
| 639 |
with gr.Row():
|
| 640 |
with gr.Column(scale=1):
|
| 641 |
-
|
| 642 |
-
|
| 643 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 644 |
|
| 645 |
|
| 646 |
def start_chat(query,history):
|
|
|
|
| 94 |
user_id = create_user_id()
|
| 95 |
|
| 96 |
|
| 97 |
+
CITATION_LABEL = "BibTeX citation for ClimateQ&A"
|
| 98 |
+
CITATION_TEXT = r"""@misc{climateqa,
|
| 99 |
+
author={Théo Alves Da Costa, Timothée Bohe},
|
| 100 |
+
title={ClimateQ&A, AI-powered conversational assistant for climate change and biodiversity loss},
|
| 101 |
+
year={2024},
|
| 102 |
+
howpublished= {\url{https://climateqa.com}},
|
| 103 |
+
}
|
| 104 |
+
@software{climateqa,
|
| 105 |
+
author = {Théo Alves Da Costa, Timothée Bohe},
|
| 106 |
+
publisher = {ClimateQ&A},
|
| 107 |
+
title = {ClimateQ&A, AI-powered conversational assistant for climate change and biodiversity loss},
|
| 108 |
+
}
|
| 109 |
+
"""
|
| 110 |
+
|
| 111 |
+
|
| 112 |
|
| 113 |
# Create vectorstore and retriever
|
| 114 |
vectorstore = get_pinecone_vectorstore(embeddings_function, index_name = os.getenv("PINECONE_API_INDEX"))
|
|
|
|
| 144 |
if reports is None or len(reports) == 0:
|
| 145 |
reports = []
|
| 146 |
|
| 147 |
+
inputs = {"user_input": query,"audience": audience_prompt,"sources_input":sources}
|
| 148 |
result = agent.astream_events(inputs,version = "v1")
|
| 149 |
|
| 150 |
|
|
|
|
| 653 |
with gr.Tab("About",elem_classes = "max-height other-tabs"):
|
| 654 |
with gr.Row():
|
| 655 |
with gr.Column(scale=1):
|
| 656 |
+
|
| 657 |
+
|
| 658 |
+
|
| 659 |
+
|
| 660 |
+
gr.Markdown("""
|
| 661 |
+
### More info
|
| 662 |
+
- See more info at [https://climateqa.com](https://climateqa.com/docs/intro/)
|
| 663 |
+
- Feedbacks on this [form](https://forms.office.com/e/1Yzgxm6jbp)
|
| 664 |
+
|
| 665 |
+
### Citation
|
| 666 |
+
""")
|
| 667 |
+
with gr.Accordion(CITATION_LABEL,elem_id="citation", open = False,):
|
| 668 |
+
# # Display citation label and text)
|
| 669 |
+
gr.Textbox(
|
| 670 |
+
value=CITATION_TEXT,
|
| 671 |
+
label="",
|
| 672 |
+
interactive=False,
|
| 673 |
+
show_copy_button=True,
|
| 674 |
+
lines=len(CITATION_TEXT.split('\n')),
|
| 675 |
+
)
|
| 676 |
+
|
| 677 |
|
| 678 |
|
| 679 |
def start_chat(query,history):
|
climateqa/engine/chains/query_transformation.py
CHANGED
|
@@ -191,11 +191,11 @@ def make_query_transform_node(llm,k_final=15):
|
|
| 191 |
# new_state["questions"] = new_questions
|
| 192 |
# new_state["remaining_questions"] = new_questions
|
| 193 |
|
|
|
|
| 194 |
new_state = {
|
| 195 |
"remaining_questions":new_questions,
|
| 196 |
"n_questions":len(new_questions),
|
| 197 |
}
|
| 198 |
-
|
| 199 |
return new_state
|
| 200 |
|
| 201 |
return transform_query
|
|
|
|
| 191 |
# new_state["questions"] = new_questions
|
| 192 |
# new_state["remaining_questions"] = new_questions
|
| 193 |
|
| 194 |
+
|
| 195 |
new_state = {
|
| 196 |
"remaining_questions":new_questions,
|
| 197 |
"n_questions":len(new_questions),
|
| 198 |
}
|
|
|
|
| 199 |
return new_state
|
| 200 |
|
| 201 |
return transform_query
|
front/utils.py
CHANGED
|
@@ -219,7 +219,6 @@ def make_html_figure_sources(source,i,img_str):
|
|
| 219 |
<img src="data:image/png;base64, { img_str }" alt="Alt text" />
|
| 220 |
<p class='ai-generated'>AI-generated description</p>
|
| 221 |
|
| 222 |
-
|
| 223 |
<p>{content}</p>
|
| 224 |
|
| 225 |
{relevancy_score}
|
|
|
|
| 219 |
<img src="data:image/png;base64, { img_str }" alt="Alt text" />
|
| 220 |
<p class='ai-generated'>AI-generated description</p>
|
| 221 |
|
|
|
|
| 222 |
<p>{content}</p>
|
| 223 |
|
| 224 |
{relevancy_score}
|
style.css
CHANGED
|
@@ -113,6 +113,8 @@ a {
|
|
| 113 |
color:#dc2626!important;
|
| 114 |
/* margin-right:1px; */
|
| 115 |
}
|
|
|
|
|
|
|
| 116 |
.card {
|
| 117 |
background-color: white;
|
| 118 |
border-radius: 10px;
|
|
@@ -326,21 +328,33 @@ footer {
|
|
| 326 |
/* ... add other mobile-specific styles ... */
|
| 327 |
}
|
| 328 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 329 |
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
}
|
| 333 |
-
|
| 334 |
-
body.dark .card-content h2{
|
| 335 |
-
color:#f4dbd3 !important;
|
| 336 |
-
}
|
| 337 |
-
|
| 338 |
-
body.dark .card-footer {
|
| 339 |
-
background-color: #404652;
|
| 340 |
-
}
|
| 341 |
|
| 342 |
-
|
| 343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
}
|
| 345 |
|
| 346 |
|
|
@@ -386,7 +400,7 @@ span.chatbot > p > img{
|
|
| 386 |
}
|
| 387 |
|
| 388 |
.card-image > .card-content{
|
| 389 |
-
background-color:#f1f7fa
|
| 390 |
}
|
| 391 |
|
| 392 |
|
|
@@ -497,7 +511,7 @@ span.chatbot > p > img{
|
|
| 497 |
border-top: 1px solid #db3434 !important; /* Blue color */
|
| 498 |
border-right: 1px solid #3498db !important; /* Blue color */
|
| 499 |
border-radius: 50%;
|
| 500 |
-
width: 20px;
|
| 501 |
height: 20px;
|
| 502 |
animation: spin 2s linear infinite;
|
| 503 |
display:inline-block;
|
|
|
|
| 113 |
color:#dc2626!important;
|
| 114 |
/* margin-right:1px; */
|
| 115 |
}
|
| 116 |
+
|
| 117 |
+
|
| 118 |
.card {
|
| 119 |
background-color: white;
|
| 120 |
border-radius: 10px;
|
|
|
|
| 328 |
/* ... add other mobile-specific styles ... */
|
| 329 |
}
|
| 330 |
|
| 331 |
+
@media (prefers-color-scheme: dark) {
|
| 332 |
+
.card{
|
| 333 |
+
background-color: #374151;
|
| 334 |
+
}
|
| 335 |
+
.card-image > .card-content{
|
| 336 |
+
background-color: rgb(55, 65, 81) !important;
|
| 337 |
+
}
|
| 338 |
|
| 339 |
+
.card-footer {
|
| 340 |
+
background-color: #404652;
|
| 341 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 342 |
|
| 343 |
+
.container > .wrap{
|
| 344 |
+
background-color: #374151 !important;
|
| 345 |
+
color:white !important;
|
| 346 |
+
}
|
| 347 |
+
.card-content h2{
|
| 348 |
+
color:#e7754f !important;
|
| 349 |
+
}
|
| 350 |
+
.doc-ref sup{
|
| 351 |
+
color:rgb(235 109 35)!important;
|
| 352 |
+
/* margin-right:1px; */
|
| 353 |
+
}
|
| 354 |
+
.card-footer span {
|
| 355 |
+
color:white !important;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
}
|
| 359 |
|
| 360 |
|
|
|
|
| 400 |
}
|
| 401 |
|
| 402 |
.card-image > .card-content{
|
| 403 |
+
background-color:#f1f7fa;
|
| 404 |
}
|
| 405 |
|
| 406 |
|
|
|
|
| 511 |
border-top: 1px solid #db3434 !important; /* Blue color */
|
| 512 |
border-right: 1px solid #3498db !important; /* Blue color */
|
| 513 |
border-radius: 50%;
|
| 514 |
+
width: 20px;
|
| 515 |
height: 20px;
|
| 516 |
animation: spin 2s linear infinite;
|
| 517 |
display:inline-block;
|