Spaces:
Sleeping
Sleeping
import os | |
import gradio as gr | |
import pkg_resources | |
from dotenv import load_dotenv | |
load_dotenv() | |
def package_installed(package_name): | |
try: | |
pkg_resources.get_distribution(package_name) | |
except pkg_resources.DistributionNotFound: | |
return False | |
else: | |
return True | |
def answer(query): | |
answer = agent.answer(query=query) | |
return answer | |
if not package_installed("cv_assistant"): | |
os.system("pip install cv_assistant-0.1-py2.py3-none-any.whl") | |
from cv_assistant.agent import Agent # noqa: E402 | |
agent = Agent( | |
faiss_index_path="./content_assets/docs.index", | |
faise_store_path="./content_assets/faiss_store.pkl", | |
) | |
description = """ | |
### Ask about my experience, skills, and education! | |
I built this using [Gradio](https://gradio.app) and [LangChain](https://langchain.readthedocs.io/en/latest/). | |
""" # noqa: E501 | |
title = "Career Chatbot" | |
hf_writer = gr.HuggingFaceDatasetSaver(os.getenv("HF_TOKEN"), "cv-assistant-logging") | |
iface = gr.Interface( | |
fn=answer, | |
inputs=gr.Textbox( | |
value="What's his experience in recommender systems?", label="Question" | |
), | |
outputs=gr.Textbox(label="Answer"), | |
description=description, | |
title=title, | |
analytics_enabled=True, | |
allow_flagging="auto", | |
flagging_callback=hf_writer, | |
) | |
iface.launch() | |