momenaca commited on
Commit
2676f5d
1 Parent(s): 109ff5f

update main without loggingbutton to check HF bug

Browse files
Files changed (3) hide show
  1. app.py +41 -25
  2. eki_esrsqa/utils.py +0 -5
  3. pyproject.toml +1 -0
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import os
2
- import logging
3
  import gradio as gr
4
  from operator import itemgetter
5
  from pinecone import Pinecone
@@ -21,10 +20,6 @@ from eki_esrsqa.utils import (
21
  init_env,
22
  )
23
 
24
- logging.basicConfig(level=logging.INFO)
25
- logger = logging.getLogger(__name__)
26
-
27
-
28
  init_env()
29
  chat_model_init = get_llm()
30
  demo_name = "ESRS_QA"
@@ -197,23 +192,44 @@ def update_visible(oauth_token: gr.OAuthToken | None):
197
  }
198
 
199
 
200
- with gr.Blocks(title=f"{demo_name}", css=css) as demo:
201
- gr.LoginButton()
202
- gr.Markdown(f"<h1><center>{demo_name}</center></h1>")
 
 
 
203
 
204
- with gr.Column() as bloc_1:
205
- textbox_1 = gr.Textbox("You are not logged to Hugging Face !", show_label=False)
206
 
207
- with gr.Column(visible=False) as bloc_3:
208
- textbox_3 = gr.Textbox(
209
- "You are not part of the ESRS Q&A Project, ask access here : https://huggingface.co/ekimetrics-esrsqa"
210
- )
 
 
 
211
 
212
- with gr.Column(visible=False) as bloc_2:
 
 
 
 
 
 
 
 
 
 
 
 
213
  with gr.Row():
214
  with gr.Column(scale=2):
215
  chatbot = gr.Chatbot(
216
- elem_id="chatbot", label=f"{demo_name} chatbot", show_label=False
 
 
 
 
 
217
  )
218
  state = gr.State([])
219
 
@@ -227,15 +243,15 @@ with gr.Blocks(title=f"{demo_name}", css=css) as demo:
227
  gr.Markdown("### Sources")
228
  sources_textbox = gr.Markdown(show_label=False)
229
 
230
- ask.submit(
231
- fn=chat,
232
- inputs=[
233
- ask,
234
- state,
235
- ],
236
- outputs=[ask, chatbot, state, sources_textbox],
237
- )
238
- demo.load(update_visible, inputs=None, outputs=[bloc_1, bloc_2, bloc_3])
239
 
240
 
241
  demo.launch(
 
1
  import os
 
2
  import gradio as gr
3
  from operator import itemgetter
4
  from pinecone import Pinecone
 
20
  init_env,
21
  )
22
 
 
 
 
 
23
  init_env()
24
  chat_model_init = get_llm()
25
  demo_name = "ESRS_QA"
 
192
  }
193
 
194
 
195
+ # Set up Gradio Theme
196
+ theme = gr.themes.Base(
197
+ primary_hue="blue",
198
+ secondary_hue="red",
199
+ font=[gr.themes.GoogleFont("Poppins"), "ui-sans-serif", "system-ui", "sans-serif"],
200
+ )
201
 
 
 
202
 
203
+ init_prompt = """
204
+ Hello, I am ESRS Q&A, a conversational assistant designed to help you understand the content of European Sustainability Reporting Standards (ESRS). I will answer your questions based **on the official definition of each ESRS as well as guidelines**.
205
+ ⚠️ Limitations
206
+ *Please note that this chatbot is in an early stage phase, it is not perfect and may sometimes give irrelevant answers. If you are not satisfied with the answer, please ask a more specific question or report your feedback to help us improve the system.*
207
+
208
+ What do you want to learn ?
209
+ """
210
 
211
+
212
+ with gr.Blocks(title=f"{demo_name}", css=css, theme=theme) as demo:
213
+ # gr.LoginButton()
214
+ # with gr.Column() as bloc_1:
215
+ # textbox_1 = gr.Textbox("You are not logged to Hugging Face !", show_label=False)
216
+
217
+ # with gr.Column(visible=False) as bloc_3:
218
+ # textbox_3 = gr.Textbox(
219
+ # "You are not part of the ESRS Q&A Project, ask access here : https://huggingface.co/ekimetrics-esrsqa"
220
+ # )
221
+
222
+ with gr.Column(visible=True) as bloc_2:
223
+ gr.Markdown(f"<h1><center>{demo_name}</center></h1>")
224
  with gr.Row():
225
  with gr.Column(scale=2):
226
  chatbot = gr.Chatbot(
227
+ value=[(None, init_prompt)],
228
+ show_copy_button=True,
229
+ show_label=False,
230
+ elem_id="chatbot",
231
+ layout="panel",
232
+ avatar_images=(None, "https://i.ibb.co/YNyd5W2/logo4.png"),
233
  )
234
  state = gr.State([])
235
 
 
243
  gr.Markdown("### Sources")
244
  sources_textbox = gr.Markdown(show_label=False)
245
 
246
+ # demo.load(update_visible, inputs=None, outputs=[bloc_1, bloc_2, bloc_3])
247
+ ask.submit(
248
+ fn=chat,
249
+ inputs=[
250
+ ask,
251
+ state,
252
+ ],
253
+ outputs=[ask, chatbot, state, sources_textbox],
254
+ )
255
 
256
 
257
  demo.launch(
eki_esrsqa/utils.py CHANGED
@@ -1,20 +1,15 @@
1
  import os
2
- import logging
3
  from typing import Tuple, List
4
  from dotenv import load_dotenv
5
  from msal import ConfidentialClientApplication
6
  from langchain_openai import AzureChatOpenAI
7
  from langchain.schema import format_document
8
 
9
- logger = logging.getLogger(__name__)
10
-
11
 
12
  def init_env():
13
  try:
14
- logger.info("Loaded local env")
15
  load_dotenv()
16
  except:
17
- logger.info("Loaded HF env")
18
  pass
19
 
20
 
 
1
  import os
 
2
  from typing import Tuple, List
3
  from dotenv import load_dotenv
4
  from msal import ConfidentialClientApplication
5
  from langchain_openai import AzureChatOpenAI
6
  from langchain.schema import format_document
7
 
 
 
8
 
9
  def init_env():
10
  try:
 
11
  load_dotenv()
12
  except:
 
13
  pass
14
 
15
 
pyproject.toml CHANGED
@@ -4,6 +4,7 @@ version = "0.1.0"
4
  description = ""
5
  authors = ["Miguel Omenaca Muro <miguel.omenacamuro@ekimetrics.com>"]
6
  readme = "README.md"
 
7
 
8
  [tool.poetry.dependencies]
9
  python = ">=3.10,<3.13"
 
4
  description = ""
5
  authors = ["Miguel Omenaca Muro <miguel.omenacamuro@ekimetrics.com>"]
6
  readme = "README.md"
7
+ package-mode = false
8
 
9
  [tool.poetry.dependencies]
10
  python = ">=3.10,<3.13"