quoc-khanh's picture
Update app.py
77263a0 verified
raw
history blame
1.63 kB
import os
import gradio as gr
import json
from tqdm import tqdm
from langchain_community.vectorstores import FAISS
from langchain_google_genai import GoogleGenerativeAIEmbeddings
import google.generativeai as genai
from helpers import (
list_docx_files, get_splits, get_json_splits_only, get_answer
)
os.environ["USER_AGENT"] = "gradio-hf-space"
if "GOOGLE_API_KEY" not in os.environ:
os.environ["GOOGLE_API_KEY"] = "AIzaSyDJ4vIKuIBIPNHATLxnoHlagXWbsAz-vRs"
key = "AIzaSyDJ4vIKuIBIPNHATLxnoHlagXWbsAz-vRs"
###
# Cấu hình API key cho Google GenAI
genai.configure(api_key=key)
institutions = ['Tất cả'] + ['Trường Công Nghệ']
categories = ['Tất cả'] + ['Đề án', 'Chương trình đào tạo']
with gr.Blocks() as demo:
with gr.Row():
category1 = gr.Dropdown(choices = institutions, label="Trường", value = 'Tất cả')
category2 = gr.Dropdown(choices = categories, label="Bạn quan tâm tới", value = 'Tất cả')
chat_interface = gr.ChatInterface(get_answer,
textbox=gr.Textbox(placeholder="Đặt câu hỏi tại đây",
container=False,
autoscroll=True,
scale=7),
type="messages",
# textbox=prompt,
# additional_inputs=[category1, category2]
)
if __name__ == "__main__":
demo.launch(share=True)