File size: 538 Bytes
505405b c13bc85 505405b 9b6cd87 95f3cec 9b6cd87 f7a043e b88db35 f7a043e b88db35 f7a043e c319c41 505405b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
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"])
|