cmpatino's picture
Setup loggging for question and answer
950ed53
raw
history blame
1.26 kB
import os
import logging
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):
logging.info(f"Query: {query}")
answer = agent.answer(query=query)
logging.info(f"Answer: {answer}")
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
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/).
"""
title = "Career Chatbot"
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",
)
iface.launch()