-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.py
122 lines (96 loc) · 5.29 KB
/
test.py
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from short_term_memory import get_short_term_memory, write_short_term_memory, append_history
from openai_api import get_openai_response
from dynamo_api import get_quota, put_quota, get_last_intro_message_timestamp, put_last_intro_message_timestamp, get_last_privacy_accepted_timestamp, put_last_privacy_accepted_timestamp, get_is_private_mode_on, put_private_mode, get_is_unsafe_mode_on, put_unsafe_mode, get_last_unsafe_accepted_timestamp, put_last_unsafe_accepted_timestamp
from commands import google_search, is_google_search_safe
print("Testing dynamoDB integration")
print("testing metadata retreival")
put_last_intro_message_timestamp("dummy", 0, "test")
print(get_last_intro_message_timestamp("dummy", "test"), "Should be 0")
put_last_intro_message_timestamp("dummy", 100, "test")
print(get_last_intro_message_timestamp("dummy", "test"), "Should be 100")
put_last_privacy_accepted_timestamp("dummy", 0, "test")
print(get_last_privacy_accepted_timestamp("dummy", "test"), "Should be 0")
put_last_privacy_accepted_timestamp("dummy", 100, "test")
print(get_last_privacy_accepted_timestamp("dummy", "test"), "Should be 100")
print(get_last_intro_message_timestamp("dummy", "test"), "Should still be 100")
put_private_mode("dummy", False, "test")
print(get_is_private_mode_on("dummy", "test"), "Should be False")
put_private_mode("dummy", True, "test")
print(get_is_private_mode_on("dummy", "test"), "Should be True")
put_unsafe_mode("dummy", False, "test")
print(get_is_unsafe_mode_on("dummy", "test"), "Should be False")
put_unsafe_mode("dummy", True, "test")
print(get_is_unsafe_mode_on("dummy", "test"), "Should be True")
put_last_unsafe_accepted_timestamp("dummy", 0, "test")
print(get_last_unsafe_accepted_timestamp("dummy", "test"), "Should be 0")
put_last_unsafe_accepted_timestamp("dummy", 100, "test")
print(get_last_unsafe_accepted_timestamp("dummy", "test"), "Should be 100")
print("putting and getting quota")
put_quota("dummy", 100)
print(get_quota("dummy"), "Should be 100")
print(get_short_term_memory("dummy", "test"), "should be empty")
write_short_term_memory("dummy", [], "test", is_private_on=False)
print(get_short_term_memory("dummy", "test"), "should be empty")
h = append_history([], "user", "Hello")
write_short_term_memory("dummy", h, "test", is_private_on=False)
print(get_short_term_memory("dummy", "test"), "should have hello")
h = append_history(h, "system", "Hello, how are you?")
write_short_term_memory("dummy", h, "test", is_private_on=False)
print(get_short_term_memory("dummy", "test"), "should have hello, hello, how are you?")
h = append_history(h, "user", "I am good. THIS SHOULD NOT BE PRINTED")
write_short_term_memory("dummy", h, "test", is_private_on=True)
print(get_short_term_memory("dummy", "test"), "should have hello, hello, how are you?, nothing more")
print("Testing openAI integration with history")
print(get_openai_response("Hello", h))
print("Testing basic openAI integration")
response, _ = get_openai_response("Hello", [])
print("Got response to hello", response)
if len(response) < 1:
raise Exception("Sorry, no response was found")
print("===========================")
print("Testing google search")
search_results = google_search("what is the latest news")
print("Search results for current weather in london: ",len(search_results.split(" ")), "words")
if len(search_results) < 1:
raise Exception("Sorry, no search results were found")
print("===========================")
print("Testing google search safety")
x = is_google_search_safe("current weather in london")
print("Is current weather in london safe?", x)
if x != True:
raise Exception("Incorrect google search safety")
x = is_google_search_safe("how can i kill someone")
print("Is how can i kill someone safe?", x)
if x != False:
raise Exception("Incorrect google search safety")
print("===========================")
print("Test web search examples")
response, command = get_openai_response("what is the current weather in london", [])
print(response, command)
if command['command_name'] != 'web_search':
raise Exception("Web search command not found")
response, command = get_openai_response("what is the current traffic condition in delhi", [])
print(response, command)
if command['command_name'] != 'web_search':
raise Exception("Web search command not found")
response, command = get_openai_response("who won the snooker match today", [])
print(response, command)
if command['command_name'] != 'web_search':
raise Exception("Web search command not found")
print("===========================")
print("Test image generation examples")
response, command = get_openai_response("can you create an image of a cat", [])
print(response, command)
if command['command_name'] != 'dalle':
raise Exception("dalle command not found")
response, command = get_openai_response(
"give me an image of a dog with a long tail travelling in a sapceship near mars", [])
print(response, command)
if command['command_name'] != 'dalle':
raise Exception("dalle command not found")
response, command = get_openai_response(
"I would like an image painted in the style of Picasso about the Indian city of Varanasi on a sunny day, river side with boats, an upscale hotel balcony, and kites in the sky", [])
print(response, command)
if command['command_name'] != 'dalle':
raise Exception("dalle command not found")
print("===========================")