Spaces:
Running
Running
File size: 1,316 Bytes
a834a31 d8ed01f a834a31 d8ed01f a834a31 aa32697 d8ed01f 950ed53 d8ed01f a834a31 82fc382 a834a31 d8ed01f 82fc382 d8ed01f bf81858 d8ed01f bf81858 d8ed01f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
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()
|