Spaces:
Sleeping
Sleeping
Commit ·
5d2c61c
1
Parent(s): c915a90
Add app.py and dependencies
Browse files
app.py
CHANGED
|
@@ -2,41 +2,55 @@
|
|
| 2 |
import streamlit as st
|
| 3 |
import pickle
|
| 4 |
import numpy as np
|
| 5 |
-
|
| 6 |
import os
|
| 7 |
|
| 8 |
-
downloads_path = '/Users/preethamreddygollapalli/Downloads/model_test_steps.pkl'
|
| 9 |
-
|
| 10 |
-
# Load the saved model
|
| 11 |
-
with open(downloads_path, 'rb') as file:
|
| 12 |
-
model_test_steps = pickle.load(file)
|
| 13 |
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
predicted_steps = model_test_steps.predict(input_array)
|
| 19 |
-
return predicted_steps[0][0] # Adjust according to the model's output structure
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
st.write("Enter the test case criteria below to generate test steps and expected results:")
|
| 25 |
|
| 26 |
-
|
| 27 |
-
user_input = st.text_area("Input Test Case Criteria", "")
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
else:
|
| 42 |
-
st.warning("Please
|
|
|
|
| 2 |
import streamlit as st
|
| 3 |
import pickle
|
| 4 |
import numpy as np
|
| 5 |
+
import huggingface_hub import hf_hub_url, cached_download
|
| 6 |
import os
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def load_model():
|
| 10 |
+
repo_id = 'Preethamreddy799/NLP_MODEL'
|
| 11 |
+
filename = 'model_test_steps.pkl'
|
| 12 |
|
| 13 |
+
# Get model URL and download
|
| 14 |
+
model_url = hf_hub_url(repo_id=repo_id, filename=filename)
|
| 15 |
+
cached_model_path = cached_download(model_url)
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
# Load the model from the cached path
|
| 18 |
+
with open(cached_model_path, 'rb') as file:
|
| 19 |
+
model = pickle.load(file)
|
| 20 |
|
| 21 |
+
print(f"Model loaded successfully from {cached_model_path}")
|
| 22 |
+
return model
|
|
|
|
| 23 |
|
| 24 |
+
model = load_model()
|
|
|
|
| 25 |
|
| 26 |
+
# Function to generate predictions
|
| 27 |
+
def generate_test_steps(acceptance_criteria, test_data):
|
| 28 |
+
# Example input preprocessing (tokenization/embedding logic should match training)
|
| 29 |
+
input_features = np.array([len(acceptance_criteria), len(test_data)]).reshape(1, -1)
|
| 30 |
|
| 31 |
+
# Generate prediction
|
| 32 |
+
predicted_steps = model.predict(input_features)
|
| 33 |
+
return predicted_steps
|
| 34 |
|
| 35 |
+
# Streamlit App
|
| 36 |
+
st.title("Test Case Steps Generator")
|
| 37 |
+
st.write("This app generates test steps based on Test Case Acceptance Criteria and Test Data.")
|
| 38 |
|
| 39 |
+
# Input section
|
| 40 |
+
acceptance_criteria = st.text_area("Enter Test Case Acceptance Criteria", "")
|
| 41 |
+
test_data = st.text_area("Enter Test Data", "")
|
| 42 |
+
|
| 43 |
+
# Generate Test Steps
|
| 44 |
+
if st.button("Generate Test Steps"):
|
| 45 |
+
if acceptance_criteria and test_data:
|
| 46 |
+
if model:
|
| 47 |
+
# Call the function to generate predictions
|
| 48 |
+
test_steps = generate_test_steps(acceptance_criteria, test_data)
|
| 49 |
+
|
| 50 |
+
# Display the results
|
| 51 |
+
st.subheader("Generated Test Steps")
|
| 52 |
+
st.write(test_steps)
|
| 53 |
+
else:
|
| 54 |
+
st.error("Model not loaded. Please check the model repository and file.")
|
| 55 |
else:
|
| 56 |
+
st.warning("Please fill in both Acceptance Criteria and Test Data.")
|