File tree Expand file tree Collapse file tree 6 files changed +8
-13
lines changed Expand file tree Collapse file tree 6 files changed +8
-13
lines changed Original file line number Diff line number Diff line change 7
7
8
8
def chat (prompt , maxtokens ):
9
9
return model .generate (prompt , max_tokens = 100 )
10
-
11
- class validate :
12
- def cosine_similarity_score (sentence1 , sentence2 ):
10
+ def cosine_similarity_score (sentence1 , sentence2 ):
13
11
vectorizer = TfidfVectorizer ()
14
12
vectors = vectorizer .fit_transform ([sentence1 , sentence2 ])
15
13
similarity = cosine_similarity (vectors [0 ], vectors [1 ])[0 ][0 ]
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2
2
3
3
4
4
def test_cos_sim ():
5
- assert framework .validate . cosine_similarity_score ("abc" ,"abc" )== 1
5
+ assert framework .cosine_similarity_score ("abc" ,"abc" )== 1
Original file line number Diff line number Diff line change 5
5
6
6
model = GPT4All (config .model )
7
7
8
- responsestates = framework .chat ("how many states are in US" , 100 )
8
+ response_states = framework .chat ("how many states are in US" , 100 )
9
9
expected_number_of_states_response = "There are 50 states"
10
10
# cosinesimularity = framework.cosine_similarity(responsestates,expected_number_of_states_response)
11
11
def test_cosinesimularity ():
12
- assert framework .validate . cosine_similarity_score (responsestates , expected_number_of_states_response ) > 0.5
12
+ assert framework .cosine_similarity_score (response_states , expected_number_of_states_response ) > 0.5
13
13
14
14
15
15
# a positive test validating reponse contains specific strings is included in the response(s)
16
16
def test_contains ():
17
17
18
- assert (responsestates .__contains__ ("United States" ) and (responsestates .__contains__ ("50" )
19
- or responsestates .__contains__ ("fifty" )))
18
+ assert (response_states .__contains__ ("United States" ) and (response_states .__contains__ ("50" )
19
+ or response_states .__contains__ ("fifty" )))
20
20
21
21
#a positive test validating a specific string is not included in the respons(s)
22
22
def test_notcontains ():
Original file line number Diff line number Diff line change 8
8
print ("response:" + responsestates )
9
9
numberofstates = "There are 50 states"
10
10
print ("cosine simularity score:" )
11
- cosinesimularity = testFramwork .validate . cosine_similarity_score (responsestates , numberofstates )
12
- print (testFramwork .validate . cosine_similarity_score (responsestates , numberofstates ))
11
+ cosinesimularity = testFramwork .cosine_similarity_score (responsestates , numberofstates )
12
+ print (testFramwork .cosine_similarity_score (responsestates , numberofstates ))
13
13
def test_cosinesimularity ():
14
14
print ("cosinesimularity=" + str (cosinesimularity ))
15
15
assert cosinesimularity > 0.6
You can’t perform that action at this time.
0 commit comments