Skip to content

Commit 609472c

Browse files
committed
refactor more tests
1 parent 9e1ad02 commit 609472c

File tree

6 files changed

+8
-13
lines changed

6 files changed

+8
-13
lines changed

.DS_Store

0 Bytes
Binary file not shown.

src/utils/framework.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77

88
def chat(prompt, maxtokens):
99
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):
1311
vectorizer = TfidfVectorizer()
1412
vectors = vectorizer.fit_transform([sentence1, sentence2])
1513
similarity = cosine_similarity(vectors[0], vectors[1])[0][0]

src/utils/similarity.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/utils/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
def test_cos_sim():
5-
assert framework.validate.cosine_similarity_score("abc","abc")==1
5+
assert framework.cosine_similarity_score("abc","abc")==1

test/test_examples.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55

66
model = GPT4All(config.model)
77

8-
responsestates = framework.chat("how many states are in US", 100)
8+
response_states = framework.chat("how many states are in US", 100)
99
expected_number_of_states_response = "There are 50 states"
1010
# cosinesimularity = framework.cosine_similarity(responsestates,expected_number_of_states_response)
1111
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
1313

1414

1515
# a positive test validating reponse contains specific strings is included in the response(s)
1616
def test_contains():
1717

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")))
2020

2121
#a positive test validating a specific string is not included in the respons(s)
2222
def test_notcontains():

test/tests.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
print("response:"+responsestates)
99
numberofstates = "There are 50 states"
1010
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))
1313
def test_cosinesimularity():
1414
print("cosinesimularity="+str(cosinesimularity))
1515
assert cosinesimularity>0.6

0 commit comments

Comments
 (0)