Spaces:
Runtime error
Runtime error
import gradio as gr | |
import pandas as pd | |
import numpy as np | |
import os | |
import time | |
import re | |
import json | |
from auditqa.sample_questions import QUESTIONS | |
from auditqa.engine.prompts import audience_prompts | |
from auditqa.reports import POSSIBLE_REPORTS, files | |
from auditqa.doc_process import process_pdf | |
from langchain_core.messages import ( | |
HumanMessage, | |
SystemMessage, | |
) | |
from langchain_huggingface import ChatHuggingFace | |
from langchain_core.output_parsers import StrOutputParser | |
from langchain_huggingface import HuggingFaceEndpoint | |
from dotenv import load_dotenv | |
load_dotenv() | |
HF_token = os.environ["HF_TOKEN"] | |
process_pdf() | |
# -------------------------------------------------------------------- | |
# Gradio | |
# -------------------------------------------------------------------- | |
# Set up Gradio Theme | |
theme = gr.themes.Base( | |
primary_hue="blue", | |
secondary_hue="red", | |
font=[gr.themes.GoogleFont("Poppins"), "ui-sans-serif", "system-ui", "sans-serif"], | |
text_size = gr.themes.utils.sizes.text_sm, | |
) | |
init_prompt = """ | |
Hello, I am Audit Q&A, a conversational assistant designed to help you understand audit Reports. I will answer your questions by using **Audit reports publishsed by Auditor General Office**. | |
💡 How to use (tabs on right) | |
- **Reports**: You can choose to address your question to either specific report or a collection of report like District or Ministry focused reports. \ | |
If you dont select any then the Consolidated report is relied upon to answer your question. | |
- **Examples**: We have curated some example questions,select a particular question from category of questions. | |
- **Sources**: This tab will display the relied upon paragraphs from the report, to help you in assessing or fact checking if the answer provided by Audit Q&A assitant is correct or not. | |
⚠️ For limitations of the tool please check **Disclaimer** tab. | |
""" | |
with gr.Blocks(title="Audit Q&A", css= "style.css", theme=theme,elem_id = "main-component") as demo: | |
# user_id_state = gr.State([user_id]) | |
with gr.Tab("AuditQ&A"): | |
with gr.Row(elem_id="chatbot-row"): | |
with gr.Column(scale=2): | |
# state = gr.State([system_template]) | |
chatbot = gr.Chatbot( | |
value=[(None,init_prompt)], | |
show_copy_button=True,show_label = False,elem_id="chatbot",layout = "panel", | |
avatar_images = (None,"data-collection.png"), | |
)#,avatar_images = ("assets/logo4.png",None)) | |
# bot.like(vote,None,None) | |
with gr.Row(elem_id = "input-message"): | |
textbox=gr.Textbox(placeholder="Ask me anything here!",show_label=False,scale=7,lines = 1,interactive = True,elem_id="input-textbox") |