Spaces:
Sleeping
Sleeping
Reinserted question-answering instead of text-generation
Browse files
app.py
CHANGED
|
@@ -2,8 +2,8 @@ import streamlit as st
|
|
| 2 |
from transformers import pipeline
|
| 3 |
#from datasets import load_dataset
|
| 4 |
|
| 5 |
-
|
| 6 |
-
pipe = pipeline("text-generation")
|
| 7 |
|
| 8 |
st.title("Adrega AI Help")
|
| 9 |
#dataset = load_dataset("andreska/adregadocs", split="test")
|
|
@@ -12,9 +12,11 @@ context = "Adrega is a very cool company, that implements AI. Rett fra Rio is a
|
|
| 12 |
user_input = st.text_input('Ask me a question')
|
| 13 |
if st.button("Submit"):
|
| 14 |
if user_input:
|
| 15 |
-
text_inputs = f"Context: {context}\nQuestion: {user_input}\nAnswer:"
|
| 16 |
-
result = pipe(text_inputs, max_length=200, num_return_sequences=1)[0]['generated_text']
|
| 17 |
-
answer = result.split("Answer:")[1].strip()
|
|
|
|
|
|
|
| 18 |
st.write(f"Adrega AI: {answer}")
|
| 19 |
else:
|
| 20 |
st.write("Please enter a question.")
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
#from datasets import load_dataset
|
| 4 |
|
| 5 |
+
pipe = pipeline("question-answering")
|
| 6 |
+
#pipe = pipeline("text-generation")
|
| 7 |
|
| 8 |
st.title("Adrega AI Help")
|
| 9 |
#dataset = load_dataset("andreska/adregadocs", split="test")
|
|
|
|
| 12 |
user_input = st.text_input('Ask me a question')
|
| 13 |
if st.button("Submit"):
|
| 14 |
if user_input:
|
| 15 |
+
#text_inputs = f"Context: {context}\nQuestion: {user_input}\nAnswer:"
|
| 16 |
+
#result = pipe(text_inputs, max_length=200, num_return_sequences=1)[0]['generated_text']
|
| 17 |
+
#answer = result.split("Answer:")[1].strip()
|
| 18 |
+
|
| 19 |
+
answer = pipe(question=user_input, context=context)
|
| 20 |
st.write(f"Adrega AI: {answer}")
|
| 21 |
else:
|
| 22 |
st.write("Please enter a question.")
|