File size: 2,295 Bytes
e499a0f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'''
import requests
import os

# Function to load the pre-trained KNN model
def load_knn_model_expected():
    github_url = "https://raw.githubusercontent.com/PreethamGollapalli/QA-Test-steps-generation-project/main/knn_model_expected%20(2).joblib"
    
    response = requests.get(github_url)
    if response.status_code == 200:
        # Save the file locally
        with open("knn_model_expected.joblib", "wb") as f:
            f.write(response.content)
        # Load the model
        knn_model_expected = joblib.load("knn_model_expected.joblib")
        # Optionally, clean up the local file
        os.remove("knn_model_expected.joblib")
        return knn_model_expected
    else:
        raise Exception(f"Failed to download the file: {response.status_code}")

def load_knn_model_steps ():
    github_url = "https://raw.githubusercontent.com/PreethamGollapalli/QA-Test-steps-generation-project/main/knn_model_steps%20(2).joblib"
    
    response = requests.get(github_url)
    if response.status_code == 200:
        # Save the file locally
        with open("knn_model_steps.joblib", "wb") as f:
            f.write(response.content)
        # Load the model
        knn_model_steps = joblib.load("knn_model_steps.joblib")
        # Optionally, clean up the local file
        os.remove("knn_model_steps.joblib")
        return knn_model_steps
    else:
        raise Exception(f"Failed to download the file: {response.status_code}")

def load_tfidf_vectorizer():
    github_url = "https://raw.githubusercontent.com/PreethamGollapalli/QA-Test-steps-generation-project/main/tfidf_vectorizer%20(3).pkl"
    
    response = requests.get(github_url)
    if response.status_code == 200:
        # Save the file locally
        with open("tfidf_vectorizer.pkl", "wb") as f:
            f.write(response.content)
        # Load the model
        vectorizer = joblib.load("tfidf_vectorizer.pkl")
        # Optionally, clean up the local file
        os.remove("tfidf_vectorizer.pkl")
        return vectorizer
    else:
        raise Exception(f"Failed to download the file: {response.status_code}")
'''

# Load models (KNN model and embedding model)
'''
knn_model_steps = load_knn_model_steps()
knn_model_results = load_knn_model_expected()
tfidf_vectorizer = load_tfidf_vectorizer()
'''