import logging | |
import sys | |
import gradio as gr | |
from dotenv import load_dotenv | |
from app.llama_index import Assistant | |
load_dotenv() | |
logging.basicConfig( | |
format="[%(asctime)s][%(levelname)s][%(name)s] %(message)s", | |
datefmt="%d/%m/%Y-%H:%M:%S", | |
stream=sys.stdout, | |
level=logging.INFO, | |
) | |
logger = logging.getLogger("app.app") | |
title = "Årsopgørelses Assistent" | |
description = "Assistent til at hjælpe med at besvare spørgsmål omkring årsopgørelsen" | |
examples = [ | |
"hvad er vigtigt at vide om årsopgørelsen?", | |
"hvordan beregnes årsopgørelsen?", | |
] | |
assistant = Assistant(data_dir="data", model_name="gpt-4") | |
def run(message: str, history: list[str]) -> str: | |
response = assistant(message, history=history) | |
return response | |
demo = gr.ChatInterface(fn=run, examples=examples, title=title, description=description) | |
demo.queue().launch() | |