Code4 / app.py
Ankush05's picture
this
95f3cec
raw
history blame
546 Bytes
import streamlit as st
from pymongo import MongoClient
import os
from transformers import pipeline
# uri = os.environ["MONGO_CONNECTION_STRING"]
# client = MongoClient(uri, tlsCertificateKeyFile="database/cert.pem")
# db = client["testing"]
# col = db["something"]
qna = pipeline("question-answering")
with open("knowledge.txt", "r") as file:
data = file.read()
knowledge = data
if query := st.chat_input("Question: "):
ans = qna(question=query, context=knowledge)
with st.chat_message("User"):
st.write(ans["answer"])