Code4 / app.py
Ankush05's picture
Update app.py
9b6cd87
raw
history blame contribute delete
538 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"])