Spaces:
Sleeping
Sleeping
Commit
·
5bfab8c
1
Parent(s):
b16f688
this
Browse files
auth.py
CHANGED
|
@@ -38,7 +38,7 @@ def login():
|
|
| 38 |
flag = True
|
| 39 |
st.experimental_rerun()
|
| 40 |
else:
|
| 41 |
-
flag = False
|
| 42 |
if flag == False:
|
| 43 |
st.error("Invalid username or password")
|
| 44 |
st.stop()
|
|
|
|
| 38 |
flag = True
|
| 39 |
st.experimental_rerun()
|
| 40 |
else:
|
| 41 |
+
flag = False
|
| 42 |
if flag == False:
|
| 43 |
st.error("Invalid username or password")
|
| 44 |
st.stop()
|
chat.py
CHANGED
|
@@ -16,7 +16,7 @@ def Chat():
|
|
| 16 |
if ans["scores"][0] > 0.85:
|
| 17 |
st.session_state["user"] = "visitor"
|
| 18 |
with st.chat_message("assistant"):
|
| 19 |
-
"You are now sleeping in dream"
|
| 20 |
st.experimental_rerun()
|
| 21 |
else:
|
| 22 |
with st.chat_message("assistant"):
|
|
|
|
| 16 |
if ans["scores"][0] > 0.85:
|
| 17 |
st.session_state["user"] = "visitor"
|
| 18 |
with st.chat_message("assistant"):
|
| 19 |
+
"You are now sleeping in dream"
|
| 20 |
st.experimental_rerun()
|
| 21 |
else:
|
| 22 |
with st.chat_message("assistant"):
|
convo.py
CHANGED
|
@@ -11,7 +11,7 @@ def convo():
|
|
| 11 |
|
| 12 |
|
| 13 |
# candidate_labels = ["HELP", "PROBLEM SOLVE", "GENERAL TALK"]
|
| 14 |
-
|
| 15 |
|
| 16 |
ans = chatbot(conversation)
|
| 17 |
# add_user_input = st.button("Add User Input")
|
|
|
|
| 11 |
|
| 12 |
|
| 13 |
# candidate_labels = ["HELP", "PROBLEM SOLVE", "GENERAL TALK"]
|
| 14 |
+
|
| 15 |
|
| 16 |
ans = chatbot(conversation)
|
| 17 |
# add_user_input = st.button("Add User Input")
|
home.py
CHANGED
|
@@ -21,7 +21,7 @@ def dashboard():
|
|
| 21 |
"gfjfvjhvjhv"
|
| 22 |
elif selected == "Chat":
|
| 23 |
Chat()
|
| 24 |
-
elif selected == "Conversation":
|
| 25 |
convo()
|
| 26 |
elif selected == "Logout":
|
| 27 |
st.session_state["user"] = "visitor"
|
|
|
|
| 21 |
"gfjfvjhvjhv"
|
| 22 |
elif selected == "Chat":
|
| 23 |
Chat()
|
| 24 |
+
elif selected == "Conversation":
|
| 25 |
convo()
|
| 26 |
elif selected == "Logout":
|
| 27 |
st.session_state["user"] = "visitor"
|
qa.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import pipeline
|
| 2 |
+
import streamlit as st
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
# def que():
|
| 6 |
+
# question = st.text_input("ASk me a question")
|
| 7 |
+
|
| 8 |
+
# oracle = pipeline(task= "question-answering",model="deepset/roberta-base-squad2")
|
| 9 |
+
# oracle(question="Where do I live?", context="My name is Wolfgang and I live in Berlin")
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def question_answering(question, context):
|
| 13 |
+
"""Answers a question given a context."""
|
| 14 |
+
|
| 15 |
+
# Load the question answering model.
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
qa_model = pipeline("question-answering")
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
# Prepare the inputs for the model.
|
| 22 |
+
inputs = {
|
| 23 |
+
"question": question,
|
| 24 |
+
"context": context,
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
# Get the answer from the model.
|
| 28 |
+
output = qa_model(**inputs)
|
| 29 |
+
answer = output["answer_start"]
|
| 30 |
+
|
| 31 |
+
# Return the answer.
|
| 32 |
+
return context[answer : answer + output["answer_length"]]
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
if __name__ == "__main__":
|
| 36 |
+
# Get the question and context.
|
| 37 |
+
question = "What is the capital of France?"
|
| 38 |
+
context = "The capital of France is Paris."
|
| 39 |
+
|
| 40 |
+
# Get the answer.
|
| 41 |
+
answer = question_answering(question, context)
|
| 42 |
+
|
| 43 |
+
# Print the answer.
|
| 44 |
+
print(answer)
|