Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,33 +1,36 @@
|
|
| 1 |
-
import
|
| 2 |
-
from huggingface_hub import InferenceClient
|
| 3 |
-
import gradio as gr
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
return f"API connection successful! Response: {response}"
|
| 13 |
-
except Exception as e:
|
| 14 |
-
return f"Error: {str(e)}"
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
-
api_key = os.getenv("WingTokenAll")
|
| 19 |
-
if not api_key:
|
| 20 |
-
return "Error: wingTokenRead not found in environment variables."
|
| 21 |
-
return test_api_connection(query, api_key)
|
| 22 |
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
| 33 |
-
|
|
|
|
| 1 |
+
from transformers import pipeline
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Predefined context
|
| 4 |
+
context = """
|
| 5 |
+
The Scrum framework consists of Scrum Teams and their roles, events, and artifacts.
|
| 6 |
+
Scrum Teams are self-managing and cross-functional. The main roles include the Scrum Master,
|
| 7 |
+
Product Owner, and Development Team. The Daily Stand-up is a short meeting for the Scrum Team
|
| 8 |
+
to synchronize activities and create a plan for the next 24 hours.
|
| 9 |
+
"""
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
# Load the question-answering model
|
| 12 |
+
question_answerer = pipeline("question-answering", model='distilbert-base-cased-distilled-squad')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
+
|
| 15 |
+
def answer_question(question):
|
| 16 |
+
"""Answer the question based on the predefined context."""
|
| 17 |
+
result = question_answerer(question=question, context=context)
|
| 18 |
+
return result['answer']
|
| 19 |
+
|
| 20 |
+
def main():
|
| 21 |
+
print("Welcome to the Simple Q&A Agent!")
|
| 22 |
+
print("Type 'exit' to quit.\n")
|
| 23 |
+
|
| 24 |
+
while True:
|
| 25 |
+
user_input = input("Ask a question: ")
|
| 26 |
+
|
| 27 |
+
if user_input.lower() == 'exit':
|
| 28 |
+
print("Goodbye!")
|
| 29 |
+
break
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
answer = answer_question(user_input)
|
| 33 |
+
print(f"Answer: {answer}\n")
|
| 34 |
|
| 35 |
if __name__ == "__main__":
|
| 36 |
+
main()
|